1 -- Standard awesome library
2 local gears = require("gears")
3 local awful = require("awful")
4 awful.rules = require("awful.rules")
5 require("awful.autofocus")
6 -- Widget and layout library
7 local wibox = require("wibox")
8 -- Theme handling library
9 local beautiful = require("beautiful")
10 -- Notification library
11 local naughty = require("naughty")
12 local menubar = require("menubar")
13 -- local vicious = require("vicious")
15 -- Load Debian menu entries
16 require("debian.menu")
19 -- Check if awesome encountered an error during startup and fell back to
20 -- another config (This code will only ever execute for the fallback config)
21 if awesome.startup_errors then
22 naughty.notify({ preset = naughty.config.presets.critical,
23 title = "Oops, there were errors during startup!",
24 text = awesome.startup_errors })
27 -- Handle runtime errors after startup
29 local in_error = false
30 awesome.connect_signal("debug::error", function (err)
31 -- Make sure we don't go into an endless error loop
32 if in_error then return end
35 naughty.notify({ preset = naughty.config.presets.critical,
36 title = "Oops, an error happened!",
43 -- {{{ Variable definitions
44 -- Themes define colours, icons, font and wallpapers.
45 beautiful.init("/usr/share/awesome/themes/sky/theme.lua")
46 -- beautiful.init("/usr/share/awesome/themes/default/theme.lua")
47 -- theme.wallpaper = "/home/mako/images/Flag_of_Cascadia.png"
48 for s = 1, screen.count() do
49 gears.wallpaper.maximized(beautiful.wallpaper, s, true)
51 -- recipes here: https://wiki.archlinux.org/index.php/Awesome#Wallpaper
53 -- This is used later as the default terminal and editor to run.
54 terminal = "x-terminal-emulator"
55 editor = os.getenv("EDITOR") or "editor"
56 editor_cmd = terminal .. " -e " .. editor
59 -- Usually, Mod4 is the key with a logo between Control and Alt.
60 -- If you do not like this or do not have such a key,
61 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
62 -- However, you can use another modifier like Mod1, but it may interact with others.
65 -- Table of layouts to cover with awful.layout.inc, order matters.
68 awful.layout.suit.tile,
69 awful.layout.suit.max,
70 awful.layout.suit.floating
75 -- if beautiful.wallpaper then
76 -- for s = 1, screen.count() do
77 -- gears.wallpaper.maximized(beautiful.wallpaper, s, true)
84 -- Define a tag table which hold all screen tags.
86 for s = 1, screen.count() do
87 -- Each screen has its own tag table.
88 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
93 -- Create a laucher widget and a main menu
95 { "manual", terminal .. " -e man awesome" },
96 { "edit config", editor_cmd .. " " .. awesome.conffile },
97 { "restart", awesome.restart },
98 { "quit", awesome.quit }
101 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
102 { "Debian", debian.menu.Debian_menu.Debian },
103 { "open terminal", terminal }
107 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
110 -- Menubar configuration
111 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
115 -- Create a textclock widget
116 mytextclock = awful.widget.textclock()
118 -- Create a wibox for each screen and add it
123 mytaglist.buttons = awful.util.table.join(
124 awful.button({ }, 1, awful.tag.viewonly),
125 awful.button({ modkey }, 1, awful.client.movetotag),
126 awful.button({ }, 3, awful.tag.viewtoggle),
127 awful.button({ modkey }, 3, awful.client.toggletag),
128 awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
129 awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
132 mytasklist.buttons = awful.util.table.join(
133 awful.button({ }, 1, function (c)
134 if c == client.focus then
137 -- Without this, the following
138 -- :isvisible() makes no sense
140 if not c:isvisible() then
141 awful.tag.viewonly(c:tags()[1])
143 -- This will also un-minimize
144 -- the client, if needed
149 awful.button({ }, 3, function ()
154 instance = awful.menu.clients({ width=250 })
157 awful.button({ }, 4, function ()
158 awful.client.focus.byidx(1)
159 if client.focus then client.focus:raise() end
161 awful.button({ }, 5, function ()
162 awful.client.focus.byidx(-1)
163 if client.focus then client.focus:raise() end
166 for s = 1, screen.count() do
167 -- Create a promptbox for each screen
168 mypromptbox[s] = awful.widget.prompt()
169 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
170 -- We need one layoutbox per screen.
171 mylayoutbox[s] = awful.widget.layoutbox(s)
172 mylayoutbox[s]:buttons(awful.util.table.join(
173 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
174 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
175 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
176 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
177 -- Create a taglist widget
178 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
180 -- Create a tasklist widget
181 mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
184 mywibox[s] = awful.wibox({ position = "top", screen = s })
186 -- Widgets that are aligned to the left
187 local left_layout = wibox.layout.fixed.horizontal()
188 left_layout:add(mylauncher)
189 left_layout:add(mytaglist[s])
190 left_layout:add(mypromptbox[s])
192 -- Widgets that are aligned to the right
193 local right_layout = wibox.layout.fixed.horizontal()
194 if s == 1 then right_layout:add(wibox.widget.systray()) end
195 right_layout:add(mytextclock)
196 right_layout:add(mylayoutbox[s])
198 -- Now bring it all together (with the tasklist in the middle)
199 local layout = wibox.layout.align.horizontal()
200 layout:set_left(left_layout)
201 layout:set_middle(mytasklist[s])
202 layout:set_right(right_layout)
204 mywibox[s]:set_widget(layout)
208 -- {{{ Mouse bindings
209 root.buttons(awful.util.table.join(
210 awful.button({ }, 3, function () mymainmenu:toggle() end),
211 awful.button({ }, 4, awful.tag.viewnext),
212 awful.button({ }, 5, awful.tag.viewprev)
217 globalkeys = awful.util.table.join(
218 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
219 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
220 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
222 awful.key({ modkey, }, "j",
224 awful.client.focus.byidx( 1)
225 if client.focus then client.focus:raise() end
227 awful.key({ modkey, }, "k",
229 awful.client.focus.byidx(-1)
230 if client.focus then client.focus:raise() end
232 awful.key({ modkey, }, "w", function () mymainmenu:show() end),
234 -- Layout manipulation
235 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
236 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
237 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
238 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
239 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
240 awful.key({ modkey, }, "Tab",
242 awful.client.focus.history.previous()
249 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
250 awful.key({ modkey, "Control" }, "r", awesome.restart),
251 awful.key({ modkey, "Shift" }, "q", awesome.quit),
253 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
254 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
255 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
256 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
257 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
258 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
259 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
260 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
262 awful.key({ modkey, "Control" }, "n", awful.client.restore),
265 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
267 awful.key({ modkey }, "x",
269 awful.prompt.run({ prompt = "Run in Terminal: " },
270 mypromptbox[mouse.screen].widget,
271 function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end) end),
273 awful.key({ modkey, "Shift" }, "x",
275 awful.prompt.run({ prompt = "Run Lua code: " },
276 mypromptbox[mouse.screen].widget,
277 awful.util.eval, nil,
278 awful.util.getdir("cache") .. "/history_eval")
280 awful.key({ modkey }, "q",
282 awful.tag.incnmaster(-1)
286 awful.key({ modkey }, "p", function() menubar.show() end)
289 clientkeys = awful.util.table.join(
290 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
291 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
292 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
293 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
294 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
295 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
296 awful.key({ modkey, }, "n",
298 -- The client currently has the input focus, so it cannot be
299 -- minimized, since minimized clients can't have the focus.
302 awful.key({ modkey, }, "m",
304 c.maximized_horizontal = not c.maximized_horizontal
305 c.maximized_vertical = not c.maximized_vertical
309 -- Bind all key numbers to tags.
310 -- Be careful: we use keycodes to make it works on any keyboard layout.
311 -- This should map on the top row of your keyboard, usually 1 to 9.
313 globalkeys = awful.util.table.join(globalkeys,
315 awful.key({ modkey }, "#" .. i + 9,
317 local screen = mouse.screen
318 local tag = awful.tag.gettags(screen)[i]
320 awful.tag.viewonly(tag)
324 awful.key({ modkey, "Control" }, "#" .. i + 9,
326 local screen = mouse.screen
327 local tag = awful.tag.gettags(screen)[i]
329 awful.tag.viewtoggle(tag)
332 -- Move client to tag.
333 awful.key({ modkey, "Shift" }, "#" .. i + 9,
336 local tag = awful.tag.gettags(client.focus.screen)[i]
338 awful.client.movetotag(tag)
343 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
346 local tag = awful.tag.gettags(client.focus.screen)[i]
348 awful.client.toggletag(tag)
354 clientbuttons = awful.util.table.join(
355 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
356 awful.button({ modkey }, 1, awful.mouse.client.move),
357 awful.button({ modkey }, 3, awful.mouse.client.resize))
360 root.keys(globalkeys)
364 -- Rules to apply to new clients (through the "manage" signal).
365 awful.rules.rules = {
366 -- All clients will match this rule.
368 properties = { border_width = beautiful.border_width,
369 border_color = beautiful.border_normal,
370 focus = awful.client.focus.filter,
373 buttons = clientbuttons } },
374 { rule = { class = "MPlayer" },
375 properties = { floating = true } },
376 { rule = { class = "pinentry" },
377 properties = { floating = true } },
378 { rule = { class = "gimp" },
379 properties = { floating = true } },
380 -- set irc to always be on screen 1, tag 1
381 { rule = { title= "irc" },
382 properties = { tag = tags[1][1] } },
383 -- set emacs instances to launch into tag 1,2
384 { rule = { class = "emacs" },
385 properties = { tag = tags[1][2] } },
386 -- set icedove instances to launch into tag 1,8
387 { rule = { class = "Icedove" },
388 properties = { tag = tags[1][7] } },
389 -- set icedove instances to launch into tag 1,8
390 { rule = { class = "spotify" },
391 properties = { tag = tags[1][8] } },
392 -- set oli instances to launch into tag 1,8
393 { rule = { title = "oli" },
394 properties = { tag = tags[1][9] } },
395 -- Set Firefox to always map to 1,3 then 2,3
396 -- { rule = { class = "Firefox" },
397 -- properties = { tag = tags[1][3] } },
398 -- { rule = { class = "Firefox" },
399 -- properties = { tag = tags[2][3] } },
400 -- set mutt instances to launch into tag 1,1, then 2,1
401 -- { rule = { title = "mutt" },
402 -- properties = { tag = tags[1][1] } },
403 -- { rule = { title= "mutt" },
404 -- properties = { tag = tags[2][1] } },
409 -- Signal function to execute when a new client appears.
410 client.connect_signal("manage", function (c, startup)
411 -- Enable sloppy focus
412 c:connect_signal("mouse::enter", function(c)
413 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
414 and awful.client.focus.filter(c) then
420 -- Set the windows at the slave,
421 -- i.e. put it at the end of others instead of setting it master.
422 -- awful.client.setslave(c)
424 -- Put windows in a smart way, only if they does not set an initial position.
425 if not c.size_hints.user_position and not c.size_hints.program_position then
426 awful.placement.no_overlap(c)
427 awful.placement.no_offscreen(c)
429 elseif not c.size_hints.user_position and not c.size_hints.program_position then
430 -- Prevent clients from being unreachable after screen count change
431 awful.placement.no_offscreen(c)
434 local titlebars_enabled = false
435 if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
436 -- buttons for the titlebar
437 local buttons = awful.util.table.join(
438 awful.button({ }, 1, function()
441 awful.mouse.client.move(c)
443 awful.button({ }, 3, function()
446 awful.mouse.client.resize(c)
450 -- Widgets that are aligned to the left
451 local left_layout = wibox.layout.fixed.horizontal()
452 left_layout:add(awful.titlebar.widget.iconwidget(c))
453 left_layout:buttons(buttons)
455 -- Widgets that are aligned to the right
456 local right_layout = wibox.layout.fixed.horizontal()
457 right_layout:add(awful.titlebar.widget.floatingbutton(c))
458 right_layout:add(awful.titlebar.widget.maximizedbutton(c))
459 right_layout:add(awful.titlebar.widget.stickybutton(c))
460 right_layout:add(awful.titlebar.widget.ontopbutton(c))
461 right_layout:add(awful.titlebar.widget.closebutton(c))
463 -- The title goes in the middle
464 local middle_layout = wibox.layout.flex.horizontal()
465 local title = awful.titlebar.widget.titlewidget(c)
466 title:set_align("center")
467 middle_layout:add(title)
468 middle_layout:buttons(buttons)
470 -- Now bring it all together
471 local layout = wibox.layout.align.horizontal()
472 layout:set_left(left_layout)
473 layout:set_right(right_layout)
474 layout:set_middle(middle_layout)
476 awful.titlebar(c):set_widget(layout)
480 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
481 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)