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
3 require("awful.autofocus")
5 -- Theme handling library
7 -- Notification library
10 -- Load Debian menu entries
11 require("debian.menu")
13 -- {{{ Variable definitions
14 -- Themes define colours, icons, and wallpapers
15 -- The default is a dark theme
16 theme_path = "/usr/share/awesome/themes/default/theme.lua"
17 -- Uncommment this for a lighter theme
18 -- theme_path = "/usr/share/awesome/themes/sky/theme.lua"
20 -- Actually load theme
21 beautiful.init(theme_path)
23 -- This is used later as the default terminal and editor to run.
24 terminal = "x-terminal-emulator"
25 editor = os.getenv("EDITOR") or "editor"
26 editor_cmd = terminal .. " -e " .. editor
29 -- Usually, Mod4 is the key with a logo between Control and Alt.
30 -- If you do not like this or do not have such a key,
31 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
32 -- However, you can use another modifier like Mod1, but it may interact with others.
35 -- Table of layouts to cover with awful.layout.inc, order matters.
38 awful.layout.suit.tile,
39 awful.layout.suit.tile.left,
40 awful.layout.suit.tile.bottom,
41 awful.layout.suit.tile.top,
42 awful.layout.suit.fair,
43 awful.layout.suit.fair.horizontal,
44 awful.layout.suit.spiral,
45 awful.layout.suit.spiral.dwindle,
46 awful.layout.suit.max,
47 awful.layout.suit.max.fullscreen,
48 awful.layout.suit.magnifier,
49 awful.layout.suit.floating
52 -- Table of clients that should be set floating. The index may be either
53 -- the application class or instance. The instance is useful when running
54 -- a console app in a terminal like (Music on Console)
55 -- xterm -name mocp -e mocp
56 -- OVERRULED BY TILEDAPPS BELOW
65 ["Play stream"] = true,
69 -- Applications that should never float, assuming everything else floats
76 -- Applications that should be maximised
87 -- Applications to be moved to a pre-defined tag by class or instance.
88 -- Use the screen and tags indices.
91 ["Navigator"] = { screen = 1, tag = 9 },
93 ["-v"] = { screen = 1, tag = 8 },
96 -- Define if we want to use titlebar on all applications.
101 -- Define a tag table which hold all screen tags.
103 for s = 1, screen.count() do
104 -- Each screen has its own tag table.
105 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s)
110 -- Create a laucher widget and a main menu
112 { "manual", terminal .. " -e man awesome" },
113 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
114 { "restart", awesome.restart },
115 { "quit", awesome.quit }
118 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
119 { "Debian", debian.menu.Debian_menu.Debian },
120 { "open terminal", terminal }
124 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
129 -- Create a textclock widget
130 mytextclock = awful.widget.textclock({ align = "right" })
133 mysystray = widget({ type = "systray" })
135 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
137 -- Create a wibox for each screen and add it
142 mytaglist.buttons = awful.util.table.join(
143 awful.button({ }, 1, awful.tag.viewonly),
144 awful.button({ modkey }, 1, awful.client.movetotag),
145 awful.button({ }, 3, awful.tag.viewtoggle),
146 awful.button({ modkey }, 3, awful.client.toggletag),
147 awful.button({ }, 4, awful.tag.viewnext),
148 awful.button({ }, 5, awful.tag.viewprev)
151 mytasklist.buttons = awful.util.table.join(
152 awful.button({ }, 1, function (c)
153 if not c:isvisible() then
154 awful.tag.viewonly(c:tags()[1])
159 awful.button({ }, 3, function ()
164 instance = awful.menu.clients({ width=250 })
167 awful.button({ }, 4, function ()
168 awful.client.focus.byidx(1)
169 if client.focus then client.focus:raise() end
171 awful.button({ }, 5, function ()
172 awful.client.focus.byidx(-1)
173 if client.focus then client.focus:raise() end
176 for s = 1, screen.count() do
177 -- Create a promptbox for each screen
178 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
179 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
180 -- We need one layoutbox per screen.
181 mylayoutbox[s] = awful.widget.layoutbox(s)
182 mylayoutbox[s]:buttons(awful.util.table.join(
183 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
184 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
185 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
186 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
187 -- Create a taglist widget
188 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
190 -- Create a tasklist widget
191 mytasklist[s] = awful.widget.tasklist(function(c)
192 return awful.widget.tasklist.label.currenttags(c, s)
193 end, mytasklist.buttons)
196 mywibox[s] = awful.wibox({ position = "top", screen = s })
197 -- Add widgets to the wibox - order matters
198 mywibox[s].widgets = {
203 layout = awful.widget.layout.horizontal.leftright
208 s == screen.count() and mysystray or nil,
210 layout = awful.widget.layout.horizontal.rightleft
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),
249 awful.key({ modkey, "Shift" }, "Right", function () awful.screen.focus( 1) end),
250 awful.key({ modkey, "Shift" }, "Left", function () awful.screen.focus(-1) end),
251 awful.key({ modkey, "Shift" }, "h", awful.tag.viewprev ),
252 awful.key({ modkey, "Shift" }, "l", awful.tag.viewnext ),
254 awful.key({ modkey, }, "k",
256 awful.client.focus.byidx( 1)
257 if client.focus then client.focus:raise() end
259 awful.key({ modkey, }, "j",
261 awful.client.focus.byidx(-1)
262 if client.focus then client.focus:raise() end
264 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
266 -- Layout manipulation
267 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( 1) end),
268 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( -1) end),
269 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus( 1) end),
270 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus(-1) end),
271 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
272 awful.key({ modkey, }, "Tab",
274 awful.client.focus.history.previous()
281 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
282 awful.key({ modkey, "Control" }, "r", awesome.restart),
283 awful.key({ modkey, "Shift" }, "q", awesome.quit),
285 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
286 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
287 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
288 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
289 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
290 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
291 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
292 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
295 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
297 awful.key({ modkey }, "x",
299 awful.prompt.run({ prompt = "Run Lua code: " },
300 mypromptbox[mouse.screen].widget,
301 awful.util.eval, nil,
302 awful.util.getdir("cache") .. "/history_eval")
306 clientkeys = awful.util.table.join(
307 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
308 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
309 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
310 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
311 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
312 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
313 awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
314 awful.key({ modkey, }, "m",
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 -- Bind all key numbers to tags.
328 -- Be careful: we use keycodes to make it works on any keyboard layout.
329 -- This should map on the top row of your keyboard, usually 1 to 9.
330 for i = 1, keynumber do
331 globalkeys = awful.util.table.join(globalkeys,
332 awful.key({ modkey }, "#" .. i + 9,
334 local screen = mouse.screen
335 if tags[screen][i] then
336 awful.tag.viewonly(tags[screen][i])
339 awful.key({ modkey, "Control" }, "#" .. i + 9,
341 local screen = mouse.screen
342 if tags[screen][i] then
343 awful.tag.viewtoggle(tags[screen][i])
346 awful.key({ modkey, "Shift" }, "#" .. i + 9,
348 if client.focus and tags[client.focus.screen][i] then
349 awful.client.movetotag(tags[client.focus.screen][i])
352 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
354 if client.focus and tags[client.focus.screen][i] then
355 awful.client.toggletag(tags[client.focus.screen][i])
360 clientbuttons = awful.util.table.join(
361 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
362 awful.button({ modkey }, 1, awful.mouse.client.move),
363 awful.button({ modkey }, 3, awful.mouse.client.resize))
368 globalkeys = awful.util.table.join(globalkeys,
369 awful.key({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end),
370 awful.key({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end),
371 awful.key({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end),
372 awful.key({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end),
373 awful.key({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end),
374 awful.key({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end),
375 awful.key({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end),
376 awful.key({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end),
377 awful.key({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end),
378 awful.key({ cmdmodkey }, "backslash", function () awful.util.spawn_with_shell("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end),
379 awful.key({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn_with_shell("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end)
383 globalkeys = awful.util.table.join(globalkeys,
384 awful.key({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end),
385 awful.key({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end),
386 awful.key({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end),
387 awful.key({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end),
388 -- awful.key({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end),
389 awful.key({ cmdmodkey }, "r", function () mypromptbox[mouse.screen]:run() 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 awful.rules.rules = {
402 -- All clients will match this rule.
404 properties = { border_width = beautiful.border_width,
405 border_color = beautiful.border_normal,
408 buttons = clientbuttons } },
409 { rule = { class = "MPlayer" },
410 properties = { floating = true } },
411 { rule = { class = "pinentry" },
412 properties = { floating = true } },
413 { rule = { class = "gimp" },
414 properties = { floating = true } },
415 { rule = { class = "twinkle" },
416 properties = { floating = true } },
417 { rule = { class = "Play stream" },
418 properties = { floating = true } },
419 { rule = { class = "gscan2pdf" },
420 properties = { floating = true } },
421 { rule = { class = "Add-ons" },
422 properties = { floating = true } },
423 -- Set Firefox to always map on tags number 2 of screen 1.
424 { rule = { class = "Firefox" },
425 properties = { tag = tags[1][9] } },
426 { rule = { class = "-v" },
427 properties = { tag = tags[1][8] } },
432 -- Signal function to execute when a new client appears.
433 client.add_signal("manage", function (c, startup)
435 -- awful.titlebar.add(c, { modkey = modkey })
437 -- Enable sloppy focus
438 c:add_signal("mouse::enter", function(c)
439 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
440 and awful.client.focus.filter(c) then
446 -- Set the windows at the slave,
447 -- i.e. put it at the end of others instead of setting it master.
448 -- awful.client.setslave(c)
450 -- Put windows in a smart way, only if they does not set an initial position.
451 if not c.size_hints.user_position and not c.size_hints.program_position then
452 awful.placement.no_overlap(c)
453 awful.placement.no_offscreen(c)
458 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
459 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
461 -- Hook called every second
462 awful.hooks.timer.register(1, function ()
463 mytextclock.text = os.date(" %a %d %b %H:%M:%S ")
466 -- Hook called every sixty seconds
467 function hook_battery()
468 mybatterybox.text = " " .. get_acpibatt() .. " "
471 -- {{{ Statusbar battery
473 function get_acpibatt()
475 local f = io.popen('acpi -b', 'r')
477 return "acpi -b failed"
480 local s = f:read('*l')
486 -- Battery 0: Discharging, 89%, 00:02:14 remaining
487 -- Battery 0: Charging, 58%, 00:02:14 until charged
488 -- Battery 0: Full, 100%
489 -- so find the first bit first and then go look for the time
490 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
491 local st, en, time = string.find(s, ',%s(%d+:%d+):%d+%s%a+', en);
493 if not status or not percent then -- time can be empty if we're full
494 return "couldn't parse line " .. s
501 if status == 'Charging' then
502 return '↑ ' .. percent;
503 elseif status == 'Discharging' then
512 local function get_bat()
513 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
514 for line in a:lines() do
518 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
519 for line in b:lines() do
523 batt=math.floor(now*100/full)
524 batterywidget:bar_data_add("bat",batt )
529 awful.hooks.timer.register(20, hook_battery)
530 -- awful.hooks.timer.register(5, get_bat)
533 -- Highlight statusbars on the screen that has focus,
534 -- set this to false if you only have one screen or
535 -- you don't like it :P
536 if screen.count() > 1 then
537 statusbar_highlight_focus = true
539 statusbar_highlight_focus = false