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/madduck"
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) c:focus_set(); 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_get()
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_get()
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_get():kill() end):add()
223 keybinding({ modkey }, "j", function () awful.client.focusbyidx(1); client.focus_get():raise() end):add()
224 keybinding({ modkey }, "k", function () awful.client.focusbyidx(-1); client.focus_get():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_get():swap(awful.client.master()) end):add()
231 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
232 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
234 -- Layout manipulation
235 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
236 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
237 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
238 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
239 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
240 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
241 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
242 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
245 keybinding({ modkey }, "F1", function ()
246 awful.prompt({ prompt = "Run: " }, mypromptbox, awful.spawn, awful.completion.bash)
248 keybinding({ modkey }, "F4", function ()
249 awful.prompt({ prompt = "Run Lua code: " }, mypromptbox, awful.eval)
252 --- Tabulous, tab manipulation
253 keybinding({ modkey, "Control" }, "y", function ()
254 local tabbedview = tabulous.tabindex_get()
255 local nextclient = awful.client.next(1)
257 if not tabbedview then
258 tabbedview = tabulous.tabindex_get(nextclient)
260 if not tabbedview then
261 tabbedview = tabulous.tab_create()
262 tabulous.tab(tabbedview, nextclient)
264 tabulous.tab(tabbedview, client.focus_get())
267 tabulous.tab(tabbedview, nextclient)
271 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
273 keybinding({ modkey }, "y", function ()
274 local tabbedview = tabulous.tabindex_get()
277 local n = tabulous.next(tabbedview)
278 tabulous.display(tabbedview, n)
282 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
283 keybinding({ modkey }, "t", awful.client.togglemarked):add()
284 keybinding({ modkey, 'Shift' }, "t", function ()
285 local tabbedview = tabulous.tabindex_get()
286 local clients = awful.client.getmarked()
288 if not tabbedview then
289 tabbedview = tabulous.tab_create(clients[1])
290 table.remove(clients, 1)
293 for k,c in pairs(clients) do
294 tabulous.tab(tabbedview, c)
299 for i = 1, keynumber do
300 keybinding({ modkey, "Shift" }, "F" .. i,
302 local screen = mouse.screen
303 if tags[screen][i] then
304 for k, c in pairs(awful.client.getmarked()) do
305 awful.client.movetotag(tags[screen][i], c)
313 -- Hook function to execute when focusing a client.
314 function hook_focus(c)
315 if not awful.client.ismarked(c) then
316 c.border_color = beautiful.border_focus
320 -- Hook function to execute when unfocusing a client.
321 function hook_unfocus(c)
322 if not awful.client.ismarked(c) then
323 c.border_color = beautiful.border_normal
327 -- Hook function to execute when marking a client
328 function hook_marked(c)
329 c.border_color = beautiful.border_marked
332 -- Hook function to execute when unmarking a client
333 function hook_unmarked(c)
334 c.border_color = beautiful.border_focus
337 -- Hook function to execute when the mouse is over a client.
338 function hook_mouseover(c)
339 -- Sloppy focus, but disabled for magnifier layout
340 if awful.layout.get(c.screen) ~= "magnifier" then
345 -- Hook function to execute when a new client appears.
346 function hook_manage(c)
347 -- Set floating placement to be smart!
348 c.floating_placement = "smart"
351 awful.titlebar.add(c, { modkey = modkey })
353 -- Add mouse bindings
354 c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
355 c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
356 c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
357 -- New client may not receive focus
358 -- if they're not focusable, so set border anyway.
359 c.border_width = beautiful.border_width
360 c.border_color = beautiful.border_normal
363 -- Check if the application should be floating.
365 local inst = c.instance
366 if floatapps[cls] then
367 c.floating = floatapps[cls]
368 elseif floatapps[inst] then
369 c.floating = floatapps[inst]
372 -- Check application->screen/tag mappings.
375 target = apptags[cls]
376 elseif apptags[inst] then
377 target = apptags[inst]
380 c.screen = target.screen
381 awful.client.movetotag(tags[target.screen][target.tag], c)
385 c.honorsizehints = true
388 -- Hook function to execute when arranging the screen
389 -- (tag switch, new client, etc)
390 function hook_arrange(screen)
391 mylayoutbox[screen].text =
392 "<bg image=\"" .. AWESOME_DATADIR .. "/icons/layouts/" .. awful.layout.get(screen) .. "w.png\" resize=\"true\"/>"
394 -- If no window has focus, give focus to the latest in history
395 if not client.focus_get() then
396 local c = awful.client.focus.history.get(screen, 0)
397 if c then c:focus_set() end
400 -- Uncomment if you want mouse warping
402 local sel = client.focus_get()
404 local c_c = sel.coords
405 local m_c = mouse.coords
407 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
408 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
409 if table.maxn(m_c.buttons) == 0 then
410 mouse.coords = { x = c_c.x + 5, y = c_c.y + 5}
417 -- Hook called every second
418 function hook_timer ()
419 -- For unix time_t lovers
420 -- mytextbox.text = " " .. os.time() .. " time_t "
422 mytextbox.text = " " .. os.date() .. " "
426 awful.hooks.focus.register(hook_focus)
427 awful.hooks.unfocus.register(hook_unfocus)
428 awful.hooks.marked.register(hook_marked)
429 awful.hooks.unmarked.register(hook_unmarked)
430 awful.hooks.manage.register(hook_manage)
431 awful.hooks.mouseover.register(hook_mouseover)
432 awful.hooks.arrange.register(hook_arrange)
433 awful.hooks.timer.register(1, hook_timer)
439 keybinding({ cmdmodkey }, "Prior", function () awful.spawn("amixer set Master 2+") end):add()
440 keybinding({ cmdmodkey }, "Next", function () awful.spawn("amixer set Master 2-") end):add()
441 keybinding({ cmdmodkey }, "Up", function () awful.spawn("amixer set PCM 2+") end):add()
442 keybinding({ cmdmodkey }, "Down", function () awful.spawn("amixer set PCM 2-") end):add()
443 keybinding({ cmdmodkey }, "Home", function () awful.spawn("amixer set Mic toggle") end):add()
444 keybinding({ cmdmodkey }, "End", function () awful.spawn("amixer set Master toggle") end):add()
445 keybinding({ cmdmodkey }, "Left", function () awful.spawn("xmms2 prev") end):add()
446 keybinding({ cmdmodkey }, "Right", function () awful.spawn("xmms2 next") end):add()
447 keybinding({ cmdmodkey }, "space", function () awful.spawn("xmms2 toggleplay") end):add()
448 keybinding({ cmdmodkey }, "backslash", function () awful.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
449 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
452 keybinding({ cmdmodkey }, "n", function () awful.spawn("sensible-browser") end):add()
453 keybinding({ cmdmodkey }, "m", function () awful.spawn(terminal .. " -e mutt -f =store") end):add()
454 keybinding({ cmdmodkey }, "t", function () awful.spawn(terminal) end):add()
455 keybinding({ cmdmodkey }, "c", function () awful.spawn(terminal .. " -e python") end):add()
456 keybinding({ cmdmodkey }, "r", function () awful.spawn("gmrun") end):add()
457 keybinding({ cmdmodkey }, "j", function () awful.spawn("jpilot") end):add()
458 keybinding({ cmdmodkey }, "x", function () awful.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
459 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.spawn("xscreensaver-command -exit") end):add()