Giant blob of minor changes
[dotfiles/.git] / .config / awesome / rc.lua
1 --[[
2
3      Awesome WM configuration template
4      github.com/lcpz
5
6 --]]
7
8 -- {{{ Required libraries
9 local awesome, client, mouse, screen, tag = awesome, client, mouse, screen, tag
10 local ipairs, string, os, table, tostring, tonumber, type = ipairs, string, os, table, tostring, tonumber, type
11
12 local screenshot    = require("screenshot")
13
14 local gears         = require("gears")
15 local awful         = require("awful")
16                       require("awful.autofocus")
17 local wibox         = require("wibox")
18 local beautiful     = require("beautiful")
19 local naughty       = require("naughty")
20 local lain          = require("lain")
21 --local menubar       = require("menubar")
22 local freedesktop   = require("freedesktop")
23 local hotkeys_popup = require("awful.hotkeys_popup").widget
24                       require("awful.hotkeys_popup.keys")
25 local my_table      = awful.util.table or gears.table -- 4.{0,1} compatibility
26 local dpi           = require("beautiful.xresources").apply_dpi
27 -- }}}
28
29 -- {{{ Error handling
30 -- Check if awesome encountered an error during startup and fell back to
31 -- another config (This code will only ever execute for the fallback config)
32 if awesome.startup_errors then
33     naughty.notify({ preset = naughty.config.presets.critical,
34                      title = "Oops, there were errors during startup!",
35                      text = awesome.startup_errors })
36 end
37
38 -- Handle runtime errors after startup
39 do
40     local in_error = false
41     awesome.connect_signal("debug::error", function (err)
42         if in_error then return end
43         in_error = true
44
45         naughty.notify({ preset = naughty.config.presets.critical,
46                          title = "Oops, an error happened!",
47                          text = tostring(err) })
48         in_error = false
49     end)
50 end
51 -- }}}
52
53 -- {{{ Autostart windowless processes
54
55 -- This function will run once every time Awesome is started
56 local function run_once(cmd_arr)
57     for _, cmd in ipairs(cmd_arr) do
58         awful.spawn.with_shell(string.format("pgrep -u $USER -fx '%s' > /dev/null || (%s)", cmd, cmd))
59     end
60 end
61
62 --run_once({ "urxvtd", "unclutter -root" }) -- entries must be separated by commas
63
64 -- This function implements the XDG autostart specification
65 --[[
66 awful.spawn.with_shell(
67     'if (xrdb -query | grep -q "^awesome\\.started:\\s*true$"); then exit; fi;' ..
68     'xrdb -merge <<< "awesome.started:true";' ..
69     -- list each of your autostart commands, followed by ; inside single quotes, followed by ..
70     'dex --environment Awesome --autostart --search-paths "$XDG_CONFIG_DIRS/autostart:$XDG_CONFIG_HOME/autostart"' -- https://github.com/jceb/dex
71 )
72 --]]
73
74 -- }}}
75
76 -- {{{ Variable definitions
77
78 local themes = {
79     "blackburn",       -- 1
80     "copland",         -- 2
81     "dremora",         -- 3
82     "holo",            -- 4
83     "multicolor",      -- 5
84     "powerarrow",      -- 6
85     "powerarrow-dark", -- 7
86     "rainbow",         -- 8
87     "steamburn",       -- 9
88     "vertex",          -- 10
89 }
90
91 local chosen_theme = themes[5]
92 local modkey       = "Mod4"
93 local altkey       = "Mod1"
94 local terminal     = "alacritty"
95 local vi_focus     = false -- vi-like client focus - https://github.com/lcpz/awesome-copycats/issues/275
96 local cycle_prev   = true -- cycle trough all previous client or just the first -- https://github.com/lcpz/awesome-copycats/issues/274
97 local editor       = os.getenv("EDITOR") or "nvim"
98 local gui_editor   = os.getenv("GUI_EDITOR") or "gvim"
99 local browser      = os.getenv("BROWSER") or "firefox"
100 local scrlocker    = "slock systemctl suspend" --This is in order to lock and suspend in one command
101
102 awful.util.terminal = terminal
103 awful.util.tagnames = { "1", "2", "3", "4", "5" }
104 awful.layout.layouts = {
105     awful.layout.suit.floating,
106     awful.layout.suit.tile,
107     awful.layout.suit.tile.left,
108     awful.layout.suit.tile.bottom,
109     awful.layout.suit.tile.top,
110     awful.layout.suit.fair,
111     --awful.layout.suit.fair.horizontal,
112     --awful.layout.suit.spiral,
113     --awful.layout.suit.spiral.dwindle,
114     --awful.layout.suit.max,
115     --awful.layout.suit.max.fullscreen,
116     awful.layout.suit.magnifier,
117     --awful.layout.suit.corner.nw,
118     --awful.layout.suit.corner.ne,
119     --awful.layout.suit.corner.sw,
120     --awful.layout.suit.corner.se,
121     --lain.layout.cascade,
122     --lain.layout.cascade.tile,
123     lain.layout.centerwork,
124     --lain.layout.centerwork.horizontal,
125     --lain.layout.termfair,
126     --lain.layout.termfair.center,
127 }
128
129 awful.util.taglist_buttons = my_table.join(
130     awful.button({ }, 1, function(t) t:view_only() end),
131     awful.button({ modkey }, 1, function(t)
132         if client.focus then
133             client.focus:move_to_tag(t)
134         end
135     end),
136     awful.button({ }, 3, awful.tag.viewtoggle),
137     awful.button({ modkey }, 3, function(t)
138         if client.focus then
139             client.focus:toggle_tag(t)
140         end
141     end),
142     awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
143     awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
144 )
145
146 awful.util.tasklist_buttons = my_table.join(
147     awful.button({ }, 1, function (c)
148         if c == client.focus then
149             c.minimized = true
150         else
151             --c:emit_signal("request::activate", "tasklist", {raise = true})<Paste>
152
153             -- Without this, the following
154             -- :isvisible() makes no sense
155             c.minimized = false
156             if not c:isvisible() and c.first_tag then
157                 c.first_tag:view_only()
158             end
159             -- This will also un-minimize
160             -- the client, if needed
161             client.focus = c
162             c:raise()
163         end
164     end),
165     awful.button({ }, 2, function (c) c:kill() end),
166     awful.button({ }, 3, function ()
167         local instance = nil
168
169         return function ()
170             if instance and instance.wibox.visible then
171                 instance:hide()
172                 instance = nil
173             else
174                 instance = awful.menu.clients({theme = {width = dpi(250)}})
175             end
176         end
177     end),
178     awful.button({ }, 4, function () awful.client.focus.byidx(1) end),
179     awful.button({ }, 5, function () awful.client.focus.byidx(-1) end)
180 )
181
182 lain.layout.termfair.nmaster           = 3
183 lain.layout.termfair.ncol              = 1
184 lain.layout.termfair.center.nmaster    = 3
185 lain.layout.termfair.center.ncol       = 1
186 lain.layout.cascade.tile.offset_x      = dpi(2)
187 lain.layout.cascade.tile.offset_y      = dpi(32)
188 lain.layout.cascade.tile.extra_padding = dpi(5)
189 lain.layout.cascade.tile.nmaster       = 5
190 lain.layout.cascade.tile.ncol          = 2
191
192 beautiful.init(string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), chosen_theme))
193 -- }}}
194
195 -- {{{ Menu
196 local myawesomemenu = {
197     { "hotkeys", function() return false, hotkeys_popup.show_help end },
198     { "manual", terminal .. " -e man awesome" },
199     { "edit config", string.format("%s -e %s %s", terminal, editor, awesome.conffile) },
200     { "restart", awesome.restart },
201     { "quit", function() awesome.quit() end }
202 }
203 awful.util.mymainmenu = freedesktop.menu.build({
204     icon_size = beautiful.menu_height or dpi(16),
205     before = {
206         { "Awesome", myawesomemenu, beautiful.awesome_icon },
207         -- other triads can be put here
208     },
209     after = {
210         { "Open terminal", terminal },
211         -- other triads can be put here
212     }
213 })
214 -- hide menu when mouse leaves it
215 --awful.util.mymainmenu.wibox:connect_signal("mouse::leave", function() awful.util.mymainmenu:hide() end)
216
217 --menubar.utils.terminal = terminal -- Set the Menubar terminal for applications that require it
218 -- }}}
219
220 -- {{{ Screen
221 -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
222 screen.connect_signal("property::geometry", function(s)
223     -- Wallpaper
224     if beautiful.wallpaper then
225         local wallpaper = beautiful.wallpaper
226         -- If wallpaper is a function, call it with the screen
227         if type(wallpaper) == "function" then
228             wallpaper = wallpaper(s)
229         end
230         gears.wallpaper.maximized(wallpaper, s, true)
231     end
232 end)
233
234 -- No borders when rearranging only 1 non-floating or maximized client
235 screen.connect_signal("arrange", function (s)
236     local only_one = #s.tiled_clients == 1
237     for _, c in pairs(s.clients) do
238         if only_one and not c.floating or c.maximized then
239             c.border_width = 0
240         else
241             c.border_width = beautiful.border_width
242         end
243     end
244 end)
245 -- Create a wibox for each screen and add it
246 awful.screen.connect_for_each_screen(function(s) beautiful.at_screen_connect(s) end)
247 -- }}}
248
249 -- {{{ Mouse bindings
250 root.buttons(my_table.join(
251     awful.button({ }, 3, function () awful.util.mymainmenu:toggle() end),
252     awful.button({ }, 4, awful.tag.viewnext),
253     awful.button({ }, 5, awful.tag.viewprev)
254 ))
255 -- }}}
256
257 -- {{{ Key bindings
258 globalkeys = my_table.join(
259     -- Take a screenshot
260     awful.key({ altkey }, "p",  scrot_full,
261               {description = "take a screenshot", group = "hotkeys"}),
262     awful.key({ }, "Print", scrot_full,
263               {description = "Take a screenshot of entire screen", group = "screenshot"}),
264     awful.key({ modkey, }, "Print", scrot_selection,
265               {description = "Take a screenshot of selection", group = "screenshot"}),
266     awful.key({ "Shift" }, "Print", scrot_window,
267               {description = "Take a screenshot of focused window", group = "screenshot"}),
268     awful.key({ "Ctrl" }, "Print", scrot_delay,
269             {description = "Take a screenshot of delay", group = "screenshot"}),
270     -- X screen locker
271     awful.key({ altkey, "Control" }, "l", function () os.execute(scrlocker) end,
272               {description = "lock screen", group = "hotkeys"}),
273
274     -- Hotkeys
275     awful.key({ modkey,           }, "s",      hotkeys_popup.show_help,
276               {description = "show help", group="awesome"}),
277     -- Tag browsing
278     awful.key({ modkey,           }, "Left",   awful.tag.viewprev,
279               {description = "view previous", group = "tag"}),
280     awful.key({ modkey,           }, "Right",  awful.tag.viewnext,
281               {description = "view next", group = "tag"}),
282     awful.key({ modkey,           }, "Escape", awful.tag.history.restore,
283               {description = "go back", group = "tag"}),
284
285     -- Non-empty tag browsing
286     awful.key({ altkey }, "Left", function () lain.util.tag_view_nonempty(-1) end,
287               {description = "view  previous nonempty", group = "tag"}),
288     awful.key({ altkey }, "Right", function () lain.util.tag_view_nonempty(1) end,
289               {description = "view  previous nonempty", group = "tag"}),
290
291     -- Default client focus
292     awful.key({ altkey,           }, "j",
293         function ()
294             awful.client.focus.byidx( 1)
295         end,
296         {description = "focus next by index", group = "client"}
297     ),
298     awful.key({ altkey,           }, "k",
299         function ()
300             awful.client.focus.byidx(-1)
301         end,
302         {description = "focus previous by index", group = "client"}
303     ),
304
305     -- By direction client focus
306     awful.key({ modkey }, "j",
307         function()
308             awful.client.focus.global_bydirection("down")
309             if client.focus then client.focus:raise() end
310         end,
311         {description = "focus down", group = "client"}),
312     awful.key({ modkey }, "k",
313         function()
314             awful.client.focus.global_bydirection("up")
315             if client.focus then client.focus:raise() end
316         end,
317         {description = "focus up", group = "client"}),
318     awful.key({ modkey }, "h",
319         function()
320             awful.client.focus.global_bydirection("left")
321             if client.focus then client.focus:raise() end
322         end,
323         {description = "focus left", group = "client"}),
324     awful.key({ modkey }, "l",
325         function()
326             awful.client.focus.global_bydirection("right")
327             if client.focus then client.focus:raise() end
328         end,
329         {description = "focus right", group = "client"}),
330     awful.key({ modkey,           }, "w", function () awful.util.mymainmenu:show() end,
331               {description = "show main menu", group = "awesome"}),
332
333     -- Layout manipulation
334     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end,
335               {description = "swap with next client by index", group = "client"}),
336     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end,
337               {description = "swap with previous client by index", group = "client"}),
338     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
339               {description = "focus the next screen", group = "screen"}),
340     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
341               {description = "focus the previous screen", group = "screen"}),
342     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto,
343               {description = "jump to urgent client", group = "client"}),
344     awful.key({ modkey,           }, "Tab",
345         function ()
346             if cycle_prev then
347                 awful.client.focus.history.previous()
348             else
349                 awful.client.focus.byidx(-1)
350             end
351             if client.focus then
352                 client.focus:raise()
353             end
354         end,
355         {description = "cycle with previous/go back", group = "client"}),
356     awful.key({ modkey, "Shift"   }, "Tab",
357         function ()
358             if cycle_prev then
359                 awful.client.focus.byidx(1)
360                 if client.focus then
361                     client.focus:raise()
362                 end
363             end
364         end,
365         {description = "go forth", group = "client"}),
366
367     -- Show/Hide Wibox
368     awful.key({ modkey }, "b", function ()
369             for s in screen do
370                 s.mywibox.visible = not s.mywibox.visible
371                 if s.mybottomwibox then
372                     s.mybottomwibox.visible = not s.mybottomwibox.visible
373                 end
374             end
375         end,
376         {description = "toggle wibox", group = "awesome"}),
377
378     -- On the fly useless gaps change
379     awful.key({ altkey, "Control" }, "=", function () lain.util.useless_gaps_resize(1) end,
380               {description = "increment useless gaps", group = "tag"}),
381     awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end,
382               {description = "decrement useless gaps", group = "tag"}),
383
384     -- Dynamic tagging
385     awful.key({ modkey, "Shift" }, "n", function () lain.util.add_tag() end,
386               {description = "add new tag", group = "tag"}),
387     awful.key({ modkey, "Shift" }, "r", function () lain.util.rename_tag() end,
388               {description = "rename tag", group = "tag"}),
389     awful.key({ modkey, "Shift" }, "Left", function () lain.util.move_tag(-1) end,
390               {description = "move tag to the left", group = "tag"}),
391     awful.key({ modkey, "Shift" }, "Right", function () lain.util.move_tag(1) end,
392               {description = "move tag to the right", group = "tag"}),
393     awful.key({ modkey, "Shift" }, "d", function () lain.util.delete_tag() end,
394               {description = "delete tag", group = "tag"}),
395
396     -- Standard program
397     awful.key({ modkey,           }, "Return", function () awful.spawn(terminal) end,
398               {description = "open a terminal", group = "launcher"}),
399     awful.key({ modkey, "Control" }, "r", awesome.restart,
400               {description = "reload awesome", group = "awesome"}),
401     awful.key({ modkey, "Shift"   }, "q", awesome.quit,
402               {description = "quit awesome", group = "awesome"}),
403
404     awful.key({ altkey, "Shift"   }, "l",     function () awful.tag.incmwfact( 0.05)          end,
405               {description = "increase master width factor", group = "layout"}),
406     awful.key({ altkey, "Shift"   }, "h",     function () awful.tag.incmwfact(-0.05)          end,
407               {description = "decrease master width factor", group = "layout"}),
408     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1, nil, true) end,
409               {description = "increase the number of master clients", group = "layout"}),
410     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1, nil, true) end,
411               {description = "decrease the number of master clients", group = "layout"}),
412     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1, nil, true)    end,
413               {description = "increase the number of columns", group = "layout"}),
414     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1, nil, true)    end,
415               {description = "decrease the number of columns", group = "layout"}),
416     awful.key({ modkey,           }, "space", function () awful.layout.inc( 1)                end,
417               {description = "select next", group = "layout"}),
418     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(-1)                end,
419               {description = "select previous", group = "layout"}),
420
421     awful.key({ modkey, "Control" }, "n",
422               function ()
423                   local c = awful.client.restore()
424                   -- Focus restored client
425                   if c then
426                       client.focus = c
427                       c:raise()
428                   end
429               end,
430               {description = "restore minimized", group = "client"}),
431
432     -- Dropdown application
433     awful.key({ modkey, }, "z", function () awful.screen.focused().quake:toggle() end,
434               {description = "dropdown application", group = "launcher"}),
435
436     -- Widgets popups
437     awful.key({ altkey, }, "c", function () if beautiful.cal then beautiful.cal.show(7) end end,
438               {description = "show calendar", group = "widgets"}),
439     awful.key({ altkey, }, "h", function () if beautiful.fs then beautiful.fs.show(7) end end,
440               {description = "show filesystem", group = "widgets"}),
441     awful.key({ altkey, }, "w", function () if beautiful.weather then beautiful.weather.show(7) end end,
442               {description = "show weather", group = "widgets"}),
443
444     -- Brightness
445     awful.key({ }, "XF86MonBrightnessUp", function () os.execute("xbacklight -inc 10") end,
446               {description = "+10%", group = "hotkeys"}),
447     awful.key({ }, "XF86MonBrightnessDown", function () os.execute("xbacklight -dec 10") end,
448               {description = "-10%", group = "hotkeys"}),
449
450     -- ALSA volume control
451     awful.key({ altkey }, "Up",
452         function ()
453             os.execute(string.format("amixer -q set %s 1%%+", beautiful.volume.channel))
454             beautiful.volume.update()
455         end,
456         {description = "volume up", group = "hotkeys"}),
457     awful.key({ altkey }, "Down",
458         function ()
459             os.execute(string.format("amixer -q set %s 1%%-", beautiful.volume.channel))
460             beautiful.volume.update()
461         end,
462         {description = "volume down", group = "hotkeys"}),
463     awful.key({ altkey }, "m",
464         function ()
465             os.execute(string.format("amixer -q set %s toggle", beautiful.volume.togglechannel or beautiful.volume.channel))
466             beautiful.volume.update()
467         end,
468         {description = "toggle mute", group = "hotkeys"}),
469     awful.key({ altkey, "Control" }, "m",
470         function ()
471             os.execute(string.format("amixer -q set %s 100%%", beautiful.volume.channel))
472             beautiful.volume.update()
473         end,
474         {description = "volume 100%", group = "hotkeys"}),
475     awful.key({ altkey, "Control" }, "0",
476         function ()
477             os.execute(string.format("amixer -q set %s 0%%", beautiful.volume.channel))
478             beautiful.volume.update()
479         end,
480         {description = "volume 0%", group = "hotkeys"}),
481
482     -- MPD control
483     awful.key({ altkey, "Control" }, "Up",
484         function ()
485             os.execute("mpc toggle")
486             beautiful.mpd.update()
487         end,
488         {description = "mpc toggle", group = "widgets"}),
489     awful.key({ altkey, "Control" }, "Down",
490         function ()
491             os.execute("mpc stop")
492             beautiful.mpd.update()
493         end,
494         {description = "mpc stop", group = "widgets"}),
495     awful.key({ altkey, "Control" }, "Left",
496         function ()
497             os.execute("mpc prev")
498             beautiful.mpd.update()
499         end,
500         {description = "mpc prev", group = "widgets"}),
501     awful.key({ altkey, "Control" }, "Right",
502         function ()
503             os.execute("mpc next")
504             beautiful.mpd.update()
505         end,
506         {description = "mpc next", group = "widgets"}),
507     awful.key({ altkey }, "0",
508         function ()
509             local common = { text = "MPD widget ", position = "top_middle", timeout = 2 }
510             if beautiful.mpd.timer.started then
511                 beautiful.mpd.timer:stop()
512                 common.text = common.text .. lain.util.markup.bold("OFF")
513             else
514                 beautiful.mpd.timer:start()
515                 common.text = common.text .. lain.util.markup.bold("ON")
516             end
517             naughty.notify(common)
518         end,
519         {description = "mpc on/off", group = "widgets"}),
520
521     -- Copy primary to clipboard (terminals to gtk)
522     awful.key({ modkey }, "c", function () awful.spawn.with_shell("xsel | xsel -i -b") end,
523               {description = "copy terminal to gtk", group = "hotkeys"}),
524     -- Copy clipboard to primary (gtk to terminals)
525     awful.key({ modkey }, "v", function () awful.spawn.with_shell("xsel -b | xsel") end,
526               {description = "copy gtk to terminal", group = "hotkeys"}),
527
528     -- User programs
529     awful.key({ modkey }, "q", function () awful.spawn(browser) end,
530               {description = "run browser", group = "launcher"}),
531     awful.key({ modkey }, "a", function () awful.spawn(gui_editor) end,
532               {description = "run gui editor", group = "launcher"}),
533
534     -- Default
535     --[[ Menubar
536     awful.key({ modkey }, "p", function() menubar.show() end,
537               {description = "show the menubar", group = "launcher"})
538     --]]
539     --[[ dmenu
540     --]]
541     awful.key({ modkey }, "x", function ()
542             os.execute(string.format("dmenu_run -i -fn 'Monospace' -nb '%s' -nf '%s' -sb '%s' -sf '%s'",
543             beautiful.bg_normal, beautiful.fg_normal, beautiful.bg_focus, beautiful.fg_focus))
544         end,
545         {description = "show dmenu", group = "launcher"}),
546     -- alternatively use rofi, a dmenu-like application with more features
547     -- check https://github.com/DaveDavenport/rofi for more details
548     --[[ rofi
549     awful.key({ modkey }, "x", function ()
550             os.execute(string.format("rofi -show %s -theme %s",
551             'run', 'dmenu'))
552         end,
553         {description = "show rofi", group = "launcher"}),
554     --]]
555     -- Prompt
556     awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
557               {description = "run prompt", group = "launcher"})
558     --[[   
559     awful.key({ modkey }, "x",
560               function ()
561                   awful.prompt.run {
562                     prompt       = "Run Lua code: ",
563                     textbox      = awful.screen.focused().mypromptbox.widget,
564                     exe_callback = awful.util.eval,
565                     history_path = awful.util.get_cache_dir() .. "/history_eval"
566                   }
567               end,
568               {description = "lua execute prompt", group = "awesome"})
569     --]]
570 )
571
572 clientkeys = my_table.join(
573     awful.key({ altkey, "Shift"   }, "m",      lain.util.magnify_client,
574               {description = "magnify client", group = "client"}),
575     awful.key({ modkey,           }, "f",
576         function (c)
577             c.fullscreen = not c.fullscreen
578             c:raise()
579         end,
580         {description = "toggle fullscreen", group = "client"}),
581     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end,
582               {description = "close", group = "client"}),
583     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ,
584               {description = "toggle floating", group = "client"}),
585     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
586               {description = "move to master", group = "client"}),
587     awful.key({ modkey,           }, "o",      function (c) c:move_to_screen()               end,
588               {description = "move to screen", group = "client"}),
589     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end,
590               {description = "toggle keep on top", group = "client"}),
591     awful.key({ modkey,           }, "n",
592         function (c)
593             -- The client currently has the input focus, so it cannot be
594             -- minimized, since minimized clients can't have the focus.
595             c.minimized = true
596         end ,
597         {description = "minimize", group = "client"}),
598     awful.key({ modkey,           }, "m",
599         function (c)
600             c.maximized = not c.maximized
601             c:raise()
602         end ,
603         {description = "maximize", group = "client"})
604 )
605
606 -- Bind all key numbers to tags.
607 -- Be careful: we use keycodes to make it works on any keyboard layout.
608 -- This should map on the top row of your keyboard, usually 1 to 9.
609 for i = 1, 9 do
610     -- Hack to only show tags 1 and 9 in the shortcut window (mod+s)
611     local descr_view, descr_toggle, descr_move, descr_toggle_focus
612     if i == 1 or i == 9 then
613         descr_view = {description = "view tag #", group = "tag"}
614         descr_toggle = {description = "toggle tag #", group = "tag"}
615         descr_move = {description = "move focused client to tag #", group = "tag"}
616         descr_toggle_focus = {description = "toggle focused client on tag #", group = "tag"}
617     end
618     globalkeys = my_table.join(globalkeys,
619         -- View tag only.
620         awful.key({ modkey }, "#" .. i + 9,
621                   function ()
622                         local screen = awful.screen.focused()
623                         local tag = screen.tags[i]
624                         if tag then
625                            tag:view_only()
626                         end
627                   end,
628                   descr_view),
629         -- Toggle tag display.
630         awful.key({ modkey, "Control" }, "#" .. i + 9,
631                   function ()
632                       local screen = awful.screen.focused()
633                       local tag = screen.tags[i]
634                       if tag then
635                          awful.tag.viewtoggle(tag)
636                       end
637                   end,
638                   descr_toggle),
639         -- Move client to tag.
640         awful.key({ modkey, "Shift" }, "#" .. i + 9,
641                   function ()
642                       if client.focus then
643                           local tag = client.focus.screen.tags[i]
644                           if tag then
645                               client.focus:move_to_tag(tag)
646                           end
647                      end
648                   end,
649                   descr_move),
650         -- Toggle tag on focused client.
651         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
652                   function ()
653                       if client.focus then
654                           local tag = client.focus.screen.tags[i]
655                           if tag then
656                               client.focus:toggle_tag(tag)
657                           end
658                       end
659                   end,
660                   descr_toggle_focus)
661     )
662 end
663
664 clientbuttons = gears.table.join(
665     awful.button({ }, 1, function (c)
666         c:emit_signal("request::activate", "mouse_click", {raise = true})
667     end),
668     awful.button({ modkey }, 1, function (c)
669         c:emit_signal("request::activate", "mouse_click", {raise = true})
670         awful.mouse.client.move(c)
671     end),
672     awful.button({ modkey }, 3, function (c)
673         c:emit_signal("request::activate", "mouse_click", {raise = true})
674         awful.mouse.client.resize(c)
675     end)
676 )
677
678 -- Set keys
679 root.keys(globalkeys)
680 -- }}}
681
682 -- {{{ Rules
683 -- Rules to apply to new clients (through the "manage" signal).
684 awful.rules.rules = {
685     -- All clients will match this rule.
686     { rule = { },
687       properties = { border_width = beautiful.border_width,
688                      border_color = beautiful.border_normal,
689                      focus = awful.client.focus.filter,
690                      raise = true,
691                      keys = clientkeys,
692                      buttons = clientbuttons,
693                      screen = awful.screen.preferred,
694                      placement = awful.placement.no_overlap+awful.placement.no_offscreen,
695                      size_hints_honor = false
696      }
697     },
698
699     -- Titlebars
700     { rule_any = { type = { "dialog", "normal" } },
701       properties = { titlebars_enabled = false } },
702
703     -- Set Firefox to always map on the first tag on screen 1.
704     { rule = { class = "Firefox" },
705       properties = { screen = 1, tag = awful.util.tagnames[1] } },
706
707     { rule = { class = "Gimp", role = "gimp-image-window" },
708           properties = { maximized = true } },
709 }
710 -- }}}
711
712 -- {{{ Signals
713 -- Signal function to execute when a new client appears.
714 client.connect_signal("manage", function (c)
715     -- Set the windows at the slave,
716     -- i.e. put it at the end of others instead of setting it master.
717     -- if not awesome.startup then awful.client.setslave(c) end
718
719     if awesome.startup and
720       not c.size_hints.user_position
721       and not c.size_hints.program_position then
722         -- Prevent clients from being unreachable after screen count changes.
723         awful.placement.no_offscreen(c)
724     end
725 end)
726
727 -- Add a titlebar if titlebars_enabled is set to true in the rules.
728 client.connect_signal("request::titlebars", function(c)
729     -- Custom
730     if beautiful.titlebar_fun then
731         beautiful.titlebar_fun(c)
732         return
733     end
734
735     -- Default
736     -- buttons for the titlebar
737     local buttons = my_table.join(
738         awful.button({ }, 1, function()
739             c:emit_signal("request::activate", "titlebar", {raise = true})
740             awful.mouse.client.move(c)
741         end),
742         awful.button({ }, 2, function() c:kill() end),
743         awful.button({ }, 3, function()
744             c:emit_signal("request::activate", "titlebar", {raise = true})
745             awful.mouse.client.resize(c)
746         end)
747     )
748
749     awful.titlebar(c, {size = dpi(16)}) : setup {
750         { -- Left
751             awful.titlebar.widget.iconwidget(c),
752             buttons = buttons,
753             layout  = wibox.layout.fixed.horizontal
754         },
755         { -- Middle
756             { -- Title
757                 align  = "center",
758                 widget = awful.titlebar.widget.titlewidget(c)
759             },
760             buttons = buttons,
761             layout  = wibox.layout.flex.horizontal
762         },
763         { -- Right
764             awful.titlebar.widget.floatingbutton (c),
765             awful.titlebar.widget.maximizedbutton(c),
766             awful.titlebar.widget.stickybutton   (c),
767             awful.titlebar.widget.ontopbutton    (c),
768             awful.titlebar.widget.closebutton    (c),
769             layout = wibox.layout.fixed.horizontal()
770         },
771         layout = wibox.layout.align.horizontal
772     }
773 end)
774
775 -- Enable sloppy focus, so that focus follows mouse.
776 client.connect_signal("mouse::enter", function(c)
777     c:emit_signal("request::activate", "mouse_enter", {raise = vi_focus})
778 end)
779
780 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
781 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
782
783 -- possible workaround for tag preservation when switching back to default screen:
784 -- https://github.com/lcpz/awesome-copycats/issues/251
785 -- }}}
786 --
787
788 --awful.spawn.with_shell("/home/josuer08/.screenlayout/ontop.sh")
789 --awful.spawn.with_shell("/home/josuer08/.local/bin/beautify")
790 awful.spawn.with_shell("feh --randomize --bg-fill /home/josuer08/Pictures/backgrounds/*")
791 awful.spawn.with_shell("compton")