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 -- Standard awesome library
6 -- Load Debian menu entries
9 -- {{{ Variable definitions
10 -- Themes define colours, icons, and wallpapers
11 -- The default is a dark theme
12 theme_path = "/usr/share/awesome/themes/default/theme.lua"
13 -- Uncommment this for a lighter theme
14 -- theme_path = "/usr/share/awesome/themes/sky/theme.lua"
16 -- Actually load theme
17 beautiful.init(theme_path)
19 -- This is used later as the default terminal and editor to run.
20 terminal = "x-terminal-emulator"
21 editor = os.getenv("EDITOR") or "editor"
22 editor_cmd = terminal .. " -e " .. editor
25 -- Usually, Mod4 is the key with a logo between Control and Alt.
26 -- If you do not like this or do not have such a key,
27 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
28 -- However, you can use another modifier like Mod1, but it may interact with others.
31 -- Table of layouts to cover with awful.layout.inc, order matters.
34 awful.layout.suit.tile,
35 awful.layout.suit.tile.left,
36 awful.layout.suit.tile.bottom,
37 awful.layout.suit.tile.top,
38 awful.layout.suit.fair,
39 awful.layout.suit.fair.horizontal,
40 awful.layout.suit.max,
41 awful.layout.suit.max.fullscreen,
42 awful.layout.suit.magnifier,
43 awful.layout.suit.floating
46 -- Table of clients that should be set floating. The index may be either
47 -- the application class or instance. The instance is useful when running
48 -- a console app in a terminal like (Music on Console)
49 -- xterm -name mocp -e mocp
50 -- OVERRULED BY TILEDAPPS BELOW
59 ["Play stream"] = true,
63 -- Applications that should never float, assuming everything else floats
70 -- Applications that should be maximised
81 -- Applications to be moved to a pre-defined tag by class or instance.
82 -- Use the screen and tags indices.
85 ["Navigator"] = { screen = 1, tag = 9 },
87 ["-v"] = { screen = 1, tag = 8 },
90 -- Define if we want to use titlebar on all applications.
97 for s = 1, screen.count() do
98 -- Each screen has its own tag table.
100 -- Create 9 tags per screen.
101 for tagnumber = 1, 9 do
102 tags[s][tagnumber] = tag(tagnumber)
103 -- split at 0.5/50% exactly
104 tags[s][tagnumber].mwfact = 0.5
105 -- Add tags to screen one by one
106 tags[s][tagnumber].screen = s
107 awful.layout.set(layouts[5], tags[s][tagnumber])
109 -- I'm sure you want to see at least one tag.
110 tags[s][1].selected = true
115 -- Create a textbox widget
116 mytextbox = widget({ type = "textbox", align = "right" })
117 -- Set the default text in textbox
118 mytextbox.text = "<b><small> " .. awesome.release .. " </small></b>"
120 -- Create a laucher widget and a main menu
122 { "manual", terminal .. " -e man awesome" },
123 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
124 { "restart", awesome.restart },
125 { "quit", awesome.quit }
128 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
129 { "open terminal", terminal },
130 { "Debian", debian.menu.Debian_menu.Debian }
134 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
138 mysystray = widget({ type = "systray", align = "right" })
140 -- Create textbox widgets
141 mytimebox = widget({ type = "textbox", name = "mytimebox", align = "right" })
142 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
144 -- Create a wibox for each screen and add it
149 mytaglist.buttons = awful.util.table.join(
150 awful.button({ }, 1, awful.tag.viewonly),
151 awful.button({ modkey }, 1, awful.client.movetotag),
152 awful.button({ }, 3, function (tag) tag.selected = not tag.selected end),
153 awful.button({ modkey }, 3, awful.client.toggletag),
154 awful.button({ }, 4, awful.tag.viewnext),
155 awful.button({ }, 5, awful.tag.viewprev)
158 mytasklist.buttons = awful.util.table.join(
159 awful.button({ }, 1, function (c)
160 if not c:isvisible() then
161 awful.tag.viewonly(c:tags()[1])
166 awful.button({ }, 3, function ()
171 instance = awful.menu.clients({ width=250 })
174 awful.button({ }, 4, function ()
175 awful.client.focus.byidx(1)
176 if client.focus then client.focus:raise() end
178 awful.button({ }, 5, function ()
179 awful.client.focus.byidx(-1)
180 if client.focus then client.focus:raise() end
183 for s = 1, screen.count() do
184 -- Create a promptbox for each screen
185 mypromptbox[s] = awful.widget.prompt({ align = "left" })
186 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
187 -- We need one layoutbox per screen.
188 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
189 mylayoutbox[s]:buttons(awful.util.table.join(
190 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
191 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
192 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
193 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
194 -- Create a taglist widget
195 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
197 -- Create a tasklist widget
198 mytasklist[s] = awful.widget.tasklist(function(c)
199 return awful.widget.tasklist.label.currenttags(c, s)
200 end, mytasklist.buttons)
203 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
204 -- Add widgets to the wibox - order matters
205 mywibox[s].widgets = { mytaglist[s],
211 s == screen.count() and mysystray or nil }
212 mywibox[s].screen = s
217 batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
218 batterywidget.width = 100
219 batterywidget.height = 0.8
220 batterywidget.gap = 1
221 batterywidget.border_padding = 1
222 batterywidget.border_width = 1
223 batterywidget.ticks_count = 10
224 batterywidget.ticks_gap = 1
225 batterywidget.vertical = false
226 batterywidget:bar_properties_set('bat', {
237 -- {{{ Mouse bindings
238 root.buttons(awful.util.table.join(
239 awful.button({ }, 3, function () mymainmenu:toggle() end),
240 awful.button({ }, 4, awful.tag.viewnext),
241 awful.button({ }, 5, awful.tag.viewprev)
246 globalkeys = awful.util.table.join(
247 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
248 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
249 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
250 awful.key({ modkey, "Shift" }, "Right", function () awful.screen.focus( 1) end),
251 awful.key({ modkey, "Shift" }, "Left", function () awful.screen.focus(-1) end),
252 awful.key({ modkey, "Shift" }, "h", awful.tag.viewprev ),
253 awful.key({ modkey, "Shift" }, "l", awful.tag.viewnext ),
255 awful.key({ modkey, }, "k",
257 awful.client.focus.byidx( 1)
258 if client.focus then client.focus:raise() end
260 awful.key({ modkey, }, "j",
262 awful.client.focus.byidx(-1)
263 if client.focus then client.focus:raise() end
265 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
267 -- Layout manipulation
268 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( 1) end),
269 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( -1) end),
270 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus( 1) end),
271 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus(-1) end),
272 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
273 awful.key({ modkey, }, "Tab",
275 awful.client.focus.history.previous()
282 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
283 awful.key({ modkey, "Control" }, "r", awesome.restart),
284 awful.key({ modkey, "Shift" }, "q", awesome.quit),
286 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
287 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
288 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
289 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
290 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
291 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
292 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
293 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
296 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
298 awful.key({ modkey }, "x",
300 awful.prompt.run({ prompt = "Run Lua code: " },
301 mypromptbox[mouse.screen].widget,
302 awful.util.eval, nil,
303 awful.util.getdir("cache") .. "/history_eval")
307 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
308 clientkeys = awful.util.table.join(
309 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
310 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
311 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
312 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
313 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
314 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
315 awful.key({ modkey }, "t", awful.client.togglemarked),
316 awful.key({ modkey,}, "m",
318 -- if not awful.client.floating then
319 -- awful.client.floating.toggle()
321 c.maximized_horizontal = not c.maximized_horizontal
322 c.maximized_vertical = not c.maximized_vertical
326 -- Compute the maximum number of digit we need, limited to 9
328 for s = 1, screen.count() do
329 keynumber = math.min(9, math.max(#tags[s], keynumber));
332 for i = 1, keynumber do
333 globalkeys = awful.util.table.join(globalkeys,
334 awful.key({ modkey }, i,
336 local screen = mouse.screen
337 if tags[screen][i] then
338 awful.tag.viewonly(tags[screen][i])
341 awful.key({ modkey, "Control" }, i,
343 local screen = mouse.screen
344 if tags[screen][i] then
345 tags[screen][i].selected = not tags[screen][i].selected
348 awful.key({ modkey, "Shift" }, i,
350 if client.focus and tags[client.focus.screen][i] then
351 awful.client.movetotag(tags[client.focus.screen][i])
354 awful.key({ modkey, "Control", "Shift" }, i,
356 if client.focus and tags[client.focus.screen][i] then
357 awful.client.toggletag(tags[client.focus.screen][i])
360 awful.key({ modkey, "Shift" }, "F" .. i,
362 local screen = mouse.screen
363 if tags[screen][i] then
364 for k, c in pairs(awful.client.getmarked()) do
365 awful.client.movetotag(tags[screen][i], c)
374 globalkeys = awful.util.table.join(globalkeys,
375 awful.key({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end),
376 awful.key({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end),
377 awful.key({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end),
378 awful.key({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end),
379 awful.key({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end),
380 awful.key({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end),
381 awful.key({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end),
382 awful.key({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end),
383 awful.key({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end),
384 awful.key({ cmdmodkey }, "backslash", function () awful.util.spawn_with_shell("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end),
385 awful.key({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn_with_shell("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end)
389 globalkeys = awful.util.table.join(globalkeys,
390 awful.key({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end),
391 awful.key({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end),
392 awful.key({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end),
393 awful.key({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end),
394 -- awful.key({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end),
395 awful.key({ cmdmodkey }, "r", function () mypromptbox[mouse.screen]:run() end),
396 awful.key({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end),
397 awful.key({ cmdmodkey }, "x", function () awful.util.spawn_with_shell("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end),
398 awful.key({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end),
399 awful.key(nil, "XF86ScreenSaver", function () awful.util.spawn("xset dpms force off") end)
403 root.keys(globalkeys)
407 -- Hook function to execute when focusing a client.
408 awful.hooks.focus.register(function (c)
409 if not awful.client.ismarked(c) then
410 c.border_color = beautiful.border_focus
414 -- Hook function to execute when unfocusing a client.
415 awful.hooks.unfocus.register(function (c)
416 if not awful.client.ismarked(c) then
417 c.border_color = beautiful.border_normal
421 -- Hook function to execute when marking a client
422 awful.hooks.marked.register(function (c)
423 c.border_color = beautiful.border_marked
426 -- Hook function to execute when unmarking a client.
427 awful.hooks.unmarked.register(function (c)
428 c.border_color = beautiful.border_focus
431 -- Hook function to execute when the mouse enters a client.
432 awful.hooks.mouse_enter.register(function (c)
433 -- Sloppy focus, but disabled for magnifier layout
434 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
435 and awful.client.focus.filter(c) then
440 -- Hook function to execute when a new client appears.
441 awful.hooks.manage.register(function (c, startup)
442 -- If we are not managing this application at startup,
443 -- move it to the screen where the mouse is.
444 -- We only do it for filtered windows (i.e. no dock, etc).
445 if not startup and awful.client.focus.filter(c) then
446 c.screen = mouse.screen
451 awful.titlebar.add(c, { modkey = modkey })
453 -- Add mouse bindings
454 c:buttons(awful.util.table.join(
455 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
456 awful.button({ modkey }, 1, awful.mouse.client.move),
457 awful.button({ modkey }, 3, awful.mouse.client.resize)
459 -- New client may not receive focus
460 -- if they're not focusable, so set border anyway.
461 c.border_width = beautiful.border_width
462 c.border_color = beautiful.border_normal
464 -- Check if the application should be floating.
465 -- OVERRIDDEN, SEE tiledapps BELOW
467 local inst = c.instance
468 if floatapps[cls] then
469 awful.client.floating.set(c, floatapps[cls])
470 elseif floatapps[inst] then
471 awful.client.floating.set(c, floatapps[inst])
474 -- Override with tiledapps
475 awful.client.floating.set(c, not (tiledapps[inst] or tiledapps[cls]))
477 -- Check application->screen/tag mappings.
480 target = apptags[cls]
481 elseif apptags[inst] then
482 target = apptags[inst]
485 c.screen = target.screen
486 awful.client.movetotag(tags[target.screen][target.tag], c)
489 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
495 -- Set the windows at the slave,
496 -- i.e. put it at the end of others instead of setting it master.
497 -- awful.client.setslave(c)
499 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
500 c.size_hints_honor = true
503 if maxapps[inst] or maxapps[cls] then
504 c.maximized_horizontal = not c.maximized_horizontal
505 c.maximized_vertical = not c.maximized_vertical
509 -- Hook function to execute when arranging the screen.
510 -- (tag switch, new client, etc)
511 awful.hooks.arrange.register(function (screen)
512 local layout = awful.layout.getname(awful.layout.get(screen))
513 if layout and beautiful["layout_" ..layout] then
514 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
516 mylayoutbox[screen].image = nil
519 -- Give focus to the latest client in history if no window has focus
520 -- or if the current window is a desktop or a dock one.
521 if not client.focus then
522 local c = awful.client.focus.history.get(screen, 0)
523 if c then client.focus = c end
527 -- Hook called every second
528 awful.hooks.timer.register(1, function ()
529 mytimebox.text = os.date(" %a %d %b %H:%M:%S ")
532 -- Hook called every sixty seconds
533 function hook_battery()
534 mybatterybox.text = " " .. get_acpibatt() .. " "
537 -- {{{ Statusbar battery
539 function get_acpibatt()
541 local f = io.popen('acpi -b', 'r')
543 return "acpi -b failed"
546 local s = f:read('*l')
552 -- Battery 0: Discharging, 89%, 00:02:14 remaining
553 -- Battery 0: Charging, 58%, 00:02:14 until charged
554 -- Battery 0: Full, 100%
555 -- so find the first bit first and then go look for the time
556 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
557 local st, en, time = string.find(s, ',%s(%d+:%d+):%d+%s%a+', en);
559 if not status or not percent then -- time can be empty if we're full
560 return "couldn't parse line " .. s
567 if status == 'Charging' then
568 return '↑ ' .. percent;
569 elseif status == 'Discharging' then
578 local function get_bat()
579 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
580 for line in a:lines() do
584 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
585 for line in b:lines() do
589 batt=math.floor(now*100/full)
590 batterywidget:bar_data_add("bat",batt )
595 awful.hooks.timer.register(20, hook_battery)
596 -- awful.hooks.timer.register(5, get_bat)
599 -- Highlight statusbars on the screen that has focus,
600 -- set this to false if you only have one screen or
601 -- you don't like it :P
602 if screen.count() > 1 then
603 statusbar_highlight_focus = true
605 statusbar_highlight_focus = false