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.focusbyidx(1) end),
134 button({ }, 5, function () awful.client.focusbyidx(-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 ()
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, 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, awful.eval, awful.prompt.bash,
301 os.getenv("HOME") .. "/.cache/awesome/history_eval") end):add()
302 keybinding({ modkey, "Ctrl" }, "i", function ()
303 if mypromptbox.text then
304 mypromptbox.text = nil
306 mypromptbox.text = nil
307 if client.focus.class then
308 mypromptbox.text = "Class: " .. client.focus.class .. " "
310 if client.focus.instance then
311 mypromptbox.text = mypromptbox.text .. "Instance: ".. client.focus.instance .. " "
313 if client.focus.role then
314 mypromptbox.text = mypromptbox.text .. "Role: ".. client.focus.role
319 --- Tabulous, tab manipulation
320 keybinding({ modkey, "Control" }, "y", function ()
321 local tabbedview = tabulous.tabindex_get()
322 local nextclient = awful.client.next(1)
324 if not tabbedview then
325 tabbedview = tabulous.tabindex_get(nextclient)
327 if not tabbedview then
328 tabbedview = tabulous.tab_create()
329 tabulous.tab(tabbedview, nextclient)
331 tabulous.tab(tabbedview, client.focus)
334 tabulous.tab(tabbedview, nextclient)
338 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
340 keybinding({ modkey }, "y", function ()
341 local tabbedview = tabulous.tabindex_get()
344 local n = tabulous.next(tabbedview)
345 tabulous.display(tabbedview, n)
349 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
350 keybinding({ modkey }, "t", awful.client.togglemarked):add()
351 keybinding({ modkey, 'Shift' }, "t", function ()
352 local tabbedview = tabulous.tabindex_get()
353 local clients = awful.client.getmarked()
355 if not tabbedview then
356 tabbedview = tabulous.tab_create(clients[1])
357 table.remove(clients, 1)
360 for k,c in pairs(clients) do
361 tabulous.tab(tabbedview, c)
366 for i = 1, keynumber do
367 keybinding({ modkey, "Shift" }, "F" .. i,
369 local screen = mouse.screen
370 if tags[screen][i] then
371 for k, c in pairs(awful.client.getmarked()) do
372 awful.client.movetotag(tags[screen][i], c)
380 -- Hook function to execute when focusing a client.
381 awful.hooks.focus.register(function (c)
382 if not awful.client.ismarked(c) then
383 c.border_color = beautiful.border_focus
387 -- Hook function to execute when unfocusing a client.
388 awful.hooks.unfocus.register(function (c)
389 if not awful.client.ismarked(c) then
390 c.border_color = beautiful.border_normal
394 -- Hook function to execute when marking a client
395 awful.hooks.marked.register(function (c)
396 c.border_color = beautiful.border_marked
399 -- Hook function to execute when unmarking a client
400 awful.hooks.unmarked.register(function (c)
401 c.border_color = beautiful.border_focus
404 -- Hook function to execute when the mouse is over a client.
405 awful.hooks.mouse_enter.register(function (c)
406 -- Sloppy focus, but disabled for magnifier layout
407 if awful.layout.get(c.screen) ~= "magnifier"
408 and awful.client.focus.filter(c) then
413 -- Hook function to execute when a new client appears.
414 awful.hooks.manage.register(function (c)
417 awful.titlebar.add(c, { modkey = modkey })
419 -- Add mouse bindings
421 button({ }, 1, function (c) client.focus = c; c:raise() end),
422 button({ modkey }, 1, function (c) c:mouse_move() end),
423 button({ modkey }, 3, function (c) c:mouse_resize() end)
425 -- New client may not receive focus
426 -- if they're not focusable, so set border anyway.
427 c.border_width = beautiful.border_width
428 c.border_color = beautiful.border_normal
431 -- Check if the application should be floating.
432 -- OVERRIDDEN, SEE tiledapps BELOW
434 local inst = c.instance
435 if floatapps[cls] then
436 c.floating = floatapps[cls]
437 elseif floatapps[inst] then
438 c.floating = floatapps[inst]
441 -- Override with tiledapps
442 c.floating = not (tiledapps[inst] or tiledapps[cls])
444 -- Check application->screen/tag mappings.
447 target = apptags[cls]
448 elseif apptags[inst] then
449 target = apptags[inst]
452 c.screen = target.screen
453 awful.client.movetotag(tags[target.screen][target.tag], c)
456 -- Set the windows at the slave,
457 -- i.e. put it at the end of others instead of setting it master.
458 -- awful.client.setslave(c)
460 -- Honor size hints: if you want to drop the gaps between windows, set this to false. | if maxapps[inst] or maxapps[cls] then
461 c.honorsizehints = true
464 if maxapps[inst] or maxapps[cls] then
465 awful.client.maximize(c)
469 -- Hook function to execute when arranging the screen
470 -- (tag switch, new client, etc)
471 awful.hooks.arrange.register(function (screen)
472 local layout = awful.layout.get(screen)
474 mylayoutbox[screen].image = image("/home/madduck/code/awesome/share/awesome/icons/layouts/" .. layout .. "w.png")
476 mylayoutbox[screen].image = nil
479 -- Give focus to the latest client in history if no window has focus
480 -- or if the current window is a desktop or a dock one.
481 if not client.focus then
482 local c = awful.client.focus.history.get(screen, 0)
483 if c then client.focus = c end
486 -- Uncomment if you want mouse warping
489 local c_c = client.focus:coords()
490 local m_c = mouse.coords()
492 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
493 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
494 if table.maxn(m_c.buttons) == 0 then
495 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
502 -- Hook called every second
503 awful.hooks.timer.register(1, function ()
504 -- For unix time_t lovers
505 -- mytextbox.text = " " .. os.time() .. " time_t "
507 mytimebox.text = " " .. os.date() .. " "
510 -- Hook called every sixty seconds
511 function hook_battery()
512 mybatterybox.text = " " .. get_acpibatt() .. " "
515 -- {{{ Statusbar battery
517 function get_acpibatt()
519 local f = io.popen('acpi -b', 'r')
521 return "acpi -b failed"
524 local s = f:read('*l')
530 -- Battery 0: Discharging, 89%, 00:02:14 remaining
531 -- Battery 0: Charging, 58%, 00:02:14 until charged
532 -- Battery 0: Full, 100%
533 -- so find the first bit first and then go look for the time
534 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
535 local st, en, time = string.find(s, ',%s(%d+:%d+:%d+)%s%a+', en);
537 if not status or not percent then -- time can be empty if we're full
538 return "couldn't parse line " .. s
545 if status == 'Charging' then
547 elseif status == 'Discarching' then
553 return percent; -- .. ' (' .. status .. ')'; -- .. ' ' .. time .. ' left';
558 local function get_bat()
559 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
560 for line in a:lines() do
564 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
565 for line in b:lines() do
569 batt=math.floor(now*100/full)
570 batterywidget:bar_data_add("bat",batt )
575 awful.hooks.timer.register(120, hook_battery)
576 -- awful.hooks.timer.register(5, get_bat)
582 keybinding({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end):add()
583 keybinding({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end):add()
584 keybinding({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end):add()
585 keybinding({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end):add()
586 keybinding({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end):add()
587 keybinding({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end):add()
588 keybinding({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end):add()
589 keybinding({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end):add()
590 keybinding({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end):add()
591 keybinding({ cmdmodkey }, "backslash", function () awful.util.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
592 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
595 keybinding({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end):add()
596 keybinding({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end):add()
597 keybinding({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end):add()
598 keybinding({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end):add()
599 keybinding({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end):add()
600 keybinding({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end):add()
601 keybinding({ cmdmodkey }, "x", function () awful.util.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
602 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end):add()
604 -- Highlight statusbars on the screen that has focus,
605 -- set this to false if you only have one screen or
606 -- you don't like it :P
607 if screen.count() > 1 then
608 statusbar_highlight_focus = true
610 statusbar_highlight_focus = false