]> git.madduck.net Git - etc/awesome.git/blob - .config/awesome/rc.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

b2b49c337be12b159f540d439fc12d10211249f5
[etc/awesome.git] / .config / awesome / rc.lua
1 -- {{{ Imports
2 -- Standard awesome library
3 local gears = require("gears")
4 local awful = require("awful")
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 hotkeys_popup = require("awful.hotkeys_popup").widget
14 -- }}}
15
16 -- {{{ Error handling
17 -- Check if awesome encountered an error during startup and fell back to
18 -- another config (This code will only ever execute for the fallback config)
19 if awesome.startup_errors then
20     naughty.notify({ preset = naughty.config.presets.critical,
21                      title = "Oops, there were errors during startup!",
22                      text = awesome.startup_errors })
23 end
24
25 -- Handle runtime errors after startup
26 do
27     local in_error = false
28     awesome.connect_signal("debug::error", function (err)
29         -- Make sure we don't go into an endless error loop
30         if in_error then return end
31         in_error = true
32
33         naughty.notify({ preset = naughty.config.presets.critical,
34                          title = "Oops, an error happened!",
35                          text = tostring(err) })
36         in_error = false
37     end)
38 end
39 -- }}}
40
41 -- {{{ Variable definitions
42 -- Themes define colours, icons, and wallpapers
43 beautiful.init(awful.util.get_themes_dir() .. "default/theme.lua")
44
45 -- This is used later as the default terminal and editor to run.
46 terminal = "x-terminal-emulator"
47 editor = "sensible-editor"
48 editor_cmd = terminal .. " -e " .. editor
49
50 -- Default modkey.
51 -- Usually, Mod4 is the key with a logo between Control and Alt.
52 -- If you do not like this or do not have such a key,
53 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
54 -- However, you can use another modifier like Mod1, but it may interact with others.
55 modkey = "Mod4"
56 cmdkey = "Mod3"
57
58 -- Table of layouts to cover with awful.layout.inc, order matters.
59 awful.layout.layouts = {
60     awful.layout.suit.fair,
61     awful.layout.suit.tile,
62     -- awful.layout.suit.tile.left,
63     -- awful.layout.suit.tile.bottom,
64     awful.layout.suit.tile.top,
65     -- awful.layout.suit.spiral,
66     -- awful.layout.suit.spiral.dwindle,
67     awful.layout.suit.max,
68     -- awful.layout.suit.max.fullscreen,
69     -- awful.layout.suit.magnifier,
70     -- awful.layout.suit.corner.nw,
71     -- awful.layout.suit.corner.ne,
72     -- awful.layout.suit.corner.sw,
73     -- awful.layout.suit.corner.se,
74     awful.layout.suit.floating,
75 }
76
77 layout_default = awful.layout.layouts[1]
78 layout_tiled = awful.layout.layouts[2]
79 layout_maximised = awful.layout.layouts[4]
80 layout_floating = awful.layout.layouts[5]
81 -- }}}
82
83 -- {{{ Helper functions
84 local function client_menu_toggle_fn()
85     local instance = nil
86
87     return function ()
88         if instance and instance.wibox.visible then
89             instance:hide()
90             instance = nil
91         else
92             instance = awful.menu.clients({ theme = { width = 250 } })
93         end
94     end
95 end
96
97 local function sorted_pairs(t, f)
98     local a = {}
99     for n in pairs(t) do table.insert(a, n) end
100     table.sort(a, f)
101     local i = 0      -- iterator variable
102     local iter = function ()   -- iterator function
103         i = i + 1
104         if a[i] == nil then return nil
105         else return a[i], t[a[i]]
106         end
107     end
108     return iter
109 end
110
111 local function print_table(tbl, indent)
112     if not indent then indent = 0 end
113     for k, v in pairs(tbl) do
114         formatting = string.rep("  ", indent) .. k .. ": "
115         if type(v) == "table" then
116             print(formatting)
117             print_table(v, indent+1)
118         else
119             print(formatting .. tostring(v))
120         end
121     end
122 end
123 -- }}}
124
125 -- {{{ Menu
126 -- Create a launcher widget and a main menu
127 myawesomemenu = {
128    { "hotkeys", function() return false, hotkeys_popup.show_help end},
129    { "manual", terminal .. " -e man awesome" },
130    { "edit config", editor_cmd .. " " .. awesome.conffile },
131    { "restart", awesome.restart },
132    { "quit", awesome.quit }
133 }
134
135 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
136                                     { "open terminal", terminal }
137                                   }
138                         })
139
140 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
141                                      menu = mymainmenu })
142 -- }}}
143
144 -- {{{ Menubar configuration
145 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
146 -- }}}
147
148 -- {{{ Wibox
149 -- Create a textclock widget
150 mytextclock = wibox.widget.textclock("%a %d %b %H:%M:%S", 1)
151
152 -- Create a wibox for each screen and add it
153 mywibox = {}
154 mypromptbox = {}
155 mylayoutbox = {}
156 mytaglist = {}
157 mytaglist.buttons = awful.util.table.join(
158                     awful.button({ }, 1, function(t) t:view_only() end),
159                     awful.button({ modkey }, 1, function(t)
160                                               if client.focus then
161                                                   client.focus:move_to_tag(t)
162                                               end
163                                           end),
164                     awful.button({ }, 3, awful.tag.viewtoggle),
165                     awful.button({ modkey }, 3, function(t)
166                                               if client.focus then
167                                                   client.focus:toggle_tag(t)
168                                               end
169                                           end),
170                     awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
171                     awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
172                 )
173
174 mytasklist = {}
175 mytasklist.buttons = awful.util.table.join(
176                      awful.button({ }, 1, function (c)
177                                               if c == client.focus then
178                                                   c.minimized = true
179                                               else
180                                                   -- Without this, the following
181                                                   -- :isvisible() makes no sense
182                                                   c.minimized = false
183                                                   if not c:isvisible() and c.first_tag then
184                                                       c.first_tag:view_only()
185                                                   end
186                                                   -- This will also un-minimize
187                                                   -- the client, if needed
188                                                   client.focus = c
189                                                   c:raise()
190                                               end
191                                           end),
192                      awful.button({ }, 3, client_menu_toggle_fn()),
193                      awful.button({ }, 4, function ()
194                                               awful.client.focus.byidx(1)
195                                           end),
196                      awful.button({ }, 5, function ()
197                                               awful.client.focus.byidx(-1)
198                                           end))
199 -- }}}
200
201 -- {{{ Tags
202 tags = {}
203 tags.config = {}
204 tags.config["main"] = {
205     t1 = { layout = layout_default, selected = true },
206     t2 = { layout = layout_default },
207     t3 = { layout = layout_tiled },
208     t4 = { layout = layout_tiled },
209     t5 = { layout = layout_tiled },
210     t6 = { layout = layout_floating },
211     t7 = { layout = layout_maximised },
212     t8 = { layout = layout_maximised },
213     t9 = { layout = layout_maximised },
214 }
215 tags.config["aux"] = {
216     t1 = { layout = layout_default, selected = true },
217     t2 = { layout = layout_default },
218     t3 = { layout = layout_tiled },
219     t4 = { layout = layout_floating },
220     t5 = { layout = layout_floating },
221     t6 = { layout = layout_floating },
222     t7 = { layout = layout_floating },
223     t8 = { layout = layout_floating },
224     t9 = { layout = layout_maximised },
225 }
226
227 screentags = {}
228 screentags[1] = tags.config["main"]
229 if screen.count() == 2 then -- aux screen is on the right
230   screentags[2] = tags.config["aux"]
231 elseif screen.count() == 3 then -- main screen is still #1 in the middle
232   screentags[2] = tags.config["aux"]
233   screentags[3] = tags.config["aux"]
234 end
235
236 awful.screen.connect_for_each_screen(function(s)
237     -- Wallpaper
238     --DISABLED--if beautiful.wallpaper then
239     --DISABLED--    local wallpaper = beautiful.wallpaper
240     --DISABLED--    -- If wallpaper is a function, call it with the screen
241     --DISABLED--    if type(wallpaper) == "function" then
242     --DISABLED--        wallpaper = wallpaper(s)
243     --DISABLED--    end
244     --DISABLED--    gears.wallpaper.maximized(wallpaper, s, true)
245     --DISABLED--end
246
247     if not tags[s.index] then
248         tags[s.index] = {}
249     end
250     for n,p in sorted_pairs(screentags[s.index]) do
251         p["screen"] = s
252         n = string.sub(n, 2) -- remove leading 't' needed for syntax in table
253         table.insert(tags[s.index], awful.tag.add(n, p))
254     end
255
256     -- Create a promptbox for each screen
257     mypromptbox[s] = awful.widget.prompt()
258     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
259     -- We need one layoutbox per screen.
260     mylayoutbox[s] = awful.widget.layoutbox(s)
261     mylayoutbox[s]:buttons(awful.util.table.join(
262                            awful.button({ }, 1, function () awful.layout.inc( 1) end),
263                            awful.button({ }, 3, function () awful.layout.inc(-1) end),
264                            awful.button({ }, 4, function () awful.layout.inc( 1) end),
265                            awful.button({ }, 5, function () awful.layout.inc(-1) end)))
266     -- Create a taglist widget
267     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
268
269     -- Create a tasklist widget
270     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
271
272     -- Create the wibox
273     mywibox[s] = awful.wibar({ position = "top", screen = s })
274
275     -- Add widgets to the wibox
276     mywibox[s]:setup {
277         layout = wibox.layout.align.horizontal,
278         { -- Left widgets
279             layout = wibox.layout.fixed.horizontal,
280             -- mylauncher,
281             mytaglist[s],
282             mypromptbox[s],
283         },
284         mytasklist[s], -- Middle widget
285         { -- Right widgets
286             layout = wibox.layout.fixed.horizontal,
287             mykeyboardlayout,
288             wibox.widget.systray(),
289             mytextclock,
290             mylayoutbox[s],
291         },
292     }
293 end)
294 -- }}}
295
296 -- {{{ Mouse bindings
297 root.buttons(awful.util.table.join(
298     awful.button({ }, 3, function () mymainmenu:toggle() end),
299     awful.button({ }, 4, awful.tag.viewnext),
300     awful.button({ }, 5, awful.tag.viewprev)
301 ))
302 -- }}}
303
304 -- {{{ Key bindings
305 globalkeys = awful.util.table.join(
306     awful.key({ modkey,           }, "s",      hotkeys_popup.show_help,
307               {description="show help", group="awesome"}),
308     awful.key({ modkey,           }, "Left",   awful.tag.viewprev,
309               {description = "view previous", group = "tag"}),
310     awful.key({ modkey,           }, "Right",  awful.tag.viewnext,
311               {description = "view next", group = "tag"}),
312     awful.key({ modkey,           }, "Escape", awful.tag.history.restore,
313               {description = "go back", group = "tag"}),
314
315     awful.key({ modkey,           }, "k",
316         function ()
317             awful.client.focus.byidx( 1)
318         end,
319         {description = "focus next by index", group = "client"}
320     ),
321     awful.key({ modkey,           }, "j",
322         function ()
323             awful.client.focus.byidx(-1)
324         end,
325         {description = "focus previous by index", group = "client"}
326     ),
327     awful.key({ modkey,           }, "w", function () mymainmenu:show() end,
328               {description = "show main menu", group = "awesome"}),
329
330     -- Layout manipulation
331     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx(  1)    end,
332               {description = "swap with next client by index", group = "client"}),
333     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx( -1)    end,
334               {description = "swap with previous client by index", group = "client"}),
335     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative( 1) end,
336               {description = "focus the next screen", group = "screen"}),
337     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative(-1) end,
338               {description = "focus the previous screen", group = "screen"}),
339     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto,
340               {description = "jump to urgent client", group = "client"}),
341     awful.key({ modkey,           }, "Tab",
342         function ()
343             awful.client.focus.history.previous()
344             if client.focus then
345                 client.focus:raise()
346             end
347         end,
348         {description = "go back", group = "client"}),
349
350     -- Standard program
351     awful.key({ modkey,           }, "Return", function () awful.spawn(terminal) end,
352               {description = "open a terminal", group = "launcher"}),
353     awful.key({ modkey, "Control" }, "r", awesome.restart,
354               {description = "reload awesome", group = "awesome"}),
355     awful.key({ modkey, "Shift"   }, "q", awesome.quit,
356               {description = "quit awesome", group = "awesome"}),
357
358     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)          end,
359               {description = "increase master width factor", group = "layout"}),
360     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)          end,
361               {description = "decrease master width factor", group = "layout"}),
362     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1, nil, true) end,
363               {description = "increase the number of master clients", group = "layout"}),
364     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1, nil, true) end,
365               {description = "decrease the number of master clients", group = "layout"}),
366     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1, nil, true)    end,
367               {description = "increase the number of columns", group = "layout"}),
368     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1, nil, true)    end,
369               {description = "decrease the number of columns", group = "layout"}),
370     awful.key({ modkey,           }, "space", function () awful.layout.inc( 1)                end,
371               {description = "select next", group = "layout"}),
372     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(-1)                end,
373               {description = "select previous", group = "layout"}),
374
375     awful.key({ modkey, "Control" }, "n",
376               function ()
377                   local c = awful.client.restore()
378                   -- Focus restored client
379                   if c then
380                       client.focus = c
381                       c:raise()
382                   end
383               end,
384               {description = "restore minimized", group = "client"}),
385
386     -- Prompt
387     awful.key({ modkey },            "r",     function () mypromptbox[awful.screen.focused()]:run() end,
388               {description = "run prompt", group = "launcher"}),
389
390     awful.key({ modkey }, "x",
391               function ()
392                   awful.prompt.run({ prompt = "Run Lua code: " },
393                   mypromptbox[awful.screen.focused()].widget,
394                   awful.util.eval, nil,
395                   awful.util.get_cache_dir() .. "/history_eval")
396               end,
397               {description = "lua execute prompt", group = "awesome"}),
398     -- Menubar
399     awful.key({ modkey }, "p", function() menubar.show() end,
400               {description = "show the menubar", group = "launcher"})
401 )
402
403 clientkeys = awful.util.table.join(
404     awful.key({ modkey,           }, "f",
405         function (c)
406             c.fullscreen = not c.fullscreen
407             c:raise()
408         end,
409         {description = "toggle fullscreen", group = "client"}),
410     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end,
411               {description = "close", group = "client"}),
412     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ,
413               {description = "toggle floating", group = "client"}),
414     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
415               {description = "move to master", group = "client"}),
416     awful.key({ modkey,           }, "o",      function (c) c:move_to_screen()               end,
417               {description = "move to screen", group = "client"}),
418     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end,
419               {description = "toggle keep on top", group = "client"}),
420     awful.key({ modkey,           }, "n",
421         function (c)
422             -- The client currently has the input focus, so it cannot be
423             -- minimized, since minimized clients can't have the focus.
424             c.minimized = true
425         end ,
426         {description = "minimize", group = "client"}),
427     awful.key({ modkey,           }, "m",
428         function (c)
429             c.maximized = not c.maximized
430             c:raise()
431         end ,
432         {description = "maximize", group = "client"})
433 )
434
435 -- Bind all key numbers to tags.
436 -- Be careful: we use keycodes to make it works on any keyboard layout.
437 -- This should map on the top row of your keyboard, usually 1 to 9.
438 for i = 1, 9 do
439     globalkeys = awful.util.table.join(globalkeys,
440         -- View tag only.
441         awful.key({ modkey }, "#" .. i + 9,
442                   function ()
443                         local screen = awful.screen.focused()
444                         local tag = screen.tags[i]
445                         if tag then
446                            tag:view_only()
447                         end
448                   end,
449                   {description = "view tag #"..i, group = "tag"}),
450         -- Toggle tag.
451         awful.key({ modkey, "Control" }, "#" .. i + 9,
452                   function ()
453                       local screen = awful.screen.focused()
454                       local tag = screen.tags[i]
455                       if tag then
456                          awful.tag.viewtoggle(tag)
457                       end
458                   end,
459                   {description = "toggle tag #" .. i, group = "tag"}),
460         -- Move client to tag.
461         awful.key({ modkey, "Shift" }, "#" .. i + 9,
462                   function ()
463                       if client.focus then
464                           local tag = client.focus.screen.tags[i]
465                           if tag then
466                               client.focus:move_to_tag(tag)
467                           end
468                      end
469                   end,
470                   {description = "move focused client to tag #"..i, group = "tag"}),
471         -- Toggle tag on focused client.
472         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
473                   function ()
474                       if client.focus then
475                           local tag = client.focus.screen.tags[i]
476                           if tag then
477                               client.focus:toggle_tag(tag)
478                           end
479                       end
480                   end,
481                   {description = "toggle focused client on tag #" .. i, group = "tag"})
482     )
483 end
484
485 clientbuttons = awful.util.table.join(
486     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
487     awful.button({ modkey }, 1, awful.mouse.client.move),
488     awful.button({ modkey }, 3, awful.mouse.client.resize))
489
490 -- misc apps
491 globalkeys = awful.util.table.join(globalkeys,
492 awful.key({ cmdkey }, "n", function () awful.spawn("firefox") end),
493 awful.key({ cmdkey }, "m", function () awful.spawn("chromium") end),
494 awful.key({ cmdkey }, "y", function () awful.spawn(terminal .. " -e python") end),
495 awful.key({ cmdkey }, "c", function () awful.spawn("icedove") end),
496 awful.key({ cmdkey }, "r", function () mypromptbox[mouse.screen]:run() end),
497 awful.key({ cmdkey }, "g", function () awful.spawn("gscan2pdf") end),
498 awful.key({ cmdkey }, "v", function () awful.spawn("virt-manager") end),
499 awful.key({ cmdkey }, "l", function () awful.spawn("libreoffice") end),
500 awful.key({ cmdkey }, "i", function () awful.spawn(terminal .. " -title irc -name irc -e env MOSH_TITLE_NOPREFIX=true mosh -4 -- irc-host screen -dr irc") end),
501 awful.key({ cmdkey }, "x", function () awful.spawn.with_shell("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver -- -no-capture-stderr; sleep 2; xscreensaver-command -lock") end),
502 awful.key({ cmdkey, "Shift" }, "x", function () awful.spawn("xscreensaver-command -exit") end),
503
504 -- function keys
505 awful.key(nil, "XF86ScreenSaver", function () awful.spawn("xset dpms force off") end),
506 awful.key(nil, "XF86AudioMute", function () awful.spawn("pactl set-sink-mute 0 toggle") end),
507 awful.key(nil, "XF86AudioLowerVolume", function () awful.spawn("pactl set-sink-volume 0 -2%") end),
508 awful.key(nil, "XF86AudioRaiseVolume", function () awful.spawn("pactl set-sink-volume 0 +2%") end),
509 awful.key(nil, "XF86AudioMicMute", function () awful.spawn("pactl set-source-mute 1 toggle") end),
510 awful.key(nil, "XF86MonBrightnessDown", function () awful.spawn("xbacklight -dec 5%") end),
511 awful.key(nil, "XF86MonBrightnessUp", function () awful.spawn("xbacklight -inc 5%") end),
512 awful.key(nil, "XF86Display", function () awful.spawn("") end),
513 awful.key(nil, "XF86WLAN", function () awful.spawn("") end),
514 awful.key(nil, "XF86Tools", function () awful.spawn("") end),
515 awful.key(nil, "XF86Search", function () awful.spawn("") end),
516 awful.key(nil, "XF86LaunchA", function () awful.spawn("") end),
517 awful.key(nil, "XF86Explorer", function () awful.spawn("") end)
518 )
519
520 -- Set keys
521 root.keys(globalkeys)
522 -- }}}
523
524 -- {{{ Rules
525 -- Rules to apply to new clients (through the "manage" signal).
526
527 local function move_to_tag(s, t)
528     return function(c)
529         c:move_to_tag(tags[s][t])
530     end
531 end
532
533 awful.rules.rules = {
534     -- All clients will match this rule.
535     { rule = { },
536       properties = { border_width = beautiful.border_width,
537                      border_color = beautiful.border_normal,
538                      focus = awful.client.focus.filter,
539                      raise = true,
540                      keys = clientkeys,
541                      buttons = clientbuttons,
542                      screen = awful.screen.preferred,
543                      placement = awful.placement.no_overlap+awful.placement.no_offscreen,
544                      floating = true
545                  },
546     },
547
548     -- Add titlebars to normal clients and dialogs
549     --DISABLED-- { rule_any = {type = { "normal", "dialog" }
550     --DISABLED--  }, properties = { titlebars_enabled = true }
551     --DISABLED-- },
552
553     { rule = { type = "dialog" },
554       properties = { placement = awful.placement.centered }},
555
556     { rule = { class = "URxvt" },
557                properties = {
558                    floating = false,
559                    size_hints_honor = false
560                } },
561     { rule = { class = "URxvt", instance = "irc" },
562                properties = {
563                    switchtotag = true
564                },
565                callback = move_to_tag(screen.count(), screen.count() == 1 and 2 or 1)
566            },
567     { rule = { class = "Firefox", instance = "Navigator" },
568                properties = {
569                    floating = false,
570                },
571                callback = move_to_tag(screen.count() == 1 and 1 or 2, 9)
572            },
573     { rule = { class = "Icedove", instance = "Mail" },
574                properties = {
575                    floating = false,
576                },
577                callback = move_to_tag(screen.count() == 1 and 1 or 2, 8)
578            },
579     { rule = { class = "chromium", instance = "chromium" },
580                properties = {
581                    floating = false,
582                },
583                callback = move_to_tag(screen.count() == 1 and 1 or 2, 9)
584            },
585     { rule = { class = "Gscan2pdf" },
586                properties = {
587                    screen = 1,
588                    tag = "5"
589                },
590                callback = move_to_tag(1, 5)
591            },
592     { rule = { name = "gscan2pdf .*" },
593                properties = {
594                    floating = false,
595                },
596                callback = move_to_tag(1, 5)
597            },
598 }
599 -- }}}
600
601 -- {{{ Signals
602 -- Signal function to execute when a new client appears.
603 client.connect_signal("manage", function (c)
604     -- Set the windows at the slave,
605     -- i.e. put it at the end of others instead of setting it master.
606     -- if not awesome.startup then awful.client.setslave(c) end
607
608     if awesome.startup and
609       not c.size_hints.user_position
610       and not c.size_hints.program_position then
611         -- Prevent clients from being unreachable after screen count changes.
612         awful.placement.no_offscreen(c)
613     end
614 end)
615
616 -- Add a titlebar if titlebars_enabled is set to true in the rules.
617 client.connect_signal("request::titlebars", function(c)
618     -- buttons for the titlebar
619     local buttons = awful.util.table.join(
620         awful.button({ }, 1, function()
621             client.focus = c
622             c:raise()
623             awful.mouse.client.move(c)
624         end),
625         awful.button({ }, 3, function()
626             client.focus = c
627             c:raise()
628             awful.mouse.client.resize(c)
629         end)
630     )
631
632     awful.titlebar(c) : setup {
633         { -- Left
634             awful.titlebar.widget.iconwidget(c),
635             buttons = buttons,
636             layout  = wibox.layout.fixed.horizontal
637         },
638         { -- Middle
639             { -- Title
640                 align  = "center",
641                 widget = awful.titlebar.widget.titlewidget(c)
642             },
643             buttons = buttons,
644             layout  = wibox.layout.flex.horizontal
645         },
646         { -- Right
647             awful.titlebar.widget.floatingbutton (c),
648             awful.titlebar.widget.maximizedbutton(c),
649             awful.titlebar.widget.stickybutton   (c),
650             awful.titlebar.widget.ontopbutton    (c),
651             awful.titlebar.widget.closebutton    (c),
652             layout = wibox.layout.fixed.horizontal()
653         },
654         layout = wibox.layout.align.horizontal
655     }
656 end)
657
658 -- Enable sloppy focus
659 client.connect_signal("mouse::enter", function(c)
660     if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
661         and awful.client.focus.filter(c) then
662         client.focus = c
663     end
664 end)
665
666 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
667 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
668
669 awful.ewmh.add_activate_filter(function(c) if c.class == "Firefox" then return false end end)
670
671 -- vim:ft=lua:sw=4:sts=4:ts=4:et