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,
62 -- Applications that should never float, assuming everything else floats
69 -- Applications that should be maximised
80 -- Applications to be moved to a pre-defined tag by class or instance.
81 -- Use the screen and tags indices.
84 ["Navigator"] = { screen = 1, tag = 9 },
86 ["-v"] = { screen = 1, tag = 8 },
89 -- Define if we want to use titlebar on all applications.
96 for s = 1, screen.count() do
97 -- Each screen has its own tag table.
99 -- Create 9 tags per screen.
100 for tagnumber = 1, 9 do
101 tags[s][tagnumber] = tag(tagnumber)
102 -- split at 0.5/50% exactly
103 tags[s][tagnumber].mwfact = 0.5
104 -- Add tags to screen one by one
105 tags[s][tagnumber].screen = s
106 awful.layout.set(layouts[5], tags[s][tagnumber])
108 -- I'm sure you want to see at least one tag.
109 tags[s][1].selected = true
114 -- Create a textbox widget
115 mytextbox = widget({ type = "textbox", align = "right" })
116 -- Set the default text in textbox
117 mytextbox.text = "<b><small> " .. awesome.release .. " </small></b>"
119 -- Create a laucher widget and a main menu
121 { "manual", terminal .. " -e man awesome" },
122 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
123 { "restart", awesome.restart },
124 { "quit", awesome.quit }
127 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
128 { "open terminal", terminal },
129 { "Debian", debian.menu.Debian_menu.Debian }
133 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
137 mysystray = widget({ type = "systray", align = "right" })
139 -- Create textbox widgets
140 mytimebox = widget({ type = "textbox", name = "mytimebox", align = "right" })
141 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
143 -- Create a wibox for each screen and add it
148 mytaglist.buttons = awful.util.table.join(
149 awful.button({ }, 1, awful.tag.viewonly),
150 awful.button({ modkey }, 1, awful.client.movetotag),
151 awful.button({ }, 3, function (tag) tag.selected = not tag.selected end),
152 awful.button({ modkey }, 3, awful.client.toggletag),
153 awful.button({ }, 4, awful.tag.viewnext),
154 awful.button({ }, 5, awful.tag.viewprev)
157 mytasklist.buttons = awful.util.table.join(
158 awful.button({ }, 1, function (c)
159 if not c:isvisible() then
160 awful.tag.viewonly(c:tags()[1])
165 awful.button({ }, 3, function ()
170 instance = awful.menu.clients({ width=250 })
173 awful.button({ }, 4, function ()
174 awful.client.focus.byidx(1)
175 if client.focus then client.focus:raise() end
177 awful.button({ }, 5, function ()
178 awful.client.focus.byidx(-1)
179 if client.focus then client.focus:raise() end
182 for s = 1, screen.count() do
183 -- Create a promptbox for each screen
184 mypromptbox[s] = awful.widget.prompt({ align = "left" })
185 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
186 -- We need one layoutbox per screen.
187 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
188 mylayoutbox[s]:buttons(awful.util.table.join(
189 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
190 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
191 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
192 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
193 -- Create a taglist widget
194 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
196 -- Create a tasklist widget
197 mytasklist[s] = awful.widget.tasklist(function(c)
198 return awful.widget.tasklist.label.currenttags(c, s)
199 end, mytasklist.buttons)
202 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
203 -- Add widgets to the wibox - order matters
204 mywibox[s].widgets = { mytaglist[s],
210 s == screen.count() and mysystray or nil }
211 mywibox[s].screen = s
216 batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
217 batterywidget.width = 100
218 batterywidget.height = 0.8
219 batterywidget.gap = 1
220 batterywidget.border_padding = 1
221 batterywidget.border_width = 1
222 batterywidget.ticks_count = 10
223 batterywidget.ticks_gap = 1
224 batterywidget.vertical = false
225 batterywidget:bar_properties_set('bat', {
236 -- {{{ Mouse bindings
237 root.buttons(awful.util.table.join(
238 awful.button({ }, 3, function () mymainmenu:toggle() end),
239 awful.button({ }, 4, awful.tag.viewnext),
240 awful.button({ }, 5, awful.tag.viewprev)
245 globalkeys = awful.util.table.join(
246 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
247 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
248 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
250 awful.key({ modkey, }, "j",
252 awful.client.focus.byidx( 1)
253 if client.focus then client.focus:raise() end
255 awful.key({ modkey, }, "k",
257 awful.client.focus.byidx(-1)
258 if client.focus then client.focus:raise() end
260 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
262 -- Layout manipulation
263 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
264 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
265 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus( 1) end),
266 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end),
267 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
268 awful.key({ modkey, }, "Tab",
270 awful.client.focus.history.previous()
277 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
278 awful.key({ modkey, "Control" }, "r", awesome.restart),
279 awful.key({ modkey, "Shift" }, "q", awesome.quit),
281 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
282 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
283 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
284 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
285 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
286 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
287 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
288 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
291 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
293 awful.key({ modkey }, "x",
295 awful.prompt.run({ prompt = "Run Lua code: " },
296 mypromptbox[mouse.screen].widget,
297 awful.util.eval, nil,
298 awful.util.getdir("cache") .. "/history_eval")
302 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
303 clientkeys = awful.util.table.join(
304 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
305 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
306 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
307 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
308 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
309 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
310 awful.key({ modkey }, "t", awful.client.togglemarked),
311 awful.key({ modkey,}, "m",
313 -- if not awful.client.floating then
314 -- awful.client.floating.toggle()
316 c.maximized_horizontal = not c.maximized_horizontal
317 c.maximized_vertical = not c.maximized_vertical
321 -- Compute the maximum number of digit we need, limited to 9
323 for s = 1, screen.count() do
324 keynumber = math.min(9, math.max(#tags[s], keynumber));
327 for i = 1, keynumber do
328 globalkeys = awful.util.table.join(globalkeys,
329 awful.key({ modkey }, i,
331 local screen = mouse.screen
332 if tags[screen][i] then
333 awful.tag.viewonly(tags[screen][i])
336 awful.key({ modkey, "Control" }, i,
338 local screen = mouse.screen
339 if tags[screen][i] then
340 tags[screen][i].selected = not tags[screen][i].selected
343 awful.key({ modkey, "Shift" }, i,
345 if client.focus and tags[client.focus.screen][i] then
346 awful.client.movetotag(tags[client.focus.screen][i])
349 awful.key({ modkey, "Control", "Shift" }, i,
351 if client.focus and tags[client.focus.screen][i] then
352 awful.client.toggletag(tags[client.focus.screen][i])
355 awful.key({ modkey, "Shift" }, "F" .. i,
357 local screen = mouse.screen
358 if tags[screen][i] then
359 for k, c in pairs(awful.client.getmarked()) do
360 awful.client.movetotag(tags[screen][i], c)
369 globalkeys = awful.util.table.join(globalkeys,
370 awful.key({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end),
371 awful.key({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end),
372 awful.key({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end),
373 awful.key({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end),
374 awful.key({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end),
375 awful.key({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end),
376 awful.key({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end),
377 awful.key({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end),
378 awful.key({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end),
379 awful.key({ cmdmodkey }, "backslash", function () awful.util.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end),
380 awful.key({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end)
384 globalkeys = awful.util.table.join(globalkeys,
385 awful.key({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end),
386 awful.key({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end),
387 awful.key({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end),
388 awful.key({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end),
389 awful.key({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end),
390 awful.key({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end),
391 awful.key({ cmdmodkey }, "x", function () awful.util.spawn_with_shell("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end),
392 awful.key({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end),
393 awful.key(nil, "XF86ScreenSaver", function () awful.util.spawn("xset dpms force off") end)
397 root.keys(globalkeys)
401 -- Hook function to execute when focusing a client.
402 awful.hooks.focus.register(function (c)
403 if not awful.client.ismarked(c) then
404 c.border_color = beautiful.border_focus
408 -- Hook function to execute when unfocusing a client.
409 awful.hooks.unfocus.register(function (c)
410 if not awful.client.ismarked(c) then
411 c.border_color = beautiful.border_normal
415 -- Hook function to execute when marking a client
416 awful.hooks.marked.register(function (c)
417 c.border_color = beautiful.border_marked
420 -- Hook function to execute when unmarking a client.
421 awful.hooks.unmarked.register(function (c)
422 c.border_color = beautiful.border_focus
425 -- Hook function to execute when the mouse enters a client.
426 awful.hooks.mouse_enter.register(function (c)
427 -- Sloppy focus, but disabled for magnifier layout
428 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
429 and awful.client.focus.filter(c) then
434 -- Hook function to execute when a new client appears.
435 awful.hooks.manage.register(function (c, startup)
436 -- If we are not managing this application at startup,
437 -- move it to the screen where the mouse is.
438 -- We only do it for filtered windows (i.e. no dock, etc).
439 if not startup and awful.client.focus.filter(c) then
440 c.screen = mouse.screen
445 awful.titlebar.add(c, { modkey = modkey })
447 -- Add mouse bindings
448 c:buttons(awful.util.table.join(
449 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
450 awful.button({ modkey }, 1, awful.mouse.client.move),
451 awful.button({ modkey }, 3, awful.mouse.client.resize)
453 -- New client may not receive focus
454 -- if they're not focusable, so set border anyway.
455 c.border_width = beautiful.border_width
456 c.border_color = beautiful.border_normal
458 -- Check if the application should be floating.
459 -- OVERRIDDEN, SEE tiledapps BELOW
461 local inst = c.instance
462 if floatapps[cls] then
463 awful.client.floating.set(c, floatapps[cls])
464 elseif floatapps[inst] then
465 awful.client.floating.set(c, floatapps[inst])
468 -- Override with tiledapps
469 awful.client.floating.set(c, not (tiledapps[inst] or tiledapps[cls]))
471 -- Check application->screen/tag mappings.
474 target = apptags[cls]
475 elseif apptags[inst] then
476 target = apptags[inst]
479 c.screen = target.screen
480 awful.client.movetotag(tags[target.screen][target.tag], c)
483 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
489 -- Set the windows at the slave,
490 -- i.e. put it at the end of others instead of setting it master.
491 -- awful.client.setslave(c)
493 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
494 c.size_hints_honor = true
497 if maxapps[inst] or maxapps[cls] then
498 c.maximized_horizontal = not c.maximized_horizontal
499 c.maximized_vertical = not c.maximized_vertical
503 -- Hook function to execute when arranging the screen.
504 -- (tag switch, new client, etc)
505 awful.hooks.arrange.register(function (screen)
506 local layout = awful.layout.getname(awful.layout.get(screen))
507 if layout and beautiful["layout_" ..layout] then
508 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
510 mylayoutbox[screen].image = nil
513 -- Give focus to the latest client in history if no window has focus
514 -- or if the current window is a desktop or a dock one.
515 if not client.focus then
516 local c = awful.client.focus.history.get(screen, 0)
517 if c then client.focus = c end
521 -- Hook called every second
522 awful.hooks.timer.register(1, function ()
523 mytimebox.text = os.date(" %a %d %b %H:%M:%S ")
526 -- Hook called every sixty seconds
527 function hook_battery()
528 mybatterybox.text = " " .. get_acpibatt() .. " "
531 -- {{{ Statusbar battery
533 function get_acpibatt()
535 local f = io.popen('acpi -b', 'r')
537 return "acpi -b failed"
540 local s = f:read('*l')
546 -- Battery 0: Discharging, 89%, 00:02:14 remaining
547 -- Battery 0: Charging, 58%, 00:02:14 until charged
548 -- Battery 0: Full, 100%
549 -- so find the first bit first and then go look for the time
550 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
551 local st, en, time = string.find(s, ',%s(%d+:%d+):%d+%s%a+', en);
553 if not status or not percent then -- time can be empty if we're full
554 return "couldn't parse line " .. s
561 if status == 'Charging' then
562 return '↑ ' .. percent;
563 elseif status == 'Discharging' then
572 local function get_bat()
573 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
574 for line in a:lines() do
578 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
579 for line in b:lines() do
583 batt=math.floor(now*100/full)
584 batterywidget:bar_data_add("bat",batt )
589 awful.hooks.timer.register(20, hook_battery)
590 -- awful.hooks.timer.register(5, get_bat)
593 -- Highlight statusbars on the screen that has focus,
594 -- set this to false if you only have one screen or
595 -- you don't like it :P
596 if screen.count() > 1 then
597 statusbar_highlight_focus = true
599 statusbar_highlight_focus = false
604 function displayMonth(month,year,weekStart)
605 local t,wkSt=os.time{year=year, month=month+1, day=0},weekStart or 1
606 local d=os.date("*t",t)
607 local mthDays,stDay=d.day,(d.wday-d.day-wkSt+1)%7
612 lines[x+1] = os.date("%a ",os.time{year=2006,month=1,day=x+wkSt})
617 while writeLine < (stDay + 1) do
618 lines[writeLine] = lines[writeLine] .. " "
619 writeLine = writeLine + 1
623 if writeLine == 8 then
626 if writeLine == 1 or x == 1 then
627 lines[8] = lines[8] .. os.date(" %V",os.time{year=year,month=month,day=x})
629 if (#(tostring(x)) == 1) then
632 lines[writeLine] = lines[writeLine] .. " " .. x
633 writeLine = writeLine + 1
635 local header = os.date("%B %Y\n",os.time{year=year,month=month,day=1})
636 header = string.rep(" ", math.floor((#(lines[1]) - #header) / 2 )) .. header
638 return header .. table.concat(lines, '\n')
642 function switchNaughtyMonth(switchMonths)
643 if (#calendar < 3) then return end
644 local swMonths = switchMonths or 1
645 calendar[1] = calendar[1] + swMonths
646 calendar[3].box.widgets[2].text = displayMonth(calendar[1], calendar[2], 2)
649 mytimebox.mouse_enter = function ()
650 local month, year = os.date('%m'), os.date('%Y')
651 calendar = { month, year,
653 text = displayMonth(month, year, 2),
654 timeout = 0, hover_timeout = 0.5,
655 width = 200, screen = mouse.screen
659 mytimebox.mouse_leave = function () naughty.destroy(calendar[3]) end
661 mytimebox.buttons = awful.util.table.join(
662 awful.button({ }, 1, function() switchNaughtyMonth(-1) end),
663 awful.button({ }, 3, function() switchNaughtyMonth(1) end),
664 awful.button({ }, 4, function() switchNaughtyMonth(-1) end),
665 awful.button({ }, 5, function() switchNaughtyMonth(1) end),
666 awful.button({ 'Shift' }, 1, function() switchNaughtyMonth(-12) end),
667 awful.button({ 'Shift' }, 3, function() switchNaughtyMonth(12) end),
668 awful.button({ 'Shift' }, 4, function() switchNaughtyMonth(-12) end),
669 awful.button({ 'Shift' }, 5, function() switchNaughtyMonth(12) end)