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
43 -- OVERRULED BY TILEDAPPS BELOW
52 ["Play stream"] = true
55 -- Applications that should never float, assuming everything else floats
62 -- Applications that should be maximised
71 -- Applications to be moved to a pre-defined tag by class or instance.
72 -- Use the screen and tags indices.
75 ["Iceweasel"] = { screen = 1, tag = 9 },
77 ["-v"] = { screen = 1, tag = 8 },
80 -- Define if we want to use titlebar on all applications.
85 -- Initialize theme (colors).
86 beautiful.init(theme_path)
88 -- Register theme in awful.
89 -- This allows to not pass plenty of arguments to each function
90 -- to inform it about colors we want it to draw.
91 awful.beautiful.register(beautiful)
93 -- Uncomment this to activate autotabbing
94 -- tabulous.autotab_start()
100 for s = 1, screen.count() do
101 -- Each screen has its own tag table.
103 -- Create 9 tags per screen.
104 for tagnumber = 1, 9 do
105 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
106 -- Add tags to screen one by one
107 -- split at 0.5/50% exactly
108 -- tags[s][tagnumber].mwfact = 0.5
109 tags[s][tagnumber].screen = s
111 -- I'm sure you want to see at least one tag.
112 tags[s][1].selected = true
117 -- Create a taglist widget
118 mytaglist = widget({ type = "taglist", name = "mytaglist" })
119 mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
120 mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
121 mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
122 mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
123 mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
124 mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
125 mytaglist.label = awful.widget.taglist.label.all
127 -- Create a tasklist widget
128 mytasklist = widget({ type = "tasklist", name = "mytasklist" })
129 mytasklist:mouse_add(mouse({ }, 1, function (object, c) client.focus = c; c:raise() end))
130 mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focusbyidx(1) end))
131 mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focusbyidx(-1) end))
132 mytasklist.label = awful.widget.tasklist.label.currenttags
134 -- Create a textbox widget
135 mytimebox = widget({ type = "textbox", name = "mytimebox", align = "right" })
136 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
137 mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
139 -- Create an iconbox widget
140 myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
141 myiconbox.text = "<bg image=\"" .. AWESOME_DATADIR .. "/icons/awesome16.png\" resize=\"true\"/>"
144 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
146 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
147 -- We need one layoutbox per screen.
149 for s = 1, screen.count() do
150 mylayoutbox[s] = widget({ type = "textbox", name = "mylayoutbox", align = "right" })
151 mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
152 mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
153 mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
154 mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
155 mylayoutbox[s].text = "<bg image=\"" .. AWESOME_DATADIR .. "/layouts/tilew.png\" resize=\"true\"/>"
159 batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
160 batterywidget.width = 100
161 batterywidget.height = 0.8
162 batterywidget.gap = 1
163 batterywidget.border_padding = 1
164 batterywidget.border_width = 1
165 batterywidget.ticks_count = 10
166 batterywidget.ticks_gap = 1
167 batterywidget.vertical = false
168 batterywidget:bar_properties_set('bat', {
178 -- Create a statusbar for each screen and add it
180 for s = 1, screen.count() do
181 mystatusbar[s] = statusbar({ position = "top", name = "mystatusbar" .. s,
182 fg = beautiful.fg_normal, bg = beautiful.bg_normal })
183 -- Add widgets to the statusbar - order matters
184 mystatusbar[s]:widgets({
192 s == screen.count() and mysystray or nil
194 mystatusbar[s].screen = s
198 -- {{{ Mouse bindings
199 awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
200 awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
201 awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
206 -- Bind keyboard digits
207 -- Compute the maximum number of digit we need, limited to 9
209 for s = 1, screen.count() do
210 keynumber = math.min(9, math.max(#tags[s], keynumber));
213 for i = 1, keynumber do
214 keybinding({ modkey }, i,
216 local screen = mouse.screen
217 if tags[screen][i] then
218 awful.tag.viewonly(tags[screen][i])
221 keybinding({ modkey, "Control" }, i,
223 local screen = mouse.screen
224 if tags[screen][i] then
225 tags[screen][i].selected = not tags[screen][i].selected
228 keybinding({ modkey, "Shift" }, i,
230 local sel = client.focus
232 if tags[sel.screen][i] then
233 awful.client.movetotag(tags[sel.screen][i])
237 keybinding({ modkey, "Control", "Shift" }, i,
239 local sel = client.focus
241 if tags[sel.screen][i] then
242 awful.client.toggletag(tags[sel.screen][i])
248 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
249 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
250 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
253 keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
255 keybinding({ modkey, "Control" }, "r", awesome.restart):add()
256 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
258 -- Client manipulation
259 keybinding({ modkey }, "m", awful.client.maximize):add()
260 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
261 keybinding({ modkey }, "j", function () awful.client.focusbyidx(1); client.focus:raise() end):add()
262 keybinding({ modkey }, "k", function () awful.client.focusbyidx(-1); client.focus:raise() end):add()
263 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
264 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
265 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
266 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
267 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
268 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
269 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
270 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
271 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
272 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
274 -- Layout manipulation
275 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
276 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
277 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
278 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
279 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
280 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
281 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
282 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
285 keybinding({ modkey }, "F1", function ()
286 awful.prompt.run({ prompt = "Run: " }, mypromptbox, awful.spawn, awful.completion.bash,
287 os.getenv("HOME") .. "/.cache/awesome/history") end):add()
288 keybinding({ modkey }, "F4", function ()
289 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox, awful.eval, awful.prompt.bash,
290 os.getenv("HOME") .. "/.cache/awesome/history_eval") end):add()
291 keybinding({ modkey, "Ctrl" }, "i", function ()
292 if mypromptbox.text then
293 mypromptbox.text = nil
295 mypromptbox.text = nil
296 if client.focus.class then
297 mypromptbox.text = "Class: " .. client.focus.class .. " "
299 if client.focus.instance then
300 mypromptbox.text = mypromptbox.text .. "Instance: ".. client.focus.instance .. " "
302 if client.focus.role then
303 mypromptbox.text = mypromptbox.text .. "Role: ".. client.focus.role
308 --- Tabulous, tab manipulation
309 keybinding({ modkey, "Control" }, "y", function ()
310 local tabbedview = tabulous.tabindex_get()
311 local nextclient = awful.client.next(1)
313 if not tabbedview then
314 tabbedview = tabulous.tabindex_get(nextclient)
316 if not tabbedview then
317 tabbedview = tabulous.tab_create()
318 tabulous.tab(tabbedview, nextclient)
320 tabulous.tab(tabbedview, client.focus)
323 tabulous.tab(tabbedview, nextclient)
327 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
329 keybinding({ modkey }, "y", function ()
330 local tabbedview = tabulous.tabindex_get()
333 local n = tabulous.next(tabbedview)
334 tabulous.display(tabbedview, n)
338 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
339 keybinding({ modkey }, "t", awful.client.togglemarked):add()
340 keybinding({ modkey, 'Shift' }, "t", function ()
341 local tabbedview = tabulous.tabindex_get()
342 local clients = awful.client.getmarked()
344 if not tabbedview then
345 tabbedview = tabulous.tab_create(clients[1])
346 table.remove(clients, 1)
349 for k,c in pairs(clients) do
350 tabulous.tab(tabbedview, c)
355 for i = 1, keynumber do
356 keybinding({ modkey, "Shift" }, "F" .. i,
358 local screen = mouse.screen
359 if tags[screen][i] then
360 for k, c in pairs(awful.client.getmarked()) do
361 awful.client.movetotag(tags[screen][i], c)
369 -- Hook function to execute when focusing a client.
370 function hook_focus(c)
371 if not awful.client.ismarked(c) then
372 c.border_color = beautiful.border_focus
376 -- Hook function to execute when unfocusing a client.
377 function hook_unfocus(c)
378 if not awful.client.ismarked(c) then
379 c.border_color = beautiful.border_normal
383 -- Hook function to execute when marking a client
384 function hook_marked(c)
385 c.border_color = beautiful.border_marked
388 -- Hook function to execute when unmarking a client
389 function hook_unmarked(c)
390 c.border_color = beautiful.border_focus
393 -- Hook function to execute when the mouse is over a client.
394 function hook_mouseover(c)
395 -- Sloppy focus, but disabled for magnifier layout
396 if awful.layout.get(c.screen) ~= "magnifier" then
401 -- Hook function to execute when a new client appears.
402 function hook_manage(c)
403 -- Set floating placement to be smart!
404 c.floating_placement = "smart"
407 awful.titlebar.add(c, { modkey = modkey })
409 -- Add mouse bindings
410 c:mouse_add(mouse({ }, 1, function (c) client.focus = c; c:raise() end))
411 c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
412 c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
413 -- New client may not receive focus
414 -- if they're not focusable, so set border anyway.
415 c.border_width = beautiful.border_width
416 c.border_color = beautiful.border_normal
419 -- Check if the application should be floating.
420 -- OVERRIDDEN, SEE tiledapps BELOW
422 local inst = c.instance
423 if floatapps[cls] then
424 c.floating = floatapps[cls]
425 elseif floatapps[inst] then
426 c.floating = floatapps[inst]
429 -- Override with tiledapps
430 c.floating = not tiledapps[inst]
432 -- Check application->screen/tag mappings.
435 target = apptags[cls]
436 elseif apptags[inst] then
437 target = apptags[inst]
440 c.screen = target.screen
441 awful.client.movetotag(tags[target.screen][target.tag], c)
445 c.honorsizehints = true
448 if maxapps[inst] then
449 awful.client.maximize(c)
453 -- Hook function to execute when arranging the screen
454 -- (tag switch, new client, etc)
455 function hook_arrange(screen)
456 local layout = awful.layout.get(screen)
458 mylayoutbox[screen].text =
459 "<bg image=\"/home/madduck/code/awesome/share/awesome/icons/layouts/" .. awful.layout.get(screen) .. "w.png\" resize=\"true\"/>"
461 mylayoutbox[screen].text = "No layout."
464 -- If no window has focus, give focus to the latest in history
465 if not client.focus then
466 local c = awful.client.focus.history.get(screen, 0)
467 if c then client.focus = c end
470 -- Uncomment if you want mouse warping
472 local sel = client.focus
474 local c_c = sel:coords()
475 local m_c = mouse.coords()
477 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
478 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
479 if table.maxn(m_c.buttons) == 0 then
480 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
487 -- Hook called every second
488 function hook_timer()
489 -- For unix time_t lovers
490 -- mytextbox.text = " " .. os.time() .. " time_t "
492 mytimebox.text = " " .. os.date() .. " "
495 -- Hook called every sixty seconds
496 function hook_battery()
497 mybatterybox.text = " " .. get_acpibatt() .. " "
500 -- {{{ Statusbar battery
502 function get_acpibatt()
504 local f = io.popen('acpi -b', 'r')
506 return "acpi -b failed"
509 local s = f:read('*l')
515 -- Battery 0: Discharging, 89%, 00:02:14 remaining
516 -- Battery 0: Charging, 58%, 00:02:14 until charged
517 -- Battery 0: Full, 100%
518 -- so find the first bit first and then go look for the time
519 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
520 local st, en, time = string.find(s, ',%s(%d+:%d+:%d+)%s%a+', en);
522 if not status or not percent then -- time can be empty if we're full
523 return "couldn't parse line " .. s
530 if status == 'Charging' then
532 elseif status == 'Discarching' then
538 return percent; -- .. ' (' .. status .. ')'; -- .. ' ' .. time .. ' left';
543 local function get_bat()
544 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
545 for line in a:lines() do
549 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
550 for line in b:lines() do
554 batt=math.floor(now*100/full)
555 batterywidget:bar_data_add("bat",batt )
560 awful.hooks.focus.register(hook_focus)
561 awful.hooks.unfocus.register(hook_unfocus)
562 awful.hooks.marked.register(hook_marked)
563 awful.hooks.unmarked.register(hook_unmarked)
564 awful.hooks.manage.register(hook_manage)
565 awful.hooks.mouseover.register(hook_mouseover)
566 awful.hooks.arrange.register(hook_arrange)
567 awful.hooks.timer.register(1, hook_timer)
568 awful.hooks.timer.register(120, hook_battery)
569 -- awful.hooks.timer.register(5, get_bat)
575 keybinding({ cmdmodkey }, "Prior", function () awful.spawn("amixer set Master 2+") end):add()
576 keybinding({ cmdmodkey }, "Next", function () awful.spawn("amixer set Master 2-") end):add()
577 keybinding({ cmdmodkey }, "Up", function () awful.spawn("amixer set PCM 2+") end):add()
578 keybinding({ cmdmodkey }, "Down", function () awful.spawn("amixer set PCM 2-") end):add()
579 keybinding({ cmdmodkey }, "Home", function () awful.spawn("amixer set Mic toggle") end):add()
580 keybinding({ cmdmodkey }, "End", function () awful.spawn("amixer set Master toggle") end):add()
581 keybinding({ cmdmodkey }, "Left", function () awful.spawn("xmms2 prev") end):add()
582 keybinding({ cmdmodkey }, "Right", function () awful.spawn("xmms2 next") end):add()
583 keybinding({ cmdmodkey }, "space", function () awful.spawn("xmms2 toggleplay") end):add()
584 keybinding({ cmdmodkey }, "backslash", function () awful.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
585 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
588 keybinding({ cmdmodkey }, "n", function () awful.spawn("sensible-browser") end):add()
589 keybinding({ cmdmodkey }, "m", function () awful.spawn(terminal .. " -e mutt -f =store") end):add()
590 keybinding({ cmdmodkey }, "t", function () awful.spawn(terminal) end):add()
591 keybinding({ cmdmodkey }, "c", function () awful.spawn(terminal .. " -e python") end):add()
592 keybinding({ cmdmodkey }, "r", function () awful.spawn("gmrun") end):add()
593 keybinding({ cmdmodkey }, "j", function () awful.spawn("jpilot") end):add()
594 keybinding({ cmdmodkey }, "x", function () awful.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
595 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.spawn("xscreensaver-command -exit") end):add()
597 -- Highlight statusbars on the screen that has focus,
598 -- set this to false if you only have one screen or
599 -- you don't like it :P
600 if screen.count() > 1 then
601 statusbar_highlight_focus = true
603 statusbar_highlight_focus = false