forked from awailly/awesome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc.lua
669 lines (582 loc) · 24.7 KB
/
rc.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
-- {{{ License
-- Awesome configuration, using awesome 3.5 on Arch GNU/Linux
-- * Inspired by Adrian C. <[email protected]>
-- }}}
-- {{{ Libraries
awful = require("awful")
awful.rules = require("awful.rules")
awful.autofocus = require("awful.autofocus")
-- User libraries
vicious = require("vicious")
vicious.contrib = require("vicious.contrib")
-- Theme handling library
beautiful = require("beautiful")
-- Wibox
wibox = require("wibox")
require('freedesktop.utils')
naughty = require("naughty")
keydoc = require("keydoc")
-- }}}
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
-- Handle runtime errors after startup
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = err })
in_error = false
end)
end
-- }}}
-- {{{ Variable definitions
local altkey = "Mod1"
local modkey = "Mod4"
local home = os.getenv("HOME")
local exec = awful.util.spawn
local sexec = awful.util.spawn_with_shell
-- Beautiful theme
beautiful.init(home .. "/.config/awesome/zenburn.lua")
awful.util.spawn_with_shell("xcompmgr -cF &")
-- This is used later as the default terminal and editor to run.
terminal = "xterm -fg white -bg black -sl 32000"
--terminal = "xterm -font -*-fixed-medium-r-*-*-14444-*-*-*-*-*-iso8859-*"
editor = os.getenv("EDITOR") or "vim"
editor_cmd = terminal .. " -e " .. editor
freedesktop.utils.terminal = terminal
freedesktop.utils.icon_theme = 'gnome'
require('freedesktop.menu')
menu_items = freedesktop.menu.new()
myawesomemenu = {
{ "manual", terminal .. " -e man awesome", freedesktop.utils.lookup_icon({ icon = 'help' }) },
{ "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua", freedesktop.utils.lookup_icon({ icon = 'package_settings' }) },
{ "restart", awesome.restart, freedesktop.utils.lookup_icon({ icon = 'gtk-refresh' }) },
{ "quit", awesome.quit, freedesktop.utils.lookup_icon({ icon = 'gtk-quit' }) }
}
table.insert(menu_items, { "awesome", myawesomemenu, beautiful.awesome_icon })
table.insert(menu_items, { "open terminal", terminal, freedesktop.utils.lookup_icon({icon = 'terminal'}) })
mymainmenu = awful.menu.new({ items = menu_items, width = 250 })
mylauncher = awful.widget.launcher({ image = beautiful.menu_icon ,
menu = mymainmenu
})
myshutdownmenu = awful.menu({
{ "shutdown", awful.util.getdir("config") .. "/scripts/shutdown.sh", freedesktop.utils.lookup_icon({ icon = 'gtk-quit'}) },
{ "reboot", awful.util.getdir("config") .. "/scripts/reboot.sh", freedesktop.utils.lookup_icon({ icon = 'gtk-refresh'}) },
{ "suspend", awful.util.getdir("config") .. "/scripts/suspend.sh", freedesktop.utils.lookup_icon({ icon = 'gtk-quit'}) },
{ "hibernate", awful.util.getdir("config") .. "/scripts/hibernate.sh", freedesktop.utils.lookup_icon({ icon = 'gtk-quit'}) }
})
myshutdownlauncher = awful.widget.launcher({ image = beautiful.shutdown_icon,
menu = myshutdownmenu })
-- Window management layouts
layouts = {
awful.layout.suit.fair, -- 3
awful.layout.suit.tile, -- 1
awful.layout.suit.tile.bottom, -- 2
awful.layout.suit.max, -- 4
awful.layout.suit.magnifier, -- 5
awful.layout.suit.floating -- 6
}
-- }}}
-- {{{ Tags
tags = {
names = { "term", "web", "ssh", "vm", "cloud", "keepass", "1", "other", "media" },
layout = { layouts[1], layouts[1], layouts[1], layouts[1], layouts[1],
layouts[1], layouts[1], layouts[1], layouts[1]
}}
for s = 1, screen.count() do
tags[s] = awful.tag(tags.names, s, tags.layout)
awful.tag.setproperty(tags[s][5], "mwfact", 0.13)
awful.tag.setproperty(tags[s][7], "hide", true)
end
-- }}}
-- {{{ Wibox
--
-- {{{ Widgets configuration
-- {{{ Reusable separator
separator = wibox.widget.imagebox()
separator:set_image(beautiful.widget_sep)
-- }}}
-- {{{ Define gradient to be used
local colour1, colour2
colour1 = beautiful.fg_widget
colour2 = beautiful.fg_end_widget
gradient_colour = {type="linear", from={0, 0}, to={0, 10},
stops={{1, colour1}, {0.5, beautiful.fg_center_widget}, {0, colour2}}}
--- }}}
-- {{{ CPU usage and temperature
cpuicon = wibox.widget.imagebox()
cpuicon:set_image(beautiful.widget_cpu)
-- Initialize widgets
cpugraph = awful.widget.graph()
tzswidget = wibox.widget.textbox()
-- Graph properties
cpugraph:set_width(40):set_height(14)
cpugraph:set_background_color(beautiful.fg_off_widget)
cpugraph:set_color(gradient_colour)
-- Register widgets
vicious.register(cpugraph, vicious.widgets.cpu, "$1")
vicious.register(tzswidget, vicious.widgets.thermal, " $1C", 19, {"thermal_zone1", "sys"})
-- }}}
-- {{{ Battery state
baticon = wibox.widget.imagebox()
baticon:set_image(beautiful.widget_bat)
-- Initialize widget
batwidget = wibox.widget.textbox()
-- Register widget
vicious.register(batwidget, vicious.widgets.bat, "$1$2%", 61, "BAT0")
-- vicious.register(batwidget, vicious.contrib.batproc, "$1$2%", 61, "BAT0")
-- }}}
-- {{{ Memory usage
memicon = wibox.widget.imagebox()
memicon:set_image(beautiful.widget_mem)
-- Initialize widget
membar = awful.widget.progressbar()
-- Progressbar properties
membar:set_vertical(true)
membar:set_ticks(true)
membar:set_height(12)
membar:set_width(8)
membar:set_ticks_size(2)
membar:set_background_color(beautiful.fg_off_widget)
membar:set_color(gradient_colour)
-- Register widget
vicious.register(membar, vicious.widgets.mem, "$1", 13)
-- }}}
-- {{{ File system usage
fsicon = wibox.widget.imagebox()
fsicon:set_image(beautiful.widget_fs)
-- Initialize widgets
fs = {
r = awful.widget.progressbar(), h = awful.widget.progressbar(),
s = awful.widget.progressbar(), b = awful.widget.progressbar()
}
-- Progressbar properties
for _, w in pairs(fs) do
w:set_vertical(true)
w:set_ticks(true)
w:set_height(14)
w:set_width(5)
w:set_ticks_size(2)
w:set_border_color(beautiful.border_widget)
w:set_background_color(beautiful.fg_off_widget)
w:set_color(gradient_colour)
--w.widget:buttons(awful.util.table.join(
-- awful.button({ }, 1, function () exec("rox", false) end)
--))
end -- Enable caching
vicious.cache(vicious.widgets.fs)
-- Register widgets
vicious.register(fs.r, vicious.widgets.fs, "${/ used_p}", 599)
vicious.register(fs.h, vicious.widgets.fs, "${/home used_p}", 599)
vicious.register(fs.s, vicious.widgets.fs, "${/var used_p}", 599)
vicious.register(fs.b, vicious.widgets.fs, "${/tmp used_p}", 599)
-- }}}
-- {{{ Network usage
dnicon = wibox.widget.imagebox()
upicon = wibox.widget.imagebox()
dnicon:set_image(beautiful.widget_net)
upicon:set_image(beautiful.widget_netup)
-- Initialize widget
netwidget = wibox.widget.textbox()
-- Register widget
vicious.register(netwidget, vicious.widgets.net, '<span color="'
.. beautiful.fg_netdn_widget ..'">${eth0 down_kb}</span> <span color="'
.. beautiful.fg_netup_widget ..'">${eth0 up_kb}</span>', 3)
-- {{{ Reusable separators
separator = wibox.widget.imagebox()
separator:set_image(beautiful.widget_sep)
separator2 = wibox.widget.imagebox()
separator2:set_image(beautiful.widget_sep_empty)
-- }}}
-- {{{ Define gradient to be used
local colour1, colour2
colour1 = beautiful.fg_widget
colour2 = beautiful.fg_end_widget
gradient_colour = {type="linear", from={0, 0}, to={0, 10},
stops={{1, colour1}, {0.5, beautiful.fg_center_widget}, {0, colour2}}}
--- }}}
-- {{{ Volume level
--
require("widgets.volume")
volicon = wibox.widget.imagebox()
volicon:set_image(beautiful.widget_vol)
volwidget:buttons(awful.util.table.join(
awful.button({ }, 1, function () exec("amixer "..pulse.." set "..channel.." 1+ toggle") end),
awful.button({ }, 4, function () exec("amixer "..pulse.." -q set "..channel.." 5%+", false) end),
awful.button({ }, 5, function () exec("amixer "..pulse.." -q set "..channel.." 5%-", false) end)
))
-- Initialize widgets
-- }}}
-- {{{ Date and time
dateicon = wibox.widget.imagebox()
dateicon:set_image(beautiful.widget_date)
-- Initialize widget
datewidget = wibox.widget.textbox()
-- Register widget
vicious.register(datewidget, vicious.widgets.date, "%R ", 61)
-- Register buttons
datewidget:buttons(awful.util.table.join(
awful.button({ }, 1, function () exec("pylendar.py") end)
))
-- }}}
-- {{{ Wibox initialisation
mywibox = {}
promptbox = {}
layoutbox = {}
taglist = {}
taglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly),
awful.button({ modkey }, 1, awful.client.movetotag),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev
))
for s = 1, screen.count() do
-- Create a promptbox
promptbox[s] = awful.widget.prompt()
-- Create a layoutbox
layoutbox[s] = awful.widget.layoutbox(s)
layoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)
))
-- Create the taglist
taglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist.buttons)
-- Create the wibox
mywibox[s] = awful.wibox({ screen = s,
fg = beautiful.fg_normal, height = 20,
bg = beautiful.bg_normal, position = "top",
border_color = beautiful.bg_normal,
border_width = 1
})
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(separator2)
left_layout:add(mylauncher)
left_layout:add(separator)
left_layout:add(taglist[s])
left_layout:add(separator)
left_layout:add(promptbox[s])
-- Widgets that are aligned to the right
local custom_widgets =
{
separator, cpuicon, cpugraph, tzswidget, separator,
baticon, batwidget, separator,
memicon, membar, separator,
fsicon, fs.r, fs.h, fs.s, fs.b, separator,
dnicon, netwidget, upicon, separator,
volicon, volbar, volwidget, separator,
dateicon, datewidget,
layoutbox[s],
separator,
myshutdownlauncher,
separator2
}
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
for _, wdgt in pairs(custom_widgets) do
right_layout:add(wdgt)
end
-- Now bring it all together (with the tasklist in the middle)
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
--layout:set_middle(mytasklist[s])
layout:set_right(right_layout)
mywibox[s]:set_widget(layout)
end
-- }}}
-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
-- Client bindings
clientbuttons = awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey }, 1, awful.mouse.client.move),
awful.button({ modkey }, 3, awful.mouse.client.resize)
)
-- }}}
-- {{{ Key bindings
globalkeys = awful.util.table.join(
keydoc.group('Layout manipulation'),
awful.key({ modkey, }, "Left", awful.tag.viewprev , 'View previous tag'),
awful.key({ modkey, }, "Right", awful.tag.viewnext , 'View next tag'),
awful.key({ modkey, }, "Escape", awful.tag.history.restore, 'Focus previously selected tag set'),
keydoc.group('Client manipulation'),
awful.key({ modkey, }, "j",
function ()
awful.client.focus.byidx( 1)
if client.focus then client.focus:raise() end
end, "Swap with next window"),
awful.key({ modkey, }, "k",
function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end, "Swap with previous window"),
awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end, 'Rotate clients around in a tag next'),
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end, 'Rotate clients around in a tag previous'),
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end, 'Focus next screen'),
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end, 'Focus previous screen'),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto, 'Focus first urgent client'),
awful.key({ modkey, }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end, 'Tab through client history'),
-- Standard program
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end, "Spawn a terminal"),
awful.key({ modkey, "Control" }, "r", awesome.restart, "Reload awesome"),
awful.key({ modkey, "Shift" }, "q", awesome.quit, "Quit awesome"),
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end, "Switch to next layout"),
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end, "Switch to previous layout"),
awful.key({ modkey, "Shift" }, "o",
function (c)
local currenttag = awful.tag.getidx()
local nextscreen = mouse.screen.index + 1
if mouse.screen.index == screen.count() then
nextscreen = mouse.screen.index - 1
end
awful.client.movetotag(tags[nextscreen][currenttag],c)
awful.tag.viewonly(tags[nextscreen][currenttag])
end, "Send current window to next screen"),
awful.key( -- restore minimized windows
{modkey, "Shift"}, "n",
function ()
local allclients = client.get(mouse.screen.index)
for _,c in ipairs(allclients) do
if c.minimized and c:tags()[mouse.screen.index] ==
awful.tag.selected(mouse.screen.index) then
c.minimized = false
client.focus = c
c:raise()
return
end
end
end
),
keydoc.group('Custom'),
awful.key({ altkey, "Control" }, "l", function () awful.util.spawn("dm-tool lock") end, "Lock Screen"),
awful.key({ modkey, }, "r", function () promptbox[mouse.screen.index]:run() end),
awful.key({ modkey, }, "e", function () awful.util.spawn_with_shell("firefox") end, "Open file explorer"),
awful.key({ modkey, }, "b", function () awful.util.spawn("chromium") end, "Open web browser"),
keydoc.group('Multimedia'),
awful.key({ }, "Print", function () awful.util.spawn_with_shell("sleep 0.5 && scrot '%Y-%m-%d_%H:%M:%S_capture.png' -e 'mv $f /home/cberland/Images/screenshots/'") end, "Take a screenshot"),
awful.key({ "Control" }, "Print", function () awful.util.spawn_with_shell("sleep 0.5 && scrot -u '%Y-%m-%d_%H:%M:%S_capture.png' -e 'mv $f /home/cberland/Images/screenshots/'") end, "Take a screenshot of current window"),
awful.key({ "Shift" }, "Print", function () awful.util.spawn_with_shell("sleep 0.5 && scrot -s '%Y-%m-%d_%H:%M:%S_capture.png' -e 'mv $f /home/cberland/Images/screenshots/'") end, "Take a screenshot of an area"),
awful.key({ modkey }, "x",
function ()
awful.prompt.run({ prompt = "Run Lua code: " },
promptbox[mouse.screen.index].widget,
awful.util.eval, nil,
awful.util.getdir("cache") .. "/history_eval")
end),
awful.key({ }, "XF86AudioRaiseVolume", function () exec("amixer -D pulse -q set Master 5%+") end),
awful.key({ }, "XF86AudioLowerVolume", function () exec("amixer -D pulse -q set Master 5%-") end),
awful.key({ }, "XF86AudioMute", function () exec("amixer -D pulse -q set Master 1+ toggle") end),
awful.key({ modkey, }, "F1", keydoc.display)
)
clientkeys = awful.util.table.join(
keydoc.group('Client keys'),
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end, "Fullscreen"),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end, "Close"),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle , "Toggle Floating"),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end, "Swap"),
awful.key({ modkey, }, "o", awful.client.movetoscreen , "Move to screen"),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, "On top"),
awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end, "Minimize"),
awful.key({ modkey, }, "m",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
end, "Maximize")
)
-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(9, math.max(#tags[s], keynumber));
end
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, keynumber do
globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen.index
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end),
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = mouse.screen.index
if tags[screen][i] then
awful.tag.viewtoggle(tags[screen][i])
end
end),
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i]
if tag then
awful.client.movetotag(tag)
end
end
end))
end
clientbuttons = awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey }, 1, awful.mouse.client.move),
awful.button({ modkey }, 3, awful.mouse.client.resize))
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Rules
awful.rules.rules = {
{ rule = { },
properties = {
focus = true, size_hints_honor = false,
keys = clientkeys, buttons = clientbuttons,
border_width = beautiful.border_width,
border_color = beautiful.border_normal
}
},
{ rule = { class = "Firefox" },
callback = function(c) awful.client.movetotag(tags[mouse.screen.index][2],c) end },
{ rule = { class = "Vim", instance = "vim" },
callback = function(c) awful.client.movetotag(tags[mouse.screen.index][1],c) end },
{ rule = { class = "owncloud", instance = "owncloud" },
callback = function(c) awful.client.movetotag(tags[mouse.screen.index][5],c) end },
{ rule = { class = "chromium" },
callback = function(c) awful.client.movetotag(tags[mouse.screen.index][2],c) end },
{ rule = { class = "KeePass.exe", instance = "KeePass.exe" },
callback = function(c) awful.client.movetotag(tags[mouse.screen.index][6],c) end },
{ rule = { class = "VirtualBox" },
callback = function(c) awful.client.movetotag(tags[mouse.screen.index][4],c) end },
{ rule = { class = "Vim", instance = "_Remember_" },
properties = { floating = true }, callback = awful.titlebar.add },
{ rule = { class = "Firefox", instance = "Download" },
properties = { floating = true } },
{ rule = { class = "Firefox", instance = "Browser" },
properties = { floating = true } },
{ rule = { class = "Firefox", instance = "Toplevel" },
properties = { floating = true } },
{ rule = { class = "Firefox", instance = "Places" },
properties = { floating = true } },
{ rule = { class = "nautilus" },
properties = { floating = true, maximized_vertical = true, maximized_horizontal = false }},
{ rule = { class = "gimp" },
properties = { floating = true, maximized_vertical = false, maximized_horizontal = false }}
}
-- }}}
-- {{{ Signals
--
-- {{{ Manage signal handler
client.connect_signal("manage", function (c, startup)
-- Add titlebar to floaters, but remove those from rule callback
if awful.client.floating.get(c)
or awful.layout.get(c.screen) == awful.layout.suit.floating then
if c.titlebar then awful.titlebar.remove(c)
else awful.titlebar(c, {modkey = modkey}) end
end
-- Enable sloppy focus
c:connect_signal("mouse::enter", function (c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
-- Client placement
if not startup then
awful.client.setslave(c)
if not c.size_hints.program_position
and not c.size_hints.user_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
end
end)
-- }}}
-- {{{ Focus signal handlers
client.connect_signal("focus", function(c)
c.border_color = beautiful.border_focus
c.opacity = 1
end)
client.connect_signal("unfocus", function(c)
c.border_color = beautiful.border_normal
c.opacity = 0.7
end)
-- }}}
-- {{{ Arrange signal handler
for s = 1, screen.count() do screen[s]:connect_signal("arrange", function ()
local clients = awful.client.visible(s)
local layout = awful.layout.getname(awful.layout.get(s))
for _, c in pairs(clients) do -- Floaters are always on top
if awful.client.floating.get(c) or layout == "floating"
then if not c.fullscreen then c.above = true end
else c.above = false end
end
end)
end
-- }}}
-- }}}
-- Autorun programs
function spawn_once(command, class, tag)
-- create move callback
local callback
callback = function(c)
if c.class == class then
awful.client.movetotag(tag, c)
client.remove_signal("manage", callback)
end
end
client.add_signal("manage", callback)
-- now check if not already running!
local findme = command
local firstspace = findme:find(" ")
if firstspace then
findme = findme:sub(0, firstspace-1)
end
-- finally run it
awful.util.spawn_with_shell("pgrep -u $USER -x .*" .. findme .. ".* > /dev/null || (" .. command .. ")")
end
autorun = true
autorunApps =
{
"nitrogen --restore",
"autocutsel -selection CLIPBOARD -fork",
"autocutsel -selection PRIMARY -fork",
"pgrep -u $USER -x .*xautolock.* > /dev/null || ~/.config/awesome/locker.sh",
-- "/usr/bin/VBoxClient-all",
"pgrep -u $USER -x .*nm-applet.* > /dev/null || nm-applet",
"owncloud"
}
if autorun then
for _, app in pairs(autorunApps) do
awful.util.spawn_with_shell(app)
end
end