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")
14 -- Load Debian menu entries
15 require("debian.menu")
18 -- Check if awesome encountered an error during startup and fell back to
19 -- another config (This code will only ever execute for the fallback config)
20 if awesome.startup_errors then
21 naughty.notify({ preset = naughty.config.presets.critical,
22 title = "Oops, there were errors during startup!",
23 text = awesome.startup_errors })
26 -- Handle runtime errors after startup
28 local in_error = false
29 awesome.connect_signal("debug::error", function (err)
30 -- Make sure we don't go into an endless error loop
31 if in_error then return end
34 naughty.notify({ preset = naughty.config.presets.critical,
35 title = "Oops, an error happened!",
42 -- {{{ Variable definitions
43 -- Themes define colours, icons, font and wallpapers.
44 beautiful.init("/usr/share/awesome/themes/sky/theme.lua")
45 theme.wallpaper = "/home/mako/images/Flag_of_Cascadia.png"
46 -- beautiful.init("~/.config/awesome/themes/default/theme.lua")
47 for s = 1, screen.count() do
48 gears.wallpaper.maximized(beautiful.wallpaper, s, true)
50 -- recipes here: https://wiki.archlinux.org/index.php/Awesome#Wallpaper
52 -- This is used later as the default terminal and editor to run.
53 terminal = "x-terminal-emulator"
54 editor = os.getenv("EDITOR") or "editor"
55 editor_cmd = terminal .. " -e " .. editor
58 -- Usually, Mod4 is the key with a logo between Control and Alt.
59 -- If you do not like this or do not have such a key,
60 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
61 -- However, you can use another modifier like Mod1, but it may interact with others.
64 -- Table of layouts to cover with awful.layout.inc, order matters.
67 awful.layout.suit.tile,
68 awful.layout.suit.max,
69 awful.layout.suit.floating
74 -- if beautiful.wallpaper then
75 -- for s = 1, screen.count() do
76 -- gears.wallpaper.maximized(beautiful.wallpaper, s, true)
83 -- Define a tag table which hold all screen tags.
85 for s = 1, screen.count() do
86 -- Each screen has its own tag table.
87 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
92 -- Create a laucher widget and a main menu
94 { "manual", terminal .. " -e man awesome" },
95 { "edit config", editor_cmd .. " " .. awesome.conffile },
96 { "restart", awesome.restart },
97 { "quit", awesome.quit }
100 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
101 { "Debian", debian.menu.Debian_menu.Debian },
102 { "open terminal", terminal }
106 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
109 -- Menubar configuration
110 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
114 -- Create a textclock widget
115 mytextclock = awful.widget.textclock()
117 -- Create a wibox for each screen and add it
122 mytaglist.buttons = awful.util.table.join(
123 awful.button({ }, 1, awful.tag.viewonly),
124 awful.button({ modkey }, 1, awful.client.movetotag),
125 awful.button({ }, 3, awful.tag.viewtoggle),
126 awful.button({ modkey }, 3, awful.client.toggletag),
127 awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
128 awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
131 mytasklist.buttons = awful.util.table.join(
132 awful.button({ }, 1, function (c)
133 if c == client.focus then
136 -- Without this, the following
137 -- :isvisible() makes no sense
139 if not c:isvisible() then
140 awful.tag.viewonly(c:tags()[1])
142 -- This will also un-minimize
143 -- the client, if needed
148 awful.button({ }, 3, function ()
153 instance = awful.menu.clients({
154 theme = { width = 250 }
158 awful.button({ }, 4, function ()
159 awful.client.focus.byidx(1)
160 if client.focus then client.focus:raise() end
162 awful.button({ }, 5, function ()
163 awful.client.focus.byidx(-1)
164 if client.focus then client.focus:raise() end
167 for s = 1, screen.count() do
168 -- Create a promptbox for each screen
169 mypromptbox[s] = awful.widget.prompt()
170 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
171 -- We need one layoutbox per screen.
172 mylayoutbox[s] = awful.widget.layoutbox(s)
173 mylayoutbox[s]:buttons(awful.util.table.join(
174 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
175 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
176 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
177 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
178 -- Create a taglist widget
179 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
181 -- Create a tasklist widget
182 mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
185 mywibox[s] = awful.wibox({ position = "top", screen = s })
187 -- Widgets that are aligned to the left
188 local left_layout = wibox.layout.fixed.horizontal()
189 left_layout:add(mylauncher)
190 left_layout:add(mytaglist[s])
191 left_layout:add(mypromptbox[s])
193 -- Widgets that are aligned to the right
194 local right_layout = wibox.layout.fixed.horizontal()
195 if s == 1 then right_layout:add(wibox.widget.systray()) end
196 right_layout:add(mytextclock)
197 right_layout:add(mylayoutbox[s])
199 -- Now bring it all together (with the tasklist in the middle)
200 local layout = wibox.layout.align.horizontal()
201 layout:set_left(left_layout)
202 layout:set_middle(mytasklist[s])
203 layout:set_right(right_layout)
205 mywibox[s]:set_widget(layout)
209 -- {{{ Mouse bindings
210 root.buttons(awful.util.table.join(
211 awful.button({ }, 3, function () mymainmenu:toggle() end),
212 awful.button({ }, 4, awful.tag.viewnext),
213 awful.button({ }, 5, awful.tag.viewprev)
218 globalkeys = awful.util.table.join(
219 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
220 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
221 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
223 awful.key({ modkey, }, "j",
225 awful.client.focus.byidx( 1)
226 if client.focus then client.focus:raise() end
228 awful.key({ modkey, }, "k",
230 awful.client.focus.byidx(-1)
231 if client.focus then client.focus:raise() end
233 awful.key({ modkey, }, "w", function () mymainmenu:show() end),
235 -- Layout manipulation
236 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
237 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
238 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
239 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
240 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
241 awful.key({ modkey, }, "Tab",
243 awful.client.focus.history.previous()
250 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
251 awful.key({ modkey, "Control" }, "r", awesome.restart),
252 awful.key({ modkey, "Shift" }, "q", awesome.quit),
254 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
255 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
256 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
257 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
258 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
259 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
260 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
261 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
263 awful.key({ modkey, "Control" }, "n", awful.client.restore),
266 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
268 awful.key({ modkey }, "x",
270 awful.prompt.run({ prompt = "Run in Terminal: " },
271 mypromptbox[mouse.screen].widget,
272 function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end) end),
274 awful.key({ modkey, "Shift" }, "x",
276 awful.prompt.run({ prompt = "Run Lua code: " },
277 mypromptbox[mouse.screen].widget,
278 awful.util.eval, nil,
279 awful.util.getdir("cache") .. "/history_eval")
281 awful.key({ modkey }, "q",
283 awful.tag.incnmaster(-1)
287 awful.key({ modkey }, "p", function() menubar.show() end)
290 clientkeys = awful.util.table.join(
291 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
292 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
293 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
294 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
295 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
296 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
297 awful.key({ modkey, }, "n",
299 -- The client currently has the input focus, so it cannot be
300 -- minimized, since minimized clients can't have the focus.
303 awful.key({ modkey, }, "m",
305 c.maximized_horizontal = not c.maximized_horizontal
306 c.maximized_vertical = not c.maximized_vertical
310 -- Bind all key numbers to tags.
311 -- Be careful: we use keycodes to make it works on any keyboard layout.
312 -- This should map on the top row of your keyboard, usually 1 to 9.
314 globalkeys = awful.util.table.join(globalkeys,
316 awful.key({ modkey }, "#" .. i + 9,
318 local screen = mouse.screen
319 local tag = awful.tag.gettags(screen)[i]
321 awful.tag.viewonly(tag)
325 awful.key({ modkey, "Control" }, "#" .. i + 9,
327 local screen = mouse.screen
328 local tag = awful.tag.gettags(screen)[i]
330 awful.tag.viewtoggle(tag)
333 -- Move client to tag.
334 awful.key({ modkey, "Shift" }, "#" .. i + 9,
337 local tag = awful.tag.gettags(client.focus.screen)[i]
339 awful.client.movetotag(tag)
344 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
347 local tag = awful.tag.gettags(client.focus.screen)[i]
349 awful.client.toggletag(tag)
355 clientbuttons = awful.util.table.join(
356 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
357 awful.button({ modkey }, 1, awful.mouse.client.move),
358 awful.button({ modkey }, 3, awful.mouse.client.resize))
361 root.keys(globalkeys)
365 -- Rules to apply to new clients (through the "manage" signal).
366 awful.rules.rules = {
367 -- All clients will match this rule.
369 properties = { border_width = beautiful.border_width,
370 border_color = beautiful.border_normal,
371 focus = awful.client.focus.filter,
374 buttons = clientbuttons } },
375 { rule = { class = "MPlayer" },
376 properties = { floating = true } },
377 { rule = { class = "pinentry" },
378 properties = { floating = true } },
379 { rule = { class = "gimp" },
380 properties = { floating = true } },
381 -- Set Firefox to always map on tags number 2 of screen 1.
382 -- { rule = { class = "Firefox" },
383 -- properties = { tag = tags[1][2] } },
388 -- Signal function to execute when a new client appears.
389 client.connect_signal("manage", function (c, startup)
390 -- Enable sloppy focus
391 c:connect_signal("mouse::enter", function(c)
392 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
393 and awful.client.focus.filter(c) then
399 -- Set the windows at the slave,
400 -- i.e. put it at the end of others instead of setting it master.
401 -- awful.client.setslave(c)
403 -- Put windows in a smart way, only if they does not set an initial position.
404 if not c.size_hints.user_position and not c.size_hints.program_position then
405 awful.placement.no_overlap(c)
406 awful.placement.no_offscreen(c)
408 elseif not c.size_hints.user_position and not c.size_hints.program_position then
409 -- Prevent clients from being unreachable after screen count change
410 awful.placement.no_offscreen(c)
413 local titlebars_enabled = false
414 if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
415 -- buttons for the titlebar
416 local buttons = awful.util.table.join(
417 awful.button({ }, 1, function()
420 awful.mouse.client.move(c)
422 awful.button({ }, 3, function()
425 awful.mouse.client.resize(c)
429 -- Widgets that are aligned to the left
430 local left_layout = wibox.layout.fixed.horizontal()
431 left_layout:add(awful.titlebar.widget.iconwidget(c))
432 left_layout:buttons(buttons)
434 -- Widgets that are aligned to the right
435 local right_layout = wibox.layout.fixed.horizontal()
436 right_layout:add(awful.titlebar.widget.floatingbutton(c))
437 right_layout:add(awful.titlebar.widget.maximizedbutton(c))
438 right_layout:add(awful.titlebar.widget.stickybutton(c))
439 right_layout:add(awful.titlebar.widget.ontopbutton(c))
440 right_layout:add(awful.titlebar.widget.closebutton(c))
442 -- The title goes in the middle
443 local middle_layout = wibox.layout.flex.horizontal()
444 local title = awful.titlebar.widget.titlewidget(c)
445 title:set_align("center")
446 middle_layout:add(title)
447 middle_layout:buttons(buttons)
449 -- Now bring it all together
450 local layout = wibox.layout.align.horizontal()
451 layout:set_left(left_layout)
452 layout:set_right(right_layout)
453 layout:set_middle(middle_layout)
455 awful.titlebar(c):set_widget(layout)
459 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
460 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)