]> 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:

Disable client minimising with mouse click
[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                                                   -- I don't like click-minimising
179                                                   -- c.minimized = true
180                                               else
181                                                   -- Without this, the following
182                                                   -- :isvisible() makes no sense
183                                                   c.minimized = false
184                                                   if not c:isvisible() and c.first_tag then
185                                                       c.first_tag:view_only()
186                                                   end
187                                                   -- This will also un-minimize
188                                                   -- the client, if needed
189                                                   client.focus = c
190                                                   c:raise()
191                                               end
192                                           end),
193                      awful.button({ }, 3, client_menu_toggle_fn()),
194                      awful.button({ }, 4, function ()
195                                               awful.client.focus.byidx(1)
196                                           end),
197                      awful.button({ }, 5, function ()
198                                               awful.client.focus.byidx(-1)
199                                           end))
200 -- }}}
201
202 -- {{{ Tags
203 tags = {}
204 tags.config = {}
205 tags.config["main"] = {
206     t1 = { layout = layout_default, selected = true },
207     t2 = { layout = layout_default },
208     t3 = { layout = layout_tiled },
209     t4 = { layout = layout_tiled },
210     t5 = { layout = layout_tiled },
211     t6 = { layout = layout_floating },
212     t7 = { layout = layout_maximised },
213     t8 = { layout = layout_maximised },
214     t9 = { layout = layout_maximised },
215 }
216 tags.config["aux"] = {
217     t1 = { layout = layout_default, selected = true },
218     t2 = { layout = layout_default },
219     t3 = { layout = layout_tiled },
220     t4 = { layout = layout_floating },
221     t5 = { layout = layout_floating },
222     t6 = { layout = layout_floating },
223     t7 = { layout = layout_floating },
224     t8 = { layout = layout_floating },
225     t9 = { layout = layout_maximised },
226 }
227
228 screentags = {}
229 screentags[1] = tags.config["main"]
230 if screen.count() == 2 then -- aux screen is on the right
231   screentags[2] = tags.config["aux"]
232 elseif screen.count() == 3 then -- main screen is still #1 in the middle
233   screentags[2] = tags.config["aux"]
234   screentags[3] = tags.config["aux"]
235 end
236
237 awful.screen.connect_for_each_screen(function(s)
238     -- Wallpaper
239     --DISABLED--if beautiful.wallpaper then
240     --DISABLED--    local wallpaper = beautiful.wallpaper
241     --DISABLED--    -- If wallpaper is a function, call it with the screen
242     --DISABLED--    if type(wallpaper) == "function" then
243     --DISABLED--        wallpaper = wallpaper(s)
244     --DISABLED--    end
245     --DISABLED--    gears.wallpaper.maximized(wallpaper, s, true)
246     --DISABLED--end
247
248     if not tags[s.index] then
249         tags[s.index] = {}
250     end
251     for n,p in sorted_pairs(screentags[s.index]) do
252         p["screen"] = s
253         n = string.sub(n, 2) -- remove leading 't' needed for syntax in table
254         table.insert(tags[s.index], awful.tag.add(n, p))
255     end
256
257     -- Create a promptbox for each screen
258     mypromptbox[s] = awful.widget.prompt()
259     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
260     -- We need one layoutbox per screen.
261     mylayoutbox[s] = awful.widget.layoutbox(s)
262     mylayoutbox[s]:buttons(awful.util.table.join(
263                            awful.button({ }, 1, function () awful.layout.inc( 1) end),
264                            awful.button({ }, 3, function () awful.layout.inc(-1) end),
265                            awful.button({ }, 4, function () awful.layout.inc( 1) end),
266                            awful.button({ }, 5, function () awful.layout.inc(-1) end)))
267     -- Create a taglist widget
268     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
269
270     -- Create a tasklist widget
271     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
272
273     -- Create the wibox
274     mywibox[s] = awful.wibar({ position = "top", screen = s })
275
276     -- Add widgets to the wibox
277     mywibox[s]:setup {
278         layout = wibox.layout.align.horizontal,
279         { -- Left widgets
280             layout = wibox.layout.fixed.horizontal,
281             -- mylauncher,
282             mytaglist[s],
283             mypromptbox[s],
284         },
285         mytasklist[s], -- Middle widget
286         { -- Right widgets
287             layout = wibox.layout.fixed.horizontal,
288             mykeyboardlayout,
289             wibox.widget.systray(),
290             mytextclock,
291             mylayoutbox[s],
292         },
293     }
294 end)
295 -- }}}
296
297 -- {{{ Mouse bindings
298 root.buttons(awful.util.table.join(
299     awful.button({ }, 3, function () mymainmenu:toggle() end),
300     awful.button({ }, 4, awful.tag.viewnext),
301     awful.button({ }, 5, awful.tag.viewprev)
302 ))
303 -- }}}
304
305 -- {{{ Key bindings
306 globalkeys = awful.util.table.join(
307     awful.key({ modkey,           }, "s",      hotkeys_popup.show_help,
308               {description="show help", group="awesome"}),
309     awful.key({ modkey,           }, "Left",   awful.tag.viewprev,
310               {description = "view previous", group = "tag"}),
311     awful.key({ modkey,           }, "Right",  awful.tag.viewnext,
312               {description = "view next", group = "tag"}),
313     awful.key({ modkey,           }, "Escape", awful.tag.history.restore,
314               {description = "go back", group = "tag"}),
315
316     awful.key({ modkey,           }, "k",
317         function ()
318             awful.client.focus.byidx( 1)
319         end,
320         {description = "focus next by index", group = "client"}
321     ),
322     awful.key({ modkey,           }, "j",
323         function ()
324             awful.client.focus.byidx(-1)
325         end,
326         {description = "focus previous by index", group = "client"}
327     ),
328     awful.key({ modkey,           }, "w", function () mymainmenu:show() end,
329               {description = "show main menu", group = "awesome"}),
330
331     -- Layout manipulation
332     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx(  1)    end,
333               {description = "swap with next client by index", group = "client"}),
334     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx( -1)    end,
335               {description = "swap with previous client by index", group = "client"}),
336     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative( 1) end,
337               {description = "focus the next screen", group = "screen"}),
338     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative(-1) end,
339               {description = "focus the previous screen", group = "screen"}),
340     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto,
341               {description = "jump to urgent client", group = "client"}),
342     awful.key({ modkey,           }, "Tab",
343         function ()
344             awful.client.focus.history.previous()
345             if client.focus then
346                 client.focus:raise()
347             end
348         end,
349         {description = "go back", group = "client"}),
350
351     -- Standard program
352     awful.key({ modkey,           }, "Return", function () awful.spawn(terminal) end,
353               {description = "open a terminal", group = "launcher"}),
354     awful.key({ modkey, "Control" }, "r", awesome.restart,
355               {description = "reload awesome", group = "awesome"}),
356     awful.key({ modkey, "Shift"   }, "q", awesome.quit,
357               {description = "quit awesome", group = "awesome"}),
358
359     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)          end,
360               {description = "increase master width factor", group = "layout"}),
361     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)          end,
362               {description = "decrease master width factor", group = "layout"}),
363     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1, nil, true) end,
364               {description = "increase the number of master clients", group = "layout"}),
365     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1, nil, true) end,
366               {description = "decrease the number of master clients", group = "layout"}),
367     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1, nil, true)    end,
368               {description = "increase the number of columns", group = "layout"}),
369     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1, nil, true)    end,
370               {description = "decrease the number of columns", group = "layout"}),
371     awful.key({ modkey,           }, "space", function () awful.layout.inc( 1)                end,
372               {description = "select next", group = "layout"}),
373     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(-1)                end,
374               {description = "select previous", group = "layout"}),
375
376     awful.key({ modkey, "Control" }, "n",
377               function ()
378                   local c = awful.client.restore()
379                   -- Focus restored client
380                   if c then
381                       client.focus = c
382                       c:raise()
383                   end
384               end,
385               {description = "restore minimized", group = "client"}),
386
387     -- Prompt
388     awful.key({ modkey },            "r",     function () mypromptbox[awful.screen.focused()]:run() end,
389               {description = "run prompt", group = "launcher"}),
390
391     awful.key({ modkey }, "x",
392               function ()
393                   awful.prompt.run({ prompt = "Run Lua code: " },
394                   mypromptbox[awful.screen.focused()].widget,
395                   awful.util.eval, nil,
396                   awful.util.get_cache_dir() .. "/history_eval")
397               end,
398               {description = "lua execute prompt", group = "awesome"}),
399     -- Menubar
400     awful.key({ modkey }, "p", function() menubar.show() end,
401               {description = "show the menubar", group = "launcher"})
402 )
403
404 clientkeys = awful.util.table.join(
405     awful.key({ modkey,           }, "f",
406         function (c)
407             c.fullscreen = not c.fullscreen
408             c:raise()
409         end,
410         {description = "toggle fullscreen", group = "client"}),
411     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end,
412               {description = "close", group = "client"}),
413     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ,
414               {description = "toggle floating", group = "client"}),
415     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
416               {description = "move to master", group = "client"}),
417     awful.key({ modkey,           }, "o",      function (c) c:move_to_screen()               end,
418               {description = "move to screen", group = "client"}),
419     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end,
420               {description = "toggle keep on top", group = "client"}),
421     awful.key({ modkey,           }, "n",
422         function (c)
423             -- The client currently has the input focus, so it cannot be
424             -- minimized, since minimized clients can't have the focus.
425             c.minimized = true
426         end ,
427         {description = "minimize", group = "client"}),
428     awful.key({ modkey,           }, "m",
429         function (c)
430             c.maximized = not c.maximized
431             c:raise()
432         end ,
433         {description = "maximize", group = "client"})
434 )
435
436 -- Bind all key numbers to tags.
437 -- Be careful: we use keycodes to make it works on any keyboard layout.
438 -- This should map on the top row of your keyboard, usually 1 to 9.
439 for i = 1, 9 do
440     globalkeys = awful.util.table.join(globalkeys,
441         -- View tag only.
442         awful.key({ modkey }, "#" .. i + 9,
443                   function ()
444                         local screen = awful.screen.focused()
445                         local tag = screen.tags[i]
446                         if tag then
447                            tag:view_only()
448                         end
449                   end,
450                   {description = "view tag #"..i, group = "tag"}),
451         -- Toggle tag.
452         awful.key({ modkey, "Control" }, "#" .. i + 9,
453                   function ()
454                       local screen = awful.screen.focused()
455                       local tag = screen.tags[i]
456                       if tag then
457                          awful.tag.viewtoggle(tag)
458                       end
459                   end,
460                   {description = "toggle tag #" .. i, group = "tag"}),
461         -- Move client to tag.
462         awful.key({ modkey, "Shift" }, "#" .. i + 9,
463                   function ()
464                       if client.focus then
465                           local tag = client.focus.screen.tags[i]
466                           if tag then
467                               client.focus:move_to_tag(tag)
468                           end
469                      end
470                   end,
471                   {description = "move focused client to tag #"..i, group = "tag"}),
472         -- Toggle tag on focused client.
473         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
474                   function ()
475                       if client.focus then
476                           local tag = client.focus.screen.tags[i]
477                           if tag then
478                               client.focus:toggle_tag(tag)
479                           end
480                       end
481                   end,
482                   {description = "toggle focused client on tag #" .. i, group = "tag"})
483     )
484 end
485
486 clientbuttons = awful.util.table.join(
487     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
488     awful.button({ modkey }, 1, awful.mouse.client.move),
489     awful.button({ modkey }, 3, awful.mouse.client.resize))
490
491 -- misc apps
492 globalkeys = awful.util.table.join(globalkeys,
493 awful.key({ cmdkey }, "n", function () awful.spawn("firefox") end),
494 awful.key({ cmdkey }, "m", function () awful.spawn("chromium") end),
495 awful.key({ cmdkey }, "y", function () awful.spawn(terminal .. " -e python") end),
496 awful.key({ cmdkey }, "c", function () awful.spawn("icedove") end),
497 awful.key({ cmdkey }, "r", function () mypromptbox[mouse.screen]:run() end),
498 awful.key({ cmdkey }, "g", function () awful.spawn("gscan2pdf") end),
499 awful.key({ cmdkey }, "v", function () awful.spawn("virt-manager") end),
500 awful.key({ cmdkey }, "l", function () awful.spawn("libreoffice") end),
501 awful.key({ cmdkey }, "f", function () awful.spawn("thunar") end),
502 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),
503 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),
504 awful.key({ cmdkey, "Shift" }, "x", function () awful.spawn("xscreensaver-command -exit") end),
505
506 -- function keys
507 awful.key(nil, "XF86ScreenSaver", function () awful.spawn("xset dpms force off") end),
508 awful.key(nil, "XF86AudioMute", function () awful.spawn("pactl set-sink-mute 0 toggle") end),
509 awful.key({ cmdkey }, "End", function () awful.spawn("pactl set-sink-mute 0 toggle") end),
510 awful.key(nil, "XF86AudioLowerVolume", function () awful.spawn("pactl set-sink-volume 0 -2%") end),
511 awful.key({ cmdkey }, "Next", function () awful.spawn("pactl set-sink-volume 0 -2%") end),
512 awful.key(nil, "XF86AudioRaiseVolume", function () awful.spawn("pactl set-sink-volume 0 +2%") end),
513 awful.key({ cmdkey }, "Prior", function () awful.spawn("pactl set-sink-volume 0 +2%") end),
514 awful.key(nil, "XF86AudioMicMute", function () awful.spawn("pactl set-source-mute 1 toggle") end),
515 awful.key({ cmdkey }, "Home", function () awful.spawn("pactl set-source-mute 1 toggle") end),
516 awful.key(nil, "XF86MonBrightnessDown", function () awful.spawn("xbacklight -dec 5%") end),
517 awful.key(nil, "XF86MonBrightnessUp", function () awful.spawn("xbacklight -inc 5%") end),
518 awful.key(nil, "XF86Display", function () awful.spawn("") end),
519 awful.key(nil, "XF86WLAN", function () awful.spawn("") end),
520 awful.key(nil, "XF86Tools", function () awful.spawn("") end),
521 awful.key(nil, "XF86Search", function () awful.spawn("") end),
522 awful.key(nil, "XF86LaunchA", function () awful.spawn("") end),
523 awful.key(nil, "XF86Explorer", function () awful.spawn("") end)
524 )
525
526 -- Set keys
527 root.keys(globalkeys)
528 -- }}}
529
530 -- {{{ Rules
531 -- Rules to apply to new clients (through the "manage" signal).
532
533 local function move_to_tag(s, t)
534     return function(c)
535         c:move_to_tag(tags[s][t])
536     end
537 end
538
539 awful.rules.rules = {
540     -- All clients will match this rule.
541     { rule = { },
542       properties = { border_width = beautiful.border_width,
543                      border_color = beautiful.border_normal,
544                      focus = awful.client.focus.filter,
545                      raise = true,
546                      keys = clientkeys,
547                      buttons = clientbuttons,
548                      screen = awful.screen.preferred,
549                      placement = awful.placement.no_overlap+awful.placement.no_offscreen,
550                      floating = true
551                  },
552     },
553
554     -- Add titlebars to normal clients and dialogs
555     --DISABLED-- { rule_any = {type = { "normal", "dialog" }
556     --DISABLED--  }, properties = { titlebars_enabled = true }
557     --DISABLED-- },
558
559     { rule = { type = "dialog" },
560       properties = { placement = awful.placement.centered }},
561
562     { rule = { class = "URxvt" },
563                properties = {
564                    floating = false,
565                    size_hints_honor = false
566                } },
567     { rule = { class = "URxvt", instance = "irc" },
568                properties = {
569                    switchtotag = true
570                },
571                callback = move_to_tag(screen.count(), screen.count() == 1 and 2 or 1)
572            },
573     { rule = { class = "Firefox", instance = "Navigator" },
574                properties = {
575                    floating = false,
576                },
577                callback = move_to_tag(screen.count() == 1 and 1 or 2, 9)
578            },
579     { rule = { class = "Icedove", instance = "Mail" },
580                properties = {
581                    floating = false,
582                },
583                callback = move_to_tag(screen.count() == 1 and 1 or 2, 8)
584            },
585     { rule = { class = "chromium", instance = "chromium" },
586                properties = {
587                    floating = false,
588                },
589                callback = move_to_tag(screen.count() == 1 and 1 or 2, 9)
590            },
591     { rule = { class = "Gscan2pdf" },
592                callback = move_to_tag(1, 5)
593            },
594     { rule = { name = "gscan2pdf .*" },
595                properties = {
596                    floating = false,
597                },
598            },
599     { rule = { class = "Thunar", type = "normal" },
600                properties = {
601                    floating = false,
602                },
603            },
604 }
605 -- }}}
606
607 -- {{{ Signals
608 -- Signal function to execute when a new client appears.
609 client.connect_signal("manage", function (c)
610     -- Set the windows at the slave,
611     -- i.e. put it at the end of others instead of setting it master.
612     -- if not awesome.startup then awful.client.setslave(c) end
613
614     if awesome.startup and
615       not c.size_hints.user_position
616       and not c.size_hints.program_position then
617         -- Prevent clients from being unreachable after screen count changes.
618         awful.placement.no_offscreen(c)
619     end
620 end)
621
622 -- Add a titlebar if titlebars_enabled is set to true in the rules.
623 client.connect_signal("request::titlebars", function(c)
624     -- buttons for the titlebar
625     local buttons = awful.util.table.join(
626         awful.button({ }, 1, function()
627             client.focus = c
628             c:raise()
629             awful.mouse.client.move(c)
630         end),
631         awful.button({ }, 3, function()
632             client.focus = c
633             c:raise()
634             awful.mouse.client.resize(c)
635         end)
636     )
637
638     awful.titlebar(c) : setup {
639         { -- Left
640             awful.titlebar.widget.iconwidget(c),
641             buttons = buttons,
642             layout  = wibox.layout.fixed.horizontal
643         },
644         { -- Middle
645             { -- Title
646                 align  = "center",
647                 widget = awful.titlebar.widget.titlewidget(c)
648             },
649             buttons = buttons,
650             layout  = wibox.layout.flex.horizontal
651         },
652         { -- Right
653             awful.titlebar.widget.floatingbutton (c),
654             awful.titlebar.widget.maximizedbutton(c),
655             awful.titlebar.widget.stickybutton   (c),
656             awful.titlebar.widget.ontopbutton    (c),
657             awful.titlebar.widget.closebutton    (c),
658             layout = wibox.layout.fixed.horizontal()
659         },
660         layout = wibox.layout.align.horizontal
661     }
662 end)
663
664 -- Enable sloppy focus
665 client.connect_signal("mouse::enter", function(c)
666     if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
667         and awful.client.focus.filter(c) then
668         client.focus = c
669     end
670 end)
671
672 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
673 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
674
675 awful.ewmh.add_activate_filter(function(c) if c.class == "Firefox" then return false end end)
676
677 -- vim:ft=lua:sw=4:sts=4:ts=4:et