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 and editor to run.
13 terminal = "x-terminal-emulator"
14 editor = "sensible-editor"
15 editor_cmd = terminal .. " -e " .. editor
18 -- Usually, Mod4 is the key with a logo between Control and Alt.
19 -- If you do not like this or do not have such a key,
20 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
21 -- However, you can use another modifier like Mod1, but it may interact with others.
24 -- Table of layouts to cover with awful.layout.inc, order matters.
40 -- Table of clients that should be set floating. The index may be either
41 -- the application class or instance. The instance is useful when running
42 -- a console app in a terminal like (Music on Console)
43 -- xterm -name mocp -e mocp
44 -- OVERRULED BY TILEDAPPS BELOW
53 ["Play stream"] = true
56 -- Applications that should never float, assuming everything else floats
63 -- Applications that should be maximised
74 -- Applications to be moved to a pre-defined tag by class or instance.
75 -- Use the screen and tags indices.
78 ["Navigator"] = { screen = 1, tag = 9 },
80 ["-v"] = { screen = 1, tag = 8 },
83 -- Define if we want to use titlebar on all applications.
88 -- Initialize theme (colors).
89 beautiful.init(theme_path)
91 -- Register theme in awful.
92 -- This allows to not pass plenty of arguments to each function
93 -- to inform it about colors we want it to draw.
94 awful.beautiful.register(beautiful)
96 -- Uncomment this to activate autotabbing
97 -- tabulous.autotab_start()
101 -- Define tags table.
103 for s = 1, screen.count() do
104 -- Each screen has its own tag table.
106 -- Create 9 tags per screen.
107 for tagnumber = 1, 9 do
108 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[6] })
109 -- Add tags to screen one by one
110 -- split at 0.5/50% exactly
111 -- tags[s][tagnumber].mwfact = 0.5
112 tags[s][tagnumber].screen = s
114 -- I'm sure you want to see at least one tag.
115 tags[s][1].selected = true
120 -- Create a textbox widget
121 mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
122 -- Set the default text in textbox
123 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
125 -- Create a laucher widget and a main menu
127 {"manual", terminal .. " -e man awesome" },
128 {"edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
129 {"restart", awesome.restart },
130 {"quit", awesome.quit }
134 {"awesome", myawesomemenu, "/home/madduck/code/awesome/share/awesome/icons/awesome16.png" },
135 {"open terminal", terminal }
138 mylauncher = awful.widget.launcher({ name = "mylauncher",
139 image = "/home/madduck/code/awesome/share/awesome/icons/awesome16.png",
140 menu = { id="mymainmenu", items=mymainmenu } })
143 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
145 -- Create a wibox for each screen and add it
150 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
151 button({ modkey }, 1, awful.client.movetotag),
152 button({ }, 3, function (tag) tag.selected = not tag.selected end),
153 button({ modkey }, 3, awful.client.toggletag),
154 button({ }, 4, awful.tag.viewnext),
155 button({ }, 5, awful.tag.viewprev) }
157 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
158 button({ }, 3, function () awful.menu.clients({ width=250 }) end),
159 button({ }, 4, function () awful.client.focus.byidx(1) end),
160 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
162 for s = 1, screen.count() do
163 mylayoutbox[s] = widget({ type = "imagebox", name = "mylayoutbox", align = "right" })
164 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
165 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
166 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
167 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
168 -- Create a taglist widget
169 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
171 -- Create a tasklist widget
172 mytasklist[s] = awful.widget.tasklist.new(function(c)
173 return awful.widget.tasklist.label.currenttags(c, s)
174 end, mytasklist.buttons)
177 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
178 -- Add widgets to the wibox - order matters
179 mywibox[s].widgets = { mytaglist[s],
184 s == 1 and mysystray or nil }
185 mywibox[s].screen = s
189 -- Create a textbox widget
190 mytimebox = widget({ type = "textbox", name = "mytimebox", align = "right" })
191 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
194 batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
195 batterywidget.width = 100
196 batterywidget.height = 0.8
197 batterywidget.gap = 1
198 batterywidget.border_padding = 1
199 batterywidget.border_width = 1
200 batterywidget.ticks_count = 10
201 batterywidget.ticks_gap = 1
202 batterywidget.vertical = false
203 batterywidget:bar_properties_set('bat', {
214 -- {{{ Mouse bindings
216 button({ }, 3, function () awful.menu.new({ id="mymainmenu", items=mymainmenu }) end),
217 button({ }, 4, awful.tag.viewnext),
218 button({ }, 5, awful.tag.viewprev)
224 -- Bind keyboard digits
225 -- Compute the maximum number of digit we need, limited to 9
227 for s = 1, screen.count() do
228 keynumber = math.min(9, math.max(#tags[s], keynumber));
231 for i = 1, keynumber do
232 keybinding({ modkey }, i,
234 local screen = mouse.screen
235 if tags[screen][i] then
236 awful.tag.viewonly(tags[screen][i])
239 keybinding({ modkey, "Control" }, i,
241 local screen = mouse.screen
242 if tags[screen][i] then
243 tags[screen][i].selected = not tags[screen][i].selected
246 keybinding({ modkey, "Shift" }, i,
249 if tags[client.focus.screen][i] then
250 awful.client.movetotag(tags[client.focus.screen][i])
254 keybinding({ modkey, "Control", "Shift" }, i,
257 if tags[client.focus.screen][i] then
258 awful.client.toggletag(tags[client.focus.screen][i])
264 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
265 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
266 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
269 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
271 keybinding({ modkey, "Control" }, "r", function ()
272 mypromptbox[mouse.screen].text =
273 awful.util.escape(awful.util.restart())
275 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
277 -- Client manipulation
278 keybinding({ modkey }, "m", awful.client.maximize):add()
279 keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
280 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
281 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
282 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
283 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
284 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
285 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
286 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
287 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
288 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
289 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
290 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
291 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
292 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
294 -- Layout manipulation
295 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
296 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
297 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
298 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
299 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
300 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
301 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
302 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
305 keybinding({ modkey }, "F1", function ()
306 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
307 awful.util.getdir("cache") .. "/history")
309 keybinding({ modkey }, "F4", function ()
310 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
311 awful.util.getdir("cache") .. "/history_eval")
314 keybinding({ modkey, "Ctrl" }, "i", function ()
315 local s = mouse.screen
316 if mypromptbox[s].text then
317 mypromptbox[s].text = nil
319 mypromptbox[s].text = nil
320 if client.focus.class then
321 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
323 if client.focus.instance then
324 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
326 if client.focus.role then
327 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
332 --- Tabulous, tab manipulation
333 keybinding({ modkey, "Control" }, "y", function ()
334 local tabbedview = tabulous.tabindex_get()
335 local nextclient = awful.client.next(1)
337 if not tabbedview then
338 tabbedview = tabulous.tabindex_get(nextclient)
340 if not tabbedview then
341 tabbedview = tabulous.tab_create()
342 tabulous.tab(tabbedview, nextclient)
344 tabulous.tab(tabbedview, client.focus)
347 tabulous.tab(tabbedview, nextclient)
351 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
353 keybinding({ modkey }, "y", function ()
354 local tabbedview = tabulous.tabindex_get()
357 local n = tabulous.next(tabbedview)
358 tabulous.display(tabbedview, n)
362 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
363 keybinding({ modkey }, "t", awful.client.togglemarked):add()
364 keybinding({ modkey, 'Shift' }, "t", function ()
365 local tabbedview = tabulous.tabindex_get()
366 local clients = awful.client.getmarked()
368 if not tabbedview then
369 tabbedview = tabulous.tab_create(clients[1])
370 table.remove(clients, 1)
373 for k,c in pairs(clients) do
374 tabulous.tab(tabbedview, c)
379 for i = 1, keynumber do
380 keybinding({ modkey, "Shift" }, "F" .. i,
382 local screen = mouse.screen
383 if tags[screen][i] then
384 for k, c in pairs(awful.client.getmarked()) do
385 awful.client.movetotag(tags[screen][i], c)
393 -- Hook function to execute when focusing a client.
394 awful.hooks.focus.register(function (c)
395 if not awful.client.ismarked(c) then
396 c.border_color = beautiful.border_focus
400 -- Hook function to execute when unfocusing a client.
401 awful.hooks.unfocus.register(function (c)
402 if not awful.client.ismarked(c) then
403 c.border_color = beautiful.border_normal
407 -- Hook function to execute when marking a client
408 awful.hooks.marked.register(function (c)
409 c.border_color = beautiful.border_marked
412 -- Hook function to execute when unmarking a client.
413 awful.hooks.unmarked.register(function (c)
414 c.border_color = beautiful.border_focus
417 -- Hook function to execute when the mouse enters a client.
418 awful.hooks.mouse_enter.register(function (c)
419 -- Sloppy focus, but disabled for magnifier layout
420 if awful.layout.get(c.screen) ~= "magnifier"
421 and awful.client.focus.filter(c) then
426 -- Hook function to execute when a new client appears.
427 awful.hooks.manage.register(function (c)
430 awful.titlebar.add(c, { modkey = modkey })
432 -- Add mouse bindings
434 button({ }, 1, function (c) client.focus = c; c:raise() end),
435 button({ modkey }, 1, function (c) c:mouse_move() end),
436 button({ modkey }, 3, function (c) c:mouse_resize() end)
438 -- New client may not receive focus
439 -- if they're not focusable, so set border anyway.
440 c.border_width = beautiful.border_width
441 c.border_color = beautiful.border_normal
444 -- Check if the application should be floating.
445 -- OVERRIDDEN, SEE tiledapps BELOW
447 local inst = c.instance
448 if floatapps[cls] then
449 c.floating = floatapps[cls]
450 elseif floatapps[inst] then
451 c.floating = floatapps[inst]
454 -- Override with tiledapps
455 c.floating = not (tiledapps[inst] or tiledapps[cls])
457 -- Check application->screen/tag mappings.
460 target = apptags[cls]
461 elseif apptags[inst] then
462 target = apptags[inst]
465 c.screen = target.screen
466 awful.client.movetotag(tags[target.screen][target.tag], c)
469 -- Set the windows at the slave,
470 -- i.e. put it at the end of others instead of setting it master.
471 -- awful.client.setslave(c)
473 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
474 c.honorsizehints = true
477 if maxapps[inst] or maxapps[cls] then
478 awful.client.maximize(c)
482 -- Hook function to execute when arranging the screen.
483 -- (tag switch, new client, etc)
484 awful.hooks.arrange.register(function (screen)
485 local layout = awful.layout.get(screen)
487 mylayoutbox[screen].image = image("/home/madduck/code/awesome/share/awesome/icons/layouts/" .. layout .. "w.png")
489 mylayoutbox[screen].image = nil
492 -- Give focus to the latest client in history if no window has focus
493 -- or if the current window is a desktop or a dock one.
494 if not client.focus then
495 local c = awful.client.focus.history.get(screen, 0)
496 if c then client.focus = c end
499 -- Uncomment if you want mouse warping
502 local c_c = client.focus:geometry()
503 local m_c = mouse.coords()
505 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
506 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
507 if table.maxn(m_c.buttons) == 0 then
508 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
515 -- Hook called every second
516 awful.hooks.timer.register(1, function ()
517 -- For unix time_t lovers
518 -- mytextbox.text = " " .. os.time() .. " time_t "
520 mytimebox.text = " " .. os.date() .. " "
523 -- Hook called every sixty seconds
524 function hook_battery()
525 mybatterybox.text = " " .. get_acpibatt() .. " "
528 -- {{{ Statusbar battery
530 function get_acpibatt()
532 local f = io.popen('acpi -b', 'r')
534 return "acpi -b failed"
537 local s = f:read('*l')
543 -- Battery 0: Discharging, 89%, 00:02:14 remaining
544 -- Battery 0: Charging, 58%, 00:02:14 until charged
545 -- Battery 0: Full, 100%
546 -- so find the first bit first and then go look for the time
547 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
548 local st, en, time = string.find(s, ',%s(%d+:%d+:%d+)%s%a+', en);
550 if not status or not percent then -- time can be empty if we're full
551 return "couldn't parse line " .. s
558 if status == 'Charging' then
560 elseif status == 'Discarching' then
566 return percent; -- .. ' (' .. status .. ')'; -- .. ' ' .. time .. ' left';
571 local function get_bat()
572 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
573 for line in a:lines() do
577 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
578 for line in b:lines() do
582 batt=math.floor(now*100/full)
583 batterywidget:bar_data_add("bat",batt )
588 awful.hooks.timer.register(120, hook_battery)
589 -- awful.hooks.timer.register(5, get_bat)
595 keybinding({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end):add()
596 keybinding({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end):add()
597 keybinding({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end):add()
598 keybinding({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end):add()
599 keybinding({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end):add()
600 keybinding({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end):add()
601 keybinding({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end):add()
602 keybinding({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end):add()
603 keybinding({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end):add()
604 keybinding({ cmdmodkey }, "backslash", function () awful.util.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
605 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
608 keybinding({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end):add()
609 keybinding({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end):add()
610 keybinding({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end):add()
611 keybinding({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end):add()
612 keybinding({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end):add()
613 keybinding({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end):add()
614 keybinding({ cmdmodkey }, "x", function () awful.util.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
615 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end):add()
617 -- Highlight statusbars on the screen that has focus,
618 -- set this to false if you only have one screen or
619 -- you don't like it :P
620 if screen.count() > 1 then
621 statusbar_highlight_focus = true
623 statusbar_highlight_focus = false