-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathrc.lua
3157 lines (2740 loc) · 96.4 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
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local awful = require("awful")
local config_path = awful.util.getdir("config")
package.path = config_path .. "/?.lua;" .. package.path
package.path = config_path .. "/?/init.lua;" .. package.path
package.path = config_path .. "/modules/?.lua;" .. package.path
package.path = config_path .. "/modules/?/init.lua;" .. package.path
local math = require("math")
local gears = require("gears")
awful.client = require("awful.client")
awful.screen = require("awful.screen")
awful.mouse = require("awful.mouse")
awful.rules = require("awful.rules")
awful.menu = require("awful.menu")
awful.ewmh = require("awful.ewmh")
awful.spawn = require("awful.spawn")
require("awful.autofocus")
require("awful.dbus")
require("awful.remote")
local wibox = require("wibox")
local beautiful = require("beautiful")
local naughty = require("naughty")
local menubar = require("menubar")
local hotkeys_popup = require("awful.hotkeys_popup").widget
local xrandr = require("xrandr")
local foggy = require("foggy")
-- vicious widgets
local vicious = require("vicious")
-- bashets config: https://gitorious.org/bashets/pages/Brief_Introduction
local bashets = require("bashets")
-- utilities
local util = require("util")
-- universal arguments
local uniarg = require("uniarg")
local capi = {
tag = tag,
screen = screen,
client = client,
timer = timer,
}
local timer = require("gears.timer")
-- do not use letters, which shadow access key to menu entry
awful.menu.menu_keys.down = { "Down", ".", ">", "'", "\"", }
awful.menu.menu_keys.up = { "Up", ",", "<", ";", ":", }
awful.menu.menu_keys.enter = { "Right", "]", "}", "=", "+", }
awful.menu.menu_keys.back = { "Left", "[", "{", "-", "_", }
awful.menu.menu_keys.exec = { "Return", "Space", }
awful.menu.menu_keys.close = { "Escape", "BackSpace", }
-- customization
customization = {}
customization.config = {}
customization.orig = {}
customization.func = {}
customization.default = {}
customization.option = {}
customization.timer = {}
customization.widgets = {}
customization.config.version = "4.1.2"
customization.config.help_url = "https://github.com/pw4ever/awesome-wm-config/tree/" .. customization.config.version
customization.default.property = {
layout = awful.layout.suit.floating,
mwfact = 0.5,
nmaster = 1,
ncol = 1,
min_opacity = 0.4,
max_opacity = 1,
default_naughty_opacity = 1,
low_naughty_opacity = 0.90,
normal_naughty_opacity = 0.95,
critical_naughty_opacity = 1,
minimal_client_width = 50,
minimal_client_height = 50,
}
customization.default.compmgr = 'picom'
customization.default.compmgr_args = '-b --unredir-if-possible --no-fading-openclose'
customization.default.wallpaper_change_interval = 15
customization.option.wallpaper_change_p = true
customization.option.launch_compmgr_p = true
customization.option.tag_persistent_p = true
customization.option.low_battery_notification_p = true
naughty.config.presets.low.opacity = customization.default.property.low_naughty_opacity
naughty.config.presets.normal.opacity = customization.default.property.normal_naughty_opacity
naughty.config.presets.critical.opacity = customization.default.property.critical_naughty_opacity
do
local config_path = awful.util.getdir("config")
bashets.set_script_path(config_path .. "/modules/bashets/")
end
-- {{{ 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
-- }}}
-- {{{
-- HACK! prevent Awesome start autostart items multiple times in a session
-- cause: in-place restart by awesome.restart, xrandr change
-- idea:
-- * create a file awesome-autostart-once when first time "dex" autostart items (at the end of this file)
-- * only "rm" this file when awesome.quit
local cachedir = awful.util.getdir("cache")
local awesome_tags_fname = cachedir .. "/awesome-tags"
local awesome_autostart_once_fname = cachedir .. "/awesome-autostart-once-" .. (os.getenv("XDG_SESSION_ID") or "0")
local awesome_client_tags_fname = cachedir .. "/awesome-client-tags-" .. (os.getenv("XDG_SESSION_ID") or "0")
do
awesome.connect_signal("exit", function (restart)
local scrcount = screen.count()
-- save number of screens, used for check proper tag recording
do
local f = io.open(awesome_tags_fname .. ".0", "w+")
if f then
f:write(string.format("%d", scrcount) .. "\n")
f:close()
end
end
-- save current tags
for s = 1, scrcount do
local f = io.open(awesome_tags_fname .. "." .. s, "w+")
if f then
local tags = screen[s].tags
for _, tag in ipairs(tags) do
f:write(tag.name .. "\n")
end
f:close()
end
f = io.open(awesome_tags_fname .. "-selected." .. s, "w+")
if f then
f:write(awful.tag.getidx() .. "\n")
f:close()
end
end
customization.func.client_opaque_off(nil) -- prevent compmgr glitches
if not restart then
awful.spawn.with_shell("rm -rf " .. awesome_autostart_once_fname)
awful.spawn.with_shell("rm -rf " .. awesome_client_tags_fname)
if not customization.option.tag_persistent_p then
awful.spawn.with_shell("rm -rf " .. awesome_tags_fname .. '*')
end
bashets.stop()
else -- if restart, save client tags
-- save tags for each client
awful.util.mkdir(awesome_client_tags_fname)
-- !! avoid awful.spawn.with_shell("mkdir -p " .. awesome_client_tags_fname)
-- race condition (whether awesome_client_tags_fname is created) due to asynchrony of "spawn_with_shell"
for _, c in ipairs(client.get()) do
local client_id = c.pid .. '-' .. c.window
local f = io.open(awesome_client_tags_fname .. '/' .. client_id, 'w+')
if f then
for _, t in ipairs(c:tags()) do
f:write(t.name .. "\n")
end
f:close()
end
end
end
end)
customization.orig.quit = awesome.quit
awesome.quit = function ()
local scr = awful.screen.focused()
awful.prompt.run({prompt = "Quit (type 'yes' to confirm)? "},
customization.widgets.promptbox[scr].widget,
function (t)
if string.lower(t) == 'yes' then
customization.orig.quit()
end
end,
function (t, p, n)
return awful.completion.generic(t, p, n, {'no', 'NO', 'yes', 'YES'})
end)
end
end
do
customization.orig.restart = awesome.restart
awesome.restart = function ()
local scr = awful.screen.focused()
awful.prompt.run({prompt = "Restart (type 'yes' to confirm)? "},
customization.widgets.promptbox[scr].widget,
function (t)
if string.lower(t) == 'yes' then
customization.orig.restart()
end
end,
function (t, p, n)
return awful.completion.generic(t, p, n, {'no', 'NO', 'yes', 'YES'})
end)
end
end
-- }}}
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
---[[
do
local config_path = awful.util.getdir("config")
local function init_theme(theme_name)
local theme_path = config_path .. "/themes/" .. theme_name .. "/theme.lua"
beautiful.init(theme_path)
end
init_theme("zenburn")
awful.spawn.with_shell("hsetroot -solid '#000000'")
-- randomly select a background picture
--{{
function customization.func.change_wallpaper()
if customization.option.wallpaper_change_p then
awful.spawn.with_shell("cd " .. config_path .. "/wallpaper/; ./my-wallpaper-pick.sh")
end
end
customization.timer.change_wallpaper= timer({timeout = customization.default.wallpaper_change_interval})
customization.timer.change_wallpaper:connect_signal("timeout", customization.func.change_wallpaper)
customization.timer.change_wallpaper:connect_signal("property::timeout",
function ()
customization.timer.change_wallpaper:stop()
customization.timer.change_wallpaper:start()
end
)
customization.timer.change_wallpaper:start()
-- first trigger
customization.func.change_wallpaper()
--}}
end
--]]
-- This is used later as the default terminal and editor to run.
--{{
local tools = {
terminal = "kitty",
system = {
filemanager = {
},
},
browser = {
},
editor = {
},
app = {
},
}
tools.system.filemanager.primary = tools.terminal .. " -e ranger"
tools.system.filemanager.secondary = "pcmanfm"
tools.system.taskmanager = "xfce4-taskmanager"
tools.browser.primary = "chromium"
tools.browser.primary_private = tools.browser.primary .. " --incognito"
tools.browser.secondary = "firefox"
tools.browser.secondary_private = tools.browser.secondary .. " --private"
-- alternative: override
--tools.browser.primary = "google-chrome-stable"
--tools.browser.primary_private = tools.browser.primary .. " --incognito"
--tools.browser.secondary = "firefox"
--tools.browser.secondary_private = tools.browser.secondary .. " --private"
tools.editor.primary = "gvim"
tools.editor.secondary = "emacs"
-- alternative: override
--tools.editor.primary = "nvim-qt"
--tools.editor.secondary = "emacs"
tools.app.mpcui = "ncmpcpp"
local myapp = nil
do
local function build(arg)
local current = {}
local keys = {} -- keep the keys sorted
for k, v in pairs(arg) do table.insert(keys, k) end
table.sort(keys)
for _, k in ipairs(keys) do
v = arg[k]
if type(v) == 'table' then
table.insert(current, {k, build(v)})
else
table.insert(current, {v, v})
end
end
return current
end
myapp = build(tools)
end
--}}
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"
-- Table of layouts to cover with awful.layout.inc, order matters.
local layouts =
{
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.fair,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier,
}
--[[
local layouts =
{
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral,
awful.layout.suit.spiral.dwindle,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier
}
--]]
-- }}}
--[[
-- {{{ Wallpaper
if beautiful.wallpaper then
for s = 1, screen.count() do
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
end
end
-- }}}
--]]
-- {{{ Customized functions
customization.func.system_lock = function ()
awful.util.spawn("xfce4-screensaver-command -l")
end
customization.func.system_screen_off = function ()
customization.func.system_lock()
awful.spawn.with_shell("sleep 3 && xset dpms force off")
end
customization.func.system_suspend = function ()
awful.util.spawn("systemctl suspend")
end
customization.func.system_hibernate = function ()
local scr = awful.screen.focused()
awful.prompt.run({prompt = "Hibernate (type 'yes' to confirm)? "},
customization.widgets.promptbox[scr].widget,
function (t)
if string.lower(t) == 'yes' then
awful.util.spawn("systemctl hibernate")
end
end,
function (t, p, n)
return awful.completion.generic(t, p, n, {'no', 'NO', 'yes', 'YES'})
end)
end
customization.func.system_hybrid_sleep = function ()
local scr = awful.screen.focused()
awful.prompt.run({prompt = "Hybrid Sleep (type 'yes' to confirm)? "},
customization.widgets.promptbox[scr].widget,
function (t)
if string.lower(t) == 'yes' then
awful.util.spawn("systemctl hybrid-sleep")
end
end,
function (t, p, n)
return awful.completion.generic(t, p, n, {'no', 'NO', 'yes', 'YES'})
end)
end
customization.func.system_reboot = function ()
local scr = awful.screen.focused()
awful.prompt.run({prompt = "Reboot (type 'yes' to confirm)? "},
customization.widgets.promptbox[scr].widget,
function (t)
if string.lower(t) == 'yes' then
awesome.emit_signal("exit", nil)
awful.util.spawn("systemctl reboot")
end
end,
function (t, p, n)
return awful.completion.generic(t, p, n, {'no', 'NO', 'yes', 'YES'})
end)
end
customization.func.system_power_off = function ()
local scr = awful.screen.focused()
awful.prompt.run({prompt = "Power Off (type 'yes' to confirm)? "},
customization.widgets.promptbox[scr].widget,
function (t)
if string.lower(t) == 'yes' then
awesome.emit_signal("exit", nil)
awful.util.spawn("systemctl poweroff")
end
end,
function (t, p, n)
return awful.completion.generic(t, p, n, {'no', 'NO', 'yes', 'YES'})
end)
end
customization.func.app_finder = function ()
awful.util.spawn("xfce4-appfinder")
end
-- {{ client actions
customization.func.client_focus_next = function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end
customization.func.client_focus_prev = function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end
customization.func.client_focus_urgent = awful.client.urgent.jumpto
customization.func.client_swap_next = function () awful.client.swap.byidx( 1) end
customization.func.client_swap_prev = function () awful.client.swap.byidx( -1) end
customization.func.client_move_next = function () util.client.rel_send(1) end
customization.func.client_move_prev = function () util.client.rel_send(-1) end
customization.func.client_move_to_tag = function ()
local keywords = {}
local scr = awful.screen.focused()
for _, t in ipairs(scr.tags) do -- only the current screen
table.insert(keywords, t.name)
end
awful.prompt.run({prompt = "Move client to tag: "},
customization.widgets.promptbox[scr].widget,
function (t)
local tag = util.tag.name2tag(t)
if tag then
awful.client.movetotag(tag)
end
end,
function (t, p, n)
return awful.completion.generic(t, p, n, keywords)
end,
nil)
end
customization.func.client_toggle_tag = function (c)
local keywords = {}
local scr = awful.screen.focused()
for _, t in ipairs(scr.tags) do -- only the current screen
table.insert(keywords, t.name)
end
local c = c or client.focus
awful.prompt.run({prompt = "Toggle tag for " .. c.name .. ": "},
customization.widgets.promptbox[scr].widget,
function (t)
local tag = util.tag.name2tag(t)
if tag then
awful.client.toggletag(tag)
end
end,
function (t, p, n)
return awful.completion.generic(t, p, n, keywords)
end,
nil)
end
customization.func.client_toggle_titlebar = function ()
awful.titlebar.toggle(client.focus)
end
customization.func.client_raise = function (c)
c:raise()
end
customization.func.client_fullscreen = function (c)
c.fullscreen = not c.fullscreen
end
customization.func.client_maximize_horizontal = function (c)
c.maximized_horizontal = not c.maximized_horizontal
end
customization.func.client_maximize_vertical = function (c)
c.maximized_vertical = not c.maximized_vertical
end
customization.func.client_maximize = function (c)
c.maximized = not c.maximized
end
customization.func.client_minimize = function (c)
c.minimized = not c.minimized
end
do
-- closures for client_status
-- client_status[client] = {sidelined = <boolean>, geometry= <client geometry>}
local client_status = {}
customization.func.client_sideline_left = function (c)
local scr = screen[awful.screen.focused()]
local workarea = scr.workarea
if client_status[c] == nil then
client_status[c] = {sidelined=false, geometry=nil}
end
if client_status[c].sidelined then
if client_status[c].geometry then
c:geometry(client_status[c].geometry)
end
else
client_status[c].geometry = c:geometry()
workarea.width = math.floor(workarea.width/2)
c:geometry(workarea)
end
client_status[c].sidelined = not client_status[c].sidelined
end
customization.func.client_sideline_right = function (c)
local scr = screen[awful.screen.focused()]
local workarea = scr.workarea
if client_status[c] == nil then
client_status[c] = {sidelined=false, geometry=nil}
end
if client_status[c].sidelined then
if client_status[c].geometry then
c:geometry(client_status[c].geometry)
end
else
client_status[c].geometry = c:geometry()
workarea.x = workarea.x + math.floor(workarea.width/2)
workarea.width = math.floor(workarea.width/2)
c:geometry(workarea)
end
client_status[c].sidelined = not client_status[c].sidelined
end
customization.func.client_sideline_top = function (c)
local scr = screen[awful.screen.focused()]
local workarea = scr.workarea
if client_status[c] == nil then
client_status[c] = {sidelined=false, geometry=nil}
end
if client_status[c].sidelined then
if client_status[c].geometry then
c:geometry(client_status[c].geometry)
end
else
client_status[c].geometry = c:geometry()
workarea.height = math.floor(workarea.height/2)
c:geometry(workarea)
end
client_status[c].sidelined = not client_status[c].sidelined
end
customization.func.client_sideline_bottom = function (c)
local scr = screen[awful.screen.focused()]
local workarea = scr.workarea
if client_status[c] == nil then
client_status[c] = {sidelined=false, geometry=nil}
end
if client_status[c].sidelined then
if client_status[c].geometry then
c:geometry(client_status[c].geometry)
end
else
client_status[c].geometry = c:geometry()
workarea.y = workarea.y + math.floor(workarea.height/2)
workarea.height = math.floor(workarea.height/2)
c:geometry(workarea)
end
client_status[c].sidelined = not client_status[c].sidelined
end
customization.func.client_sideline_extend_left = function (c, by)
local cg = c:geometry()
if by then
cg.x = cg.x - by
cg.width = cg.width + by
else -- use heuristics
local delta = math.floor(cg.x/7)
if delta ~= 0 then
cg.x = cg.x - delta
cg.width = cg.width + delta
end
end
c:geometry(cg)
end
customization.func.client_sideline_extend_right = function (c, by)
local cg = c:geometry()
if by then
cg.width = cg.width + by
else
local workarea = screen[awful.screen.focused()].workarea
local rmargin = math.max( (workarea.x + workarea.width - cg.x - cg.width), 0)
local delta = math.floor(rmargin/7)
if delta ~= 0 then
cg.width = cg.width + delta
end
end
c:geometry(cg)
end
customization.func.client_sideline_extend_top = function (c, by)
local cg = c:geometry()
if by then
cg.y = cg.y - by
cg.height = cg.height + by
else
local delta = math.floor(cg.y/7)
if delta ~= 0 then
cg.y = cg.y - delta
cg.height = cg.height + delta
end
end
c:geometry(cg)
end
customization.func.client_sideline_extend_bottom = function (c, by)
local cg = c:geometry()
if by then
cg.height = cg.height + by
else
local workarea = screen[awful.screen.focused()].workarea
local bmargin = math.max( (workarea.y + workarea.height - cg.y - cg.height), 0)
local delta = math.floor(bmargin/7)
if delta ~= 0 then
cg.height = cg.height + delta
end
end
c:geometry(cg)
end
customization.func.client_sideline_shrink_left = function (c, by)
local cg = c:geometry()
local min = customization.default.property.minimal_client_width
if by then
cg.width = math.max(cg.width - by, min)
else
local delta = math.floor(cg.width/11)
if delta ~= 0 and cg.width > min then
cg.width = cg.width - delta
end
end
c:geometry(cg)
end
customization.func.client_sideline_shrink_right = function (c, by)
local cg = c:geometry()
local min = customization.default.property.minimal_client_width
if by then
local t = cg.x + cg.width
cg.width = math.max(cg.width - by, min)
cg.x = t - cg.width
else
local delta = math.floor(cg.width/11)
if delta ~= 0 and cg.width > min then
cg.x = cg.x + delta
cg.width = cg.width - delta
end
end
c:geometry(cg)
end
customization.func.client_sideline_shrink_top = function (c, by)
local cg = c:geometry()
local min = customization.default.property.minimal_client_height
if by then
cg.height = math.max(cg.height - by, min)
else
local delta = math.floor(cg.height/11)
if delta ~= 0 and cg.height > min then
cg.height = cg.height - delta
end
end
c:geometry(cg)
end
customization.func.client_sideline_shrink_bottom = function (c, by)
local cg = c:geometry()
local min = customization.default.property.minimal_client_height
if by then
local t = cg.y + cg.width
cg.height = math.max(cg.height - by, min)
cg.y = t - cg.height
else
local delta = math.floor(cg.height/11)
if delta ~= 0 and cg.height > min then
cg.y = cg.y + delta
cg.height = cg.height - delta
end
end
c:geometry(cg)
end
end
customization.func.client_opaque_less = function (c)
local opacity = c.opacity - 0.1
if opacity and opacity >= customization.default.property.min_opacity then
c.opacity = opacity
end
end
customization.func.client_opaque_more = function (c)
local opacity = c.opacity + 0.1
if opacity and opacity <= customization.default.property.max_opacity then
c.opacity = opacity
end
end
customization.func.client_opaque_off = function (c)
awful.spawn.with_shell("pkill " .. customization.default.compmgr)
end
customization.func.client_opaque_on = function (c)
awful.spawn.with_shell(customization.default.compmgr.. " " .. customization.default.compmgr_args)
end
customization.func.client_swap_with_master = function (c)
c:swap(awful.client.getmaster())
end
customization.func.client_toggle_top = function (c)
c.ontop = not c.ontop
end
customization.func.client_toggle_sticky = function (c)
c.sticky = not c.sticky
end
customization.func.client_kill = function (c)
c:kill()
end
do
local instance = nil
customization.func.client_action_menu = function (c)
local clear_instance = function ()
if instance then
instance:hide()
instance = nil
end
end
if instance and instance.wibox.visible then
clear_instance()
return
end
c = c or client.focus
instance = awful.menu({
theme = {
width = 200,
},
items = {
{
"&cancel", function ()
clear_instance()
end
},
{
"=== task action menu ===", function ()
clear_instance()
end
},
{
"--- status ---", function ()
clear_instance()
end
},
{
"&raise", function ()
clear_instance()
customization.func.client_raise(c)
end
},
{
"&top", function ()
clear_instance()
customization.func.client_toggle_top(c)
end
},
{
"&sticky", function ()
clear_instance()
customization.func.client_toggle_sticky(c)
end
},
{
"&kill", function ()
clear_instance()
customization.func.client_kill(c)
end
},
{
"toggle title&bar", function ()
clear_instance()
customization.func.client_toggle_titlebar(c)
end
},
{
"--- focus ---", function ()
clear_instance()
end
},
{
"&next client", function ()
clear_instance()
customization.func.client_focus_next(c)
end
},
{
"&prev client", function ()
clear_instance()
customization.func.client_focus_prev(c)
end
},
{
"&urgent", function ()
clear_instance()
customization.func.client_focus_urgent(c)
end
},
{
"--- tag ---", function ()
clear_instance()
end
},
{
"move to next tag", function ()
clear_instance()
customization.func.client_move_next(c)
end
},
{
"move to previous tag", function ()
clear_instance()
customization.func.client_move_prev(c)
end
},
{
"move to ta&g", function ()
clear_instance()
customization.func.client_move_to_tag(c)
end
},
{
"togg&le tag", function ()
clear_instance()
customization.func.client_toggle_tag(c)
end
},
{
"--- geometry ---", function ()
clear_instance()
end
},
{
"&fullscreen", function ()
clear_instance()
customization.func.client_fullscreen(c)
end
},
{
"m&aximize", function ()
clear_instance()
customization.func.client_maximize(c)
end
},
{
"maximize h&orizontal", function ()
clear_instance()
customization.func.client_maximize_horizontal(c)
end
},
{
"maximize &vertical", function ()
clear_instance()
customization.func.client_maximize_vertical(c)
end
},
{
"m&inimize", function ()
clear_instance()
customization.func.client_minimize(c)
end
},
{
"move to left", function ()
clear_instance()
customization.func.client_sideline_left(c)
end
},
{
"move to right", function ()
clear_instance()
customization.func.client_sideline_right(c)
end
},
{
"move to top", function ()
clear_instance()
customization.func.client_sideline_top(c)
end
},
{
"move to bottom", function ()
clear_instance()
customization.func.client_sideline_bottom(c)
end
},
{
"extend left", function ()
clear_instance()
customization.func.client_sideline_extend_left(c)
end
},
{
"extend right", function ()
clear_instance()
customization.func.client_sideline_extend_right(c)
end
},
{
"extend top", function ()
clear_instance()
customization.func.client_sideline_extend_top(c)
end
},
{
"extend bottom", function ()
clear_instance()
customization.func.client_sideline_extend_bottom(c)
end
},
{
"shrink left", function ()
clear_instance()
customization.func.client_sideline_shrink_left(c)
end
},
{
"shrink right", function ()
clear_instance()
customization.func.client_sideline_shrink_right(c)
end
},