All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 -- awesome 3 configuration file
3 AWESOME_DATADIR = "/home/madduck/code/awesome"
4 package.path = AWESOME_DATADIR .. "/lib/?.lua;" .. package.path
6 -- Include awesome library, with lots of useful function!
11 -- {{{ Variable definitions
12 -- This is a file path to a theme file which will defines colors.
13 theme_path = AWESOME_DATADIR .. "/themes/default"
15 -- This is used later as the default terminal to run.
16 terminal = "x-terminal-emulator"
19 -- Usually, Mod4 is the key with a logo between Control and Alt.
20 -- If you do not like this or do not have such a key,
21 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
22 -- However, you can use another modifier like Mod1, but it may interact with others.
25 -- Table of layouts to cover with awful.layout.inc, order matters.
39 -- Table of clients that should be set floating. The index may be either
40 -- the application class or instance. The instance is useful when running
41 -- a console app in a terminal like (Music on Console)
42 -- xterm -name mocp -e mocp
51 ["Play stream"] = true
54 -- Applications to be moved to a pre-defined tag by class or instance.
55 -- Use the screen and workspace indices.
58 ["Firefox"] = { screen = 1, tag = 9 },
59 ["jpilot"] = { screen = 1, tag = 8 },
62 -- Define if we want to use titlebar on all applications.
67 -- Initialize theme (colors).
68 beautiful.init(theme_path)
70 -- Register theme in awful.
71 -- This allows to not pass plenty of arguments to each function
72 -- to inform it about colors we want it to draw.
73 awful.beautiful.register(beautiful)
75 -- Uncomment this to activate autotabbing
76 -- tabulous.autotab_start()
82 for s = 1, screen.count() do
83 -- Each screen has its own tag table.
85 -- Create 9 tags per screen.
86 for tagnumber = 1, 9 do
87 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
88 -- Add tags to screen one by one
89 -- split at 0.5/50% exactly
90 tags[s][tagnumber].mwfact = 0.5
91 tags[s][tagnumber].screen = s
93 -- I'm sure you want to see at least one tag.
94 tags[s][1].selected = true
99 -- Create a taglist widget
100 mytaglist = widget({ type = "taglist", name = "mytaglist" })
101 mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
102 mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
103 mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
104 mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
105 mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
106 mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
107 mytaglist.label = awful.widget.taglist.label.all
109 -- Create a tasklist widget
110 mytasklist = widget({ type = "tasklist", name = "mytasklist" })
111 mytasklist:mouse_add(mouse({ }, 1, function (object, c) client.focus = c; c:raise() end))
112 mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focusbyidx(1) end))
113 mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focusbyidx(-1) end))
114 mytasklist.label = awful.widget.tasklist.label.currenttags
116 -- Create a textbox widget
117 mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
118 -- Set the default text in textbox
119 mytextbox.text = "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>"
120 mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
122 -- Create an iconbox widget
123 myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
124 myiconbox.text = "<bg image=\"" .. AWESOME_DATADIR .. "/icons/awesome16.png\" resize=\"true\"/>"
127 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
129 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
130 -- We need one layoutbox per screen.
132 for s = 1, screen.count() do
133 mylayoutbox[s] = widget({ type = "textbox", name = "mylayoutbox", align = "right" })
134 mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
135 mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
136 mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
137 mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
138 mylayoutbox[s].text = "<bg image=\"" .. AWESOME_DATADIR .. "/layouts/tilew.png\" resize=\"true\"/>"
141 -- Create a statusbar for each screen and add it
143 for s = 1, screen.count() do
144 mystatusbar[s] = statusbar({ position = "top", name = "mystatusbar" .. s,
145 fg = beautiful.fg_normal, bg = beautiful.bg_normal })
146 -- Add widgets to the statusbar - order matters
147 mystatusbar[s].widgets =
154 s == screen.count() and mysystray or nil
156 mystatusbar[s].screen = s
160 -- {{{ Mouse bindings
161 awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
162 awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
163 awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
168 -- Bind keyboard digits
169 -- Compute the maximum number of digit we need, limited to 9
171 for s = 1, screen.count() do
172 keynumber = math.min(9, math.max(#tags[s], keynumber));
175 for i = 1, keynumber do
176 keybinding({ modkey }, i,
178 local screen = mouse.screen
179 if tags[screen][i] then
180 awful.tag.viewonly(tags[screen][i])
183 keybinding({ modkey, "Control" }, i,
185 local screen = mouse.screen
186 if tags[screen][i] then
187 tags[screen][i].selected = not tags[screen][i].selected
190 keybinding({ modkey, "Shift" }, i,
192 local sel = client.focus
194 if tags[sel.screen][i] then
195 awful.client.movetotag(tags[sel.screen][i])
199 keybinding({ modkey, "Control", "Shift" }, i,
201 local sel = client.focus
203 if tags[sel.screen][i] then
204 awful.client.toggletag(tags[sel.screen][i])
210 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
211 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
212 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
215 keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
217 keybinding({ modkey, "Control" }, "r", awesome.restart):add()
218 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
220 -- Client manipulation
221 keybinding({ modkey }, "m", awful.client.maximize):add()
222 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
223 keybinding({ modkey }, "j", function () awful.client.focusbyidx(1); client.focus:raise() end):add()
224 keybinding({ modkey }, "k", function () awful.client.focusbyidx(-1); client.focus:raise() end):add()
225 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
226 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
227 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
228 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
229 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
230 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
231 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
232 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
233 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
235 -- Layout manipulation
236 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
237 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
238 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
239 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
240 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
241 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
242 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
243 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
246 keybinding({ modkey }, "F1", function ()
247 awful.prompt.run({ prompt = "Run: " }, mypromptbox, awful.spawn, awful.completion.bash,
248 os.getenv("HOME") .. "/.cache/awesome/history") end):add()
249 keybinding({ modkey }, "F4", function ()
250 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox, awful.eval, awful.prompt.bash,
251 os.getenv("HOME") .. "/.cache/awesome/history_eval") end):add()
252 keybinding({ modkey, "Ctrl" }, "i", function ()
253 if mypromptbox.text then
254 mypromptbox.text = nil
256 mypromptbox.text = "Class: " .. client.focus.class .. " Instance: ".. client.focus.instance
260 --- Tabulous, tab manipulation
261 keybinding({ modkey, "Control" }, "y", function ()
262 local tabbedview = tabulous.tabindex_get()
263 local nextclient = awful.client.next(1)
265 if not tabbedview then
266 tabbedview = tabulous.tabindex_get(nextclient)
268 if not tabbedview then
269 tabbedview = tabulous.tab_create()
270 tabulous.tab(tabbedview, nextclient)
272 tabulous.tab(tabbedview, client.focus)
275 tabulous.tab(tabbedview, nextclient)
279 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
281 keybinding({ modkey }, "y", function ()
282 local tabbedview = tabulous.tabindex_get()
285 local n = tabulous.next(tabbedview)
286 tabulous.display(tabbedview, n)
290 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
291 keybinding({ modkey }, "t", awful.client.togglemarked):add()
292 keybinding({ modkey, 'Shift' }, "t", function ()
293 local tabbedview = tabulous.tabindex_get()
294 local clients = awful.client.getmarked()
296 if not tabbedview then
297 tabbedview = tabulous.tab_create(clients[1])
298 table.remove(clients, 1)
301 for k,c in pairs(clients) do
302 tabulous.tab(tabbedview, c)
307 for i = 1, keynumber do
308 keybinding({ modkey, "Shift" }, "F" .. i,
310 local screen = mouse.screen
311 if tags[screen][i] then
312 for k, c in pairs(awful.client.getmarked()) do
313 awful.client.movetotag(tags[screen][i], c)
321 -- Hook function to execute when focusing a client.
322 function hook_focus(c)
323 if not awful.client.ismarked(c) then
324 c.border_color = beautiful.border_focus
328 -- Hook function to execute when unfocusing a client.
329 function hook_unfocus(c)
330 if not awful.client.ismarked(c) then
331 c.border_color = beautiful.border_normal
335 -- Hook function to execute when marking a client
336 function hook_marked(c)
337 c.border_color = beautiful.border_marked
340 -- Hook function to execute when unmarking a client
341 function hook_unmarked(c)
342 c.border_color = beautiful.border_focus
345 -- Hook function to execute when the mouse is over a client.
346 function hook_mouseover(c)
347 -- Sloppy focus, but disabled for magnifier layout
348 if awful.layout.get(c.screen) ~= "magnifier" then
353 -- Hook function to execute when a new client appears.
354 function hook_manage(c)
355 -- Set floating placement to be smart!
356 c.floating_placement = "smart"
359 awful.titlebar.add(c, { modkey = modkey })
361 -- Add mouse bindings
362 c:mouse_add(mouse({ }, 1, function (c) client.focus = c; c:raise() end))
363 c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
364 c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
365 -- New client may not receive focus
366 -- if they're not focusable, so set border anyway.
367 c.border_width = beautiful.border_width
368 c.border_color = beautiful.border_normal
371 -- Check if the application should be floating.
373 local inst = c.instance
374 if floatapps[cls] then
375 c.floating = floatapps[cls]
376 elseif floatapps[inst] then
377 c.floating = floatapps[inst]
380 -- Check application->screen/tag mappings.
383 target = apptags[cls]
384 elseif apptags[inst] then
385 target = apptags[inst]
388 c.screen = target.screen
389 awful.client.movetotag(tags[target.screen][target.tag], c)
393 c.honorsizehints = true
396 -- Hook function to execute when arranging the screen
397 -- (tag switch, new client, etc)
398 function hook_arrange(screen)
399 local layout = awful.layout.get(screen)
401 mylayoutbox[screen].text =
402 "<bg image=\"/home/madduck/code/awesome/share/awesome/icons/layouts/" .. awful.layout.get(screen) .. "w.png\" resize=\"true\"/>"
404 mylayoutbox[screen].text = "No layout."
407 -- If no window has focus, give focus to the latest in history
408 if not client.focus then
409 local c = awful.client.focus.history.get(screen, 0)
410 if c then client.focus = c end
413 -- Uncomment if you want mouse warping
415 local sel = client.focus
417 local c_c = sel.coords
418 local m_c = mouse.coords
420 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
421 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
422 if table.maxn(m_c.buttons) == 0 then
423 mouse.coords = { x = c_c.x + 5, y = c_c.y + 5}
430 -- Hook called every second
431 function hook_timer ()
432 -- For unix time_t lovers
433 -- mytextbox.text = " " .. os.time() .. " time_t "
435 mytextbox.text = " " .. os.date() .. " "
439 awful.hooks.focus.register(hook_focus)
440 awful.hooks.unfocus.register(hook_unfocus)
441 awful.hooks.marked.register(hook_marked)
442 awful.hooks.unmarked.register(hook_unmarked)
443 awful.hooks.manage.register(hook_manage)
444 awful.hooks.mouseover.register(hook_mouseover)
445 awful.hooks.arrange.register(hook_arrange)
446 awful.hooks.timer.register(1, hook_timer)
452 keybinding({ cmdmodkey }, "Prior", function () awful.spawn("amixer set Master 2+") end):add()
453 keybinding({ cmdmodkey }, "Next", function () awful.spawn("amixer set Master 2-") end):add()
454 keybinding({ cmdmodkey }, "Up", function () awful.spawn("amixer set PCM 2+") end):add()
455 keybinding({ cmdmodkey }, "Down", function () awful.spawn("amixer set PCM 2-") end):add()
456 keybinding({ cmdmodkey }, "Home", function () awful.spawn("amixer set Mic toggle") end):add()
457 keybinding({ cmdmodkey }, "End", function () awful.spawn("amixer set Master toggle") end):add()
458 keybinding({ cmdmodkey }, "Left", function () awful.spawn("xmms2 prev") end):add()
459 keybinding({ cmdmodkey }, "Right", function () awful.spawn("xmms2 next") end):add()
460 keybinding({ cmdmodkey }, "space", function () awful.spawn("xmms2 toggleplay") end):add()
461 keybinding({ cmdmodkey }, "backslash", function () awful.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
462 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
465 keybinding({ cmdmodkey }, "n", function () awful.spawn("sensible-browser") end):add()
466 keybinding({ cmdmodkey }, "m", function () awful.spawn(terminal .. " -e mutt -f =store") end):add()
467 keybinding({ cmdmodkey }, "t", function () awful.spawn(terminal) end):add()
468 keybinding({ cmdmodkey }, "c", function () awful.spawn(terminal .. " -e python") end):add()
469 keybinding({ cmdmodkey }, "r", function () awful.spawn("gmrun") end):add()
470 keybinding({ cmdmodkey }, "j", function () awful.spawn("jpilot") end):add()
471 keybinding({ cmdmodkey }, "x", function () awful.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
472 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.spawn("xscreensaver-command -exit") end):add()
474 -- Highlight statusbars on the screen that has focus,
475 -- set this to false if you only have one screen or
476 -- you don't like it :P
477 if screen.count() > 1 then
478 statusbar_highlight_focus = true
480 statusbar_highlight_focus = false