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 -- Include awesome library, with lots of useful function!
8 -- {{{ Variable definitions
9 -- This is a file path to a theme file which will defines colors.
10 theme_path = "/home/madduck/code/awesome/share/awesome/themes/default"
12 -- This is used later as the default terminal to run.
13 terminal = "x-terminal-emulator"
16 -- Usually, Mod4 is the key with a logo between Control and Alt.
17 -- If you do not like this or do not have such a key,
18 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
19 -- However, you can use another modifier like Mod1, but it may interact with others.
22 -- Table of layouts to cover with awful.layout.inc, order matters.
38 -- Table of clients that should be set floating. The index may be either
39 -- the application class or instance. The instance is useful when running
40 -- a console app in a terminal like (Music on Console)
41 -- xterm -name mocp -e mocp
42 -- OVERRULED BY TILEDAPPS BELOW
51 ["Play stream"] = true
54 -- Applications that should never float, assuming everything else floats
61 -- 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 ["Navigator"] = { 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[6] })
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" })
120 button({ }, 1, function (object, tag) awful.tag.viewonly(tag) end),
121 button({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end),
122 button({ }, 3, function (object, tag) tag.selected = not tag.selected end),
123 button({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end),
124 button({ }, 4, awful.tag.viewnext),
125 button({ }, 5, awful.tag.viewprev)
127 mytaglist.label = awful.widget.taglist.label.all
129 -- Create a tasklist widget
130 mytasklist = widget({ type = "tasklist", name = "mytasklist" })
132 button({ }, 1, function (object, c) client.focus = c; c:raise() end),
133 button({ }, 4, function () awful.client.focus.byidx(1) end),
134 button({ }, 5, function () awful.client.focus.byidx(-1) end)
136 mytasklist.label = awful.widget.tasklist.label.currenttags
138 -- Create a textbox widget
139 mytimebox = widget({ type = "textbox", name = "mytimebox", align = "right" })
140 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
141 mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
143 -- Create a laucher widget
144 mylauncher = awful.widget.launcher({ name = "mylauncher",
145 image = "/home/madduck/code/awesome/share/awesome/icons/awesome16.png",
146 command = terminal .. " -e man awesome"})
149 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
151 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
152 -- We need one layoutbox per screen.
154 for s = 1, screen.count() do
155 mylayoutbox[s] = widget({ type = "imagebox", name = "mylayoutbox", align = "right" })
156 mylayoutbox[s]:buttons({
157 button({ }, 1, function () awful.layout.inc(layouts, 1) end),
158 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
159 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
160 button({ }, 5, function () awful.layout.inc(layouts, -1) end)
162 mylayoutbox[s].image = image("/home/madduck/code/awesome/share/awesome/icons/layouts/tilew.png")
166 batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
167 batterywidget.width = 100
168 batterywidget.height = 0.8
169 batterywidget.gap = 1
170 batterywidget.border_padding = 1
171 batterywidget.border_width = 1
172 batterywidget.ticks_count = 10
173 batterywidget.ticks_gap = 1
174 batterywidget.vertical = false
175 batterywidget:bar_properties_set('bat', {
185 -- Create a wibox for each screen and add it
187 for s = 1, screen.count() do
188 mywibox[s] = wibox({ position = "top", name = "mywibox" .. s,
189 fg = beautiful.fg_normal, bg = beautiful.bg_normal })
190 -- Add widgets to the wibox - order matters
199 s == screen.count() and mysystray or nil
201 mywibox[s].screen = s
205 -- {{{ Mouse bindings
207 button({ }, 3, function () awful.util.spawn(terminal) end),
208 button({ }, 4, awful.tag.viewnext),
209 button({ }, 5, awful.tag.viewprev)
215 -- Bind keyboard digits
216 -- Compute the maximum number of digit we need, limited to 9
218 for s = 1, screen.count() do
219 keynumber = math.min(9, math.max(#tags[s], keynumber));
222 for i = 1, keynumber do
223 keybinding({ modkey }, i,
225 local screen = mouse.screen
226 if tags[screen][i] then
227 awful.tag.viewonly(tags[screen][i])
230 keybinding({ modkey, "Control" }, i,
232 local screen = mouse.screen
233 if tags[screen][i] then
234 tags[screen][i].selected = not tags[screen][i].selected
237 keybinding({ modkey, "Shift" }, i,
240 if tags[client.focus.screen][i] then
241 awful.client.movetotag(tags[client.focus.screen][i])
245 keybinding({ modkey, "Control", "Shift" }, i,
248 if tags[client.focus.screen][i] then
249 awful.client.toggletag(tags[client.focus.screen][i])
255 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
256 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
257 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
260 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
262 keybinding({ modkey, "Control" }, "r", function ()
263 mypromptbox[mouse.screen].text =
264 awful.util.escape(awful.util.restart())
266 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
268 -- Client manipulation
269 keybinding({ modkey }, "m", awful.client.maximize):add()
270 keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
271 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
272 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
273 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
274 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
275 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
276 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
277 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
278 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
279 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
280 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
281 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
282 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
283 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
285 -- Layout manipulation
286 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
287 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
288 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
289 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
290 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
291 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
292 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
293 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
296 keybinding({ modkey }, "F1", function ()
297 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
298 os.getenv("HOME") .. "/.cache/awesome/history") end):add()
299 keybinding({ modkey }, "F4", function ()
300 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
301 os.getenv("HOME") .. "/.cache/awesome/history_eval") end):add()
302 keybinding({ modkey, "Ctrl" }, "i", function ()
303 local s = mouse.screen
304 if mypromptbox[s].text then
305 mypromptbox[s].text = nil
307 mypromptbox[s].text = nil
308 if client.focus.class then
309 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
311 if client.focus.instance then
312 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
314 if client.focus.role then
315 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
320 --- Tabulous, tab manipulation
321 keybinding({ modkey, "Control" }, "y", function ()
322 local tabbedview = tabulous.tabindex_get()
323 local nextclient = awful.client.next(1)
325 if not tabbedview then
326 tabbedview = tabulous.tabindex_get(nextclient)
328 if not tabbedview then
329 tabbedview = tabulous.tab_create()
330 tabulous.tab(tabbedview, nextclient)
332 tabulous.tab(tabbedview, client.focus)
335 tabulous.tab(tabbedview, nextclient)
339 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
341 keybinding({ modkey }, "y", function ()
342 local tabbedview = tabulous.tabindex_get()
345 local n = tabulous.next(tabbedview)
346 tabulous.display(tabbedview, n)
350 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
351 keybinding({ modkey }, "t", awful.client.togglemarked):add()
352 keybinding({ modkey, 'Shift' }, "t", function ()
353 local tabbedview = tabulous.tabindex_get()
354 local clients = awful.client.getmarked()
356 if not tabbedview then
357 tabbedview = tabulous.tab_create(clients[1])
358 table.remove(clients, 1)
361 for k,c in pairs(clients) do
362 tabulous.tab(tabbedview, c)
367 for i = 1, keynumber do
368 keybinding({ modkey, "Shift" }, "F" .. i,
370 local screen = mouse.screen
371 if tags[screen][i] then
372 for k, c in pairs(awful.client.getmarked()) do
373 awful.client.movetotag(tags[screen][i], c)
381 -- Hook function to execute when focusing a client.
382 awful.hooks.focus.register(function (c)
383 if not awful.client.ismarked(c) then
384 c.border_color = beautiful.border_focus
388 -- Hook function to execute when unfocusing a client.
389 awful.hooks.unfocus.register(function (c)
390 if not awful.client.ismarked(c) then
391 c.border_color = beautiful.border_normal
395 -- Hook function to execute when marking a client
396 awful.hooks.marked.register(function (c)
397 c.border_color = beautiful.border_marked
400 -- Hook function to execute when unmarking a client
401 awful.hooks.unmarked.register(function (c)
402 c.border_color = beautiful.border_focus
405 -- Hook function to execute when the mouse is over a client.
406 awful.hooks.mouse_enter.register(function (c)
407 -- Sloppy focus, but disabled for magnifier layout
408 if awful.layout.get(c.screen) ~= "magnifier"
409 and awful.client.focus.filter(c) then
414 -- Hook function to execute when a new client appears.
415 awful.hooks.manage.register(function (c)
418 awful.titlebar.add(c, { modkey = modkey })
420 -- Add mouse bindings
422 button({ }, 1, function (c) client.focus = c; c:raise() end),
423 button({ modkey }, 1, function (c) c:mouse_move() end),
424 button({ modkey }, 3, function (c) c:mouse_resize() end)
426 -- New client may not receive focus
427 -- if they're not focusable, so set border anyway.
428 c.border_width = beautiful.border_width
429 c.border_color = beautiful.border_normal
432 -- Check if the application should be floating.
433 -- OVERRIDDEN, SEE tiledapps BELOW
435 local inst = c.instance
436 if floatapps[cls] then
437 c.floating = floatapps[cls]
438 elseif floatapps[inst] then
439 c.floating = floatapps[inst]
442 -- Override with tiledapps
443 c.floating = not (tiledapps[inst] or tiledapps[cls])
445 -- Check application->screen/tag mappings.
448 target = apptags[cls]
449 elseif apptags[inst] then
450 target = apptags[inst]
453 c.screen = target.screen
454 awful.client.movetotag(tags[target.screen][target.tag], c)
457 -- Set the windows at the slave,
458 -- i.e. put it at the end of others instead of setting it master.
459 -- awful.client.setslave(c)
461 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
462 c.honorsizehints = true
465 if maxapps[inst] or maxapps[cls] then
466 awful.client.maximize(c)
470 -- Hook function to execute when arranging the screen
471 -- (tag switch, new client, etc)
472 awful.hooks.arrange.register(function (screen)
473 local layout = awful.layout.get(screen)
475 mylayoutbox[screen].image = image("/home/madduck/code/awesome/share/awesome/icons/layouts/" .. layout .. "w.png")
477 mylayoutbox[screen].image = nil
480 -- Give focus to the latest client in history if no window has focus
481 -- or if the current window is a desktop or a dock one.
482 if not client.focus then
483 local c = awful.client.focus.history.get(screen, 0)
484 if c then client.focus = c end
487 -- Uncomment if you want mouse warping
490 local c_c = client.focus:coords()
491 local m_c = mouse.coords()
493 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
494 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
495 if table.maxn(m_c.buttons) == 0 then
496 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
503 -- Hook called every second
504 awful.hooks.timer.register(1, function ()
505 -- For unix time_t lovers
506 -- mytextbox.text = " " .. os.time() .. " time_t "
508 mytimebox.text = " " .. os.date() .. " "
511 -- Hook called every sixty seconds
512 function hook_battery()
513 mybatterybox.text = " " .. get_acpibatt() .. " "
516 -- {{{ Statusbar battery
518 function get_acpibatt()
520 local f = io.popen('acpi -b', 'r')
522 return "acpi -b failed"
525 local s = f:read('*l')
531 -- Battery 0: Discharging, 89%, 00:02:14 remaining
532 -- Battery 0: Charging, 58%, 00:02:14 until charged
533 -- Battery 0: Full, 100%
534 -- so find the first bit first and then go look for the time
535 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
536 local st, en, time = string.find(s, ',%s(%d+:%d+:%d+)%s%a+', en);
538 if not status or not percent then -- time can be empty if we're full
539 return "couldn't parse line " .. s
546 if status == 'Charging' then
548 elseif status == 'Discarching' then
554 return percent; -- .. ' (' .. status .. ')'; -- .. ' ' .. time .. ' left';
559 local function get_bat()
560 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
561 for line in a:lines() do
565 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
566 for line in b:lines() do
570 batt=math.floor(now*100/full)
571 batterywidget:bar_data_add("bat",batt )
576 awful.hooks.timer.register(120, hook_battery)
577 -- awful.hooks.timer.register(5, get_bat)
583 keybinding({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end):add()
584 keybinding({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end):add()
585 keybinding({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end):add()
586 keybinding({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end):add()
587 keybinding({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end):add()
588 keybinding({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end):add()
589 keybinding({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end):add()
590 keybinding({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end):add()
591 keybinding({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end):add()
592 keybinding({ cmdmodkey }, "backslash", function () awful.util.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
593 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
596 keybinding({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end):add()
597 keybinding({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end):add()
598 keybinding({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end):add()
599 keybinding({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end):add()
600 keybinding({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end):add()
601 keybinding({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end):add()
602 keybinding({ cmdmodkey }, "x", function () awful.util.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
603 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end):add()
605 -- Highlight statusbars on the screen that has focus,
606 -- set this to false if you only have one screen or
607 -- you don't like it :P
608 if screen.count() > 1 then
609 statusbar_highlight_focus = true
611 statusbar_highlight_focus = false