-
Notifications
You must be signed in to change notification settings - Fork 3
/
rc.lua
1088 lines (940 loc) · 29.9 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
-- Include awesome libraries, with lots of useful function!
require("awful")
require("awful.titlebar")
require("awful.autofocus")
require("awesome")
require("client")
require("screen")
require("beautiful")
require("naughty")
require("freedesktop.utils")
require("freedesktop.menu")
require("tsave")
require("pipelets")
require("myrc.mainmenu")
require("myrc.tagman")
require("myrc.themes")
require("myrc.keybind")
require("myrc.memory")
require("myrc.logmon")
--{{{ Debug
function dbg(vars)
local text = ""
for i=1, #vars-1 do text = text .. tostring(vars[i]) .. " | " end
text = text .. tostring(vars[#vars])
naughty.notify({ text = text, timeout = 10 })
end
function dbg_client(c)
local text = ""
if c.class then
text = text .. "Class: " .. c.class .. " "
end
if c.instance then
text = text .. "Instance: ".. c.instance .. " "
end
if c.role then
text = text .. "Role: ".. c.role .. " "
end
if c.type then
text = text .. "Type: ".. c.type .. " "
end
text = text .. "Full name: '" .. client_name(c) .. "'"
dbg({text})
end
--}}}
--{{{ Run or raise
--- Spawns cmd if no client can be found matching properties
-- If such a client can be found, pop to first tag where it is visible, and give it focus
-- @param cmd the command to execute
-- @param properties a table of properties to match against clients. Possible entries: any properties of the client object
function run_or_raise(cmd, properties)
local clients = client.get()
local focused = awful.client.next(0)
local findex = 0
local matched_clients = {}
local n = 0
-- Returns true if all pairs in table1 are present in table2
function match (table1, table2)
for k, v in pairs(table1) do
if table2[k] ~= v and not table2[k]:find(v) then
return false
end
end
return true
end
for i, c in pairs(clients) do
--make an array of matched clients
if match(properties, c) then
n = n + 1
matched_clients[n] = c
if c == focused then
findex = n
end
end
end
if n > 0 then
local c = matched_clients[1]
-- if the focused window matched switch focus to next in list
if 0 < findex and findex < n then
c = matched_clients[findex+1]
end
local ctags = c:tags()
if table.getn(ctags) == 0 then
-- ctags is empty, show client on current tag
local curtag = awful.tag.selected()
awful.client.movetotag(curtag, c)
else
-- Otherwise, pop to first tag client is visible on
awful.tag.viewonly(ctags[1])
end
-- And then focus the client
if client.focus == c then
c:tags({})
else
client.focus = c
c:raise()
end
return
end
awful.util.spawn(cmd, false)
end
--}}}
--{{{ Data serialisation helpers
function client_name(c)
local cls = c.class or ""
local inst = c.instance or ""
local role = c.role or ""
local ctype = c.type or ""
return cls..":"..inst..":"..role..":"..ctype
end
-- where can be 'left' 'right' 'center' nil
function client_snap(c, where, geom)
local sg = screen[c.screen].geometry
local cg = geom or c:geometry()
local cs = c:struts()
cs['left'] = 0
cs['top'] = 0
cs['bottom'] = 0
cs['right'] = 0
if where == 'right' then
cg.x = sg.width - cg.width
cs[where] = cg.width
c:struts(cs)
c:geometry(cg)
elseif where == 'left' then
cg.x = 0
cs[where] = cg.width
c:struts(cs)
c:geometry(cg)
elseif where == 'bottom' then
awful.placement.centered(c)
cg = c:geometry()
cg.y = sg.height - cg.height - beautiful.wibox_bottom_height
cs[where] = cg.height + beautiful.wibox_bottom_height
c:struts(cs)
c:geometry(cg)
elseif where == nil then
c:struts(cs)
c:geometry(cg)
elseif where == 'center' then
c:struts(cs)
awful.placement.centered(c)
else
return
end
end
function save_geometry(c, g)
myrc.memory.set("geometry", client_name(c), g)
if g ~= nil then
c:geometry(g)
end
end
function save_floating(c, f)
myrc.memory.set("floating", client_name(c), f)
awful.client.floating.set(c, f)
end
function save_titlebar(c, val)
myrc.memory.set("titlebar", client_name(c), val)
if val == true then
awful.titlebar.add(c, { modkey = modkey })
elseif val == false then
awful.titlebar.remove(c)
end
return val
end
function get_titlebar(c, def)
return myrc.memory.get("titlebar", client_name(c), def)
end
function save_tag(c, tag)
local tn = "none"
if tag then tn = tag.name end
myrc.memory.set("tags", client_name(c), tn)
if tag ~= nil and tag ~= awful.tag.selected() then
awful.client.movetotag(tag, c)
end
end
function get_tag(c, def)
local tn = myrc.memory.get("tags", client_name(c), def)
return myrc.tagman.find(tn)
end
function save_dockable(c, val)
myrc.memory.set("dockable", client_name(c), val)
awful.client.dockable.set(c, val)
end
function get_dockable(c, def)
return myrc.memory.get("dockable", client_name(c), def)
end
function save_hor(c, val)
myrc.memory.set("maxhor", client_name(c), val)
c.maximized_horizontal = val
end
function get_hor(c, def)
return myrc.memory.get("maxhor", client_name(c), def)
end
function save_vert(c, val)
myrc.memory.set("maxvert", client_name(c), val)
c.maximized_vertical = val
end
function get_vert(c, def)
return myrc.memory.get("maxvert", client_name(c), def)
end
function save_snap(c, val)
myrc.memory.set("snap", client_name(c), val)
client_snap(c, val)
end
function get_snap(c, def)
return myrc.memory.get("snap", client_name(c), def)
end
function save_hidden(c, val)
myrc.memory.set("hidden", client_name(c), val)
c.skip_taskbar = val
end
function get_hidden(c, def)
return myrc.memory.get("hidden", client_name(c), def)
end
function get_border(c, def)
return myrc.memory.get("border", client_name(c), def)
end
function get_layout_border(c)
if awful.client.floating.get(c) == false and
awful.layout.get() == awful.layout.suit.max
then
return 0
else
return get_border(c, beautiful.border_width)
end
end
function save_border(c, val)
myrc.memory.set("border", client_name(c), val)
c.border_width = get_layout_border(c)
end
--}}}
-- Menu helpers--{{{
mymenu = nil
function menu_hide()
if mymenu ~= nil then
mymenu:hide()
mymenu = nil
end
end
function menu_current(menu, args)
if mymenu ~= nil and mymenu ~= menu then
mymenu:hide()
end
mymenu = menu
mymenu:show(args)
return mymenu
end
function client_contex_menu(c)
local mp = mouse.coords()
local menupos = {x = mp.x-1*beautiful.menu_width/3, y = mp.y}
local menuitmes = {
{" ::: "..c.class.." :::" ,nil,nil}
,
{"&Q Kill", function ()
c:kill()
end},
{"",nil,nil}
,
{"&F Floating", {
{ "&Enable", function ()
save_floating(c, true)
end},
{ "&Disable", function ()
save_floating(c, false)
end}
}},
{"&T Titlebar", {
{ "&Enable" , function ()
save_titlebar(c, true)
end},
{"&Disable", function ()
save_titlebar(c, false)
end},
}},
{"&G Geometry", {
{ "&Save" , function ()
save_geometry(c, c:geometry())
end},
{"&Clear", function ()
save_geometry(c, nil)
end},
}},
{"&V Fullscreen vert", {
{"&Enable", function ()
save_vert(c, true)
end},
{"&Disable" , function ()
save_vert(c, false)
end},
}},
{"&H Fullscreen hor", {
{"&Enable", function ()
save_hor(c, true)
end},
{"&Disable" , function ()
save_hor(c, false)
end},
}},
{"&S Snap", {
{ "&Center", function ()
save_snap(c, 'center')
end},
{"&Right", function ()
save_snap(c, 'right')
end},
{"&Left", function ()
save_snap(c, 'left')
end},
{"&Bottom", function ()
save_snap(c, 'bottom')
end},
{"&Off", function ()
save_snap(c, nil)
end},
}},
{"&B Border", {
{ "&None", function ()
save_border(c, 0)
end},
{"&One", function ()
save_border(c, 1)
end},
{"&Default", function ()
save_border(c, nil)
end},
}},
{"&S Stick", {
{ "To &this tag",
function ()
local t = awful.tag.selected()
save_tag(c, t)
naughty.notify({text = "Client " .. c.name .. " has been sticked to tag " .. t.name})
end},
{"To &none", function ()
save_tag(c, nil)
naughty.notify({text = "Client " .. c.name .. " has been unsticked from tag"})
end},
}},
{ "&I Hidden", {
{"&Enable", function ()
save_hidden(c, true)
end},
{"&Disable" , function ()
save_hidden(c, false)
end},
}},
{"&R Rename", function ()
awful.prompt.run(
{ prompt = "Rename client: " },
mypromptbox[mouse.screen].widget,
function(n)
awful.client.property.set(c,"label", n)
end,
awful.completion.bash,
awful.util.getdir("cache") .. "/rename")
end},
}
return awful.menu( { items = menuitmes, height = theme.menu_context_height } ), menupos
end--}}}
-- {{{ Variable definitions
-- Default modkey.
modkey = "Mod4"
altkey = "Mod1"
-- Environment programs
env = {
browser = "chromium ",
man = "urxvt -e man ",
terminal = "urxvt ",
screen = "urxvt -e screen",
fileman = "nautilus",
terminal_root = "urxvt -e su -c screen",
im = "pidgin ",
editor = os.getenv("EDITOR") or "urxvt -e vim ",
home_dir = os.getenv("HOME"),
music_show = "gmpc --replace",
music_hide = "gmpc --quit",
run = "gmrun",
locker = "xscreensaver-command -lock",
xkill = "xkill",
poweroff = "sudo /sbin/poweroff",
reboot = "sudo /sbin/reboot",
hibernate = "sudo /usr/sbin/pm-hibernate",
suspend = "sudo /usr/sbin/pm-suspend",
rotate = "rotator",
rfkill = {
wifi = "sudo /usr/local/bin/laptop-net wifi",
wimax = "sudo /usr/local/bin/laptop-net wimax",
off = "sudo /usr/local/bin/laptop-net off"},
syslog = "urxvt -e vim -T xterm-256color /var/log/messages"
}
-- Pipelets
pipelets.config.script_path = awful.util.getdir("config").."/pipelets/"
-- Naughty
naughty.config.presets.keybind = {
position = 'top_left',
timeout = 0,
}
logmon_width = 180
naughty.config.position = 'top_right'
naughty.config.presets.low.width = logmon_width
naughty.config.presets.normal.width = logmon_width
naughty.config.presets.critical.width = logmon_width
-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
awful.layout.suit.max,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.magnifier,
awful.layout.suit.floating
}
awful.menu.menu_keys = {
up={ "Up", 'k' },
down = { "Down", 'j' },
back = { "Left", 'x', 'h' },
exec = { "Return", "Right", 'o', 'l' },
close = { "Escape" }
}
contextmenu_args = {
coords={ x=0, y=0 },
keygrabber = true
}
mainmenu_args = {
coords={ x=0, y=0 },
keygrabber = true
}
chord_menu_args = {
coords={ x=0, y=0 },
keygrabber = false
}
myrc.memory.init()
beautiful.init(myrc.themes.current())
-- Custom icons
clientmenu_icon = beautiful.clientmenu_icon or beautiful.awesome_icon
kbd_icon = beautiful.xvkbd_icon or beautiful.awesome_icon
myrc.mainmenu.init(env)
myrc.tagman.init(function(s) return myrc.memory.get("tagnames", tostring(s), nil) end)
myrc.logmon.init()
pipelets.init()
-- }}}
-- {{{ Wibox
-- Empty launcher
mymainmenu = myrc.mainmenu.build()
mylauncher = awful.widget.button({image = beautiful.awesome_icon})
-- Main menu will be placed at left top corner of screen
mylauncher:buttons(awful.util.table.join(mylauncher:buttons(),
awful.button({}, 1, nil, function () menu_current(mymainmenu, mainmenu_args) end)))
-- Create a systray
mysystray = widget({ type = "systray" })
-- Create a wibox for each screen and add it
mytop = {}
mybottom = {}
mypromptbox = {}
myclientmenu = {}
myclientmenu.timer = timer{ timeout=0.7 }
myclientmenu.timer:add_signal("timeout", function()
myclientmenu.suppress = nil
myclientmenu.timer:stop()
end)
myclientmenu.buttons = awful.util.table.join(
awful.button({ }, 1, function ()
if myclientmenu.suppress ~= nil then return end
if client.focus == nil then return end
local menu, coords = client_contex_menu(client.focus)
menu_current(menu, {coords = coords})
myclientmenu.suppress = true
myclientmenu.timer:start()
end))
-- On screen keyboard
mykbd = {}
mykbd.timer = timer{ timeout=0.7 }
mykbd.timer:add_signal("timeout", function()
mykbd.suppress = nil
mykbd.timer:stop()
end)
mykbd.buttons = awful.util.table.join(
awful.button({ }, 1, function ()
if mykbd.suppress ~= nil then return end
local clients = client.get()
local xvkbd = nil
for i, c in pairs(clients) do
if c.class == "XVkbd" then
xvkbd = c
break
end
end
if xvkbd ~= nil then
awful.util.spawn("killall xvkbd", false)
else
awful.util.spawn("xvkbd", false)
end
mykbd.suppress = true
mykbd.timer:start()
end))
-- Clock
mytextclock = {}
mytextclock = widget({ type = "textbox", align="right" })
pipelets.register_fmt(mytextclock, "date", " $1 ")
-- Mountbox
mymountbox = widget({ type = "textbox", align="right" })
pipelets.register_fmt( mymountbox, "mmount", " $1")
-- BatteryBox
mybatbox = widget({ type = "textbox", align="right" })
pipelets.register( mybatbox, "batmon")
-- Kbdbox
mykbdbox = widget({ type = "textbox", align="right" })
pipelets.register_fmt( mykbdbox, "kbd", " $1 ")
-- Temp
mytemp = widget({ type = "textbox", align="right" })
pipelets.register_fmt( mytemp, "temp", " $1 ")
-- RFKILL
myrfkill = widget({ type = "textbox", align="right" })
pipelets.register_fmt( myrfkill, "rfkill", "<span color='#336633'> $1</span>")
-- Wifi assoc ESSID
mywifibox = widget({ type = "textbox", align="right" })
pipelets.register_fmt( mywifibox, "wireless", "<span color='#333366'> $1</span>")
-- Wimax
mywimaxbox = widget({ type = "textbox", align="right" })
pipelets.register_fmt( mywimaxbox, "wimax", "<span color='#333366'> $1</span>")
-- Layoutbox
mylayoutbox = {}
mylayoutbox.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)
)
-- Taglist
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly),
awful.button({ modkey }, 1, awful.client.movetotag),
awful.button({ }, 3, function (tag) tag.selected = not tag.selected end),
awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
)
-- Tasklist
mytasklist = {}
mytasklist.buttons = awful.util.table.join(
awful.button({ }, 1, function (c)
if not c:isvisible() then
awful.tag.viewonly(c:tags()[1])
end
if client.focus ~= c then
client.focus = c;
end
client.focus:raise()
end),
awful.button({ }, 3, function (c)
local menu, coords = client_contex_menu(c)
menu_current(menu, {coords = coords})
end),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end)
)
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt({layout = awful.widget.layout.horizontal.leftright})
-- Create an imagebox widget which will contains an icon indicating
-- which layout we're using. We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(mylayoutbox.buttons)
-- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s,
awful.widget.taglist.label.all,
mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist( function (c)
return awful.widget.tasklist.label.currenttags(c,s)
end, mytasklist.buttons)
myclientmenu[s] = awful.widget.button({image = clientmenu_icon})
myclientmenu[s]:buttons(myclientmenu.buttons)
mykbd[s] = awful.widget.button({image = kbd_icon})
mykbd[s]:buttons(mykbd.buttons)
-- Create top wibox
mytop[s] = awful.wibox({
position = "top", screen = s, height = beautiful.wibox_height })
mytop[s].widgets = {
mylauncher,
mylayoutbox[s],
mytaglist[s],
mypromptbox[s],
{
myclientmenu[s],
s == 1 and mysystray or nil,
mytextclock,
layout = awful.widget.layout.horizontal.rightleft
},
mytasklist[s],
layout = awful.widget.layout.horizontal.leftright,
height = mytop[s].height
}
-- Create bottom wibox
mybottom[s] = awful.wibox({
position = "bottom", screen = s, height = beautiful.wibox_bottom_height })
mybottom[s].widgets = {
{
mykbdbox,
mykbd[s],
layout = awful.widget.layout.horizontal.rightleft
},
myrfkill,
mytemp,
mybatbox,
mymountbox,
mywifibox,
mywimaxbox,
layout = awful.widget.layout.horizontal.leftright
}
end
-- }}}
-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 3, function () menu_current(mymainmenu) end),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}
-- {{{ Key bindings
-- Switches to prev/next client
function switch_to_client(direction)
if direction == 0 then
awful.client.focus.history.previous()
else
awful.client.focus.byidx(direction);
end
if client.focus then client.focus:raise() end
end
-- Toggle tags between current and one, that has name @name
function toggle_tag(name)
local this = awful.tag.selected()
if this.name == name then
awful.tag.history.restore()
else
local t = myrc.tagman.find(name)
if t == nil then
naughty.notify({text = "Can't find tag with name '" .. name .. "'"})
return
end
awful.tag.viewonly(t)
end
end
function chord_mpd()
return {
menu = {
height = theme.menu_context_height
},
naughty = {
title = "::MPD::"
},
{{}, "Escape", "Cancel", function ()
end},
{{}, "w", "Cancel", function ()
end},
{{}, "p", "Play/pause", function ()
awful.util.spawn("mpc toggle", false)
end},
{{}, "n", "Next", function ()
awful.util.spawn("mpc next", false)
end},
{{"Shift"}, "n", "Prev", function ()
awful.util.spawn("mpc prev", false)
end},
{{}, "b", "Back", function ()
awful.util.spawn("mpc seek 0%", false)
end},
{{}, "9", "Vol down", function ()
awful.util.spawn("mpc volume -5", false)
return false
end},
{{}, "0", "Vol up", function ()
awful.util.spawn("mpc volume +5", false)
return false
end},
}
end
function chord_tags()
return {
menu = {
height = theme.menu_context_height
},
naughty = {
title = "::TAGS::"
},
{{}, "Escape", "Cancel", function ()
end},
{{}, "Return", "Cancel", function ()
end},
{{}, "r", "Rename current tag", function ()
awful.prompt.run(
{ prompt = "Rename this tag: " },
mypromptbox[mouse.screen].widget,
function(newname)
myrc.tagman.rename(awful.tag.selected(),newname)
end,
awful.completion.bash,
awful.util.getdir("cache") .. "/tag_rename")
end},
{{}, "c", "Create new tag", function ()
awful.prompt.run(
{ prompt = "Create new tag: " },
mypromptbox[mouse.screen].widget,
function(newname)
local t = myrc.tagman.add(newname)
myrc.tagman.move(t, myrc.tagman.next_to(awful.tag.selected()))
end,
awful.completion.bash,
awful.util.getdir("cache") .. "/tag_new")
end},
{{}, "d", "Delete current tag", function ()
local sel = awful.tag.selected()
local def = myrc.tagman.prev_to(sel)
myrc.tagman.del(sel,def)
awful.tag.viewonly(def)
end},
{{}, "k", "Move tag right", function ()
local sel = awful.tag.selected()
local tgt = myrc.tagman.next_to(sel)
myrc.tagman.move(sel,tgt)
return false
end},
{{}, "j", "Move tag left", function ()
local sel = awful.tag.selected()
local tgt = myrc.tagman.prev_to(sel)
myrc.tagman.move(sel,tgt)
return false
end}
}
end
-- Bind keyboard digits
globalkeys = awful.util.table.join(
-- Main menu
awful.key({ altkey }, "Escape", function()
menu_current(mymainmenu,mainmenu_args)
end),
-- Awesome control
awful.key({ modkey, "Control" }, "q", awesome.quit),
awful.key({ modkey, "Control" }, "r", function()
mypromptbox[mouse.screen].widget.text = awful.util.escape(awful.util.restart())
end),
-- Application hotkeys
awful.key({ modkey }, "b", function () awful.util.spawn(env.browser) end),
awful.key({ modkey }, "e", function () awful.util.spawn(env.screen) end),
awful.key({ }, "Scroll_Lock", function () awful.util.spawn(env.locker) end),
awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
awful.key({ modkey, }, "m", function () run_or_raise("gmpc", { class = "Gmpc" }) end),
awful.key({ modkey }, "p", function () awful.util.spawn("pidgin") end),
awful.key({ modkey }, "c", function () run_or_raise("xterm -e calc", { class="XTerm", name = "calc" }) end),
-- Tag hotkeys
awful.key({ modkey, "Control" }, "m", function () toggle_tag("im") end),
awful.key({ modkey, "Control" }, "w", function () toggle_tag("work") end),
awful.key({ modkey, "Control" }, "n", function () toggle_tag("net") end),
awful.key({ modkey, "Control" }, "f", function () toggle_tag("fun") end),
awful.key({ modkey, "Control" }, "e", function () toggle_tag("sys") end),
awful.key({ modkey }, "Tab", function() awful.tag.history.restore() end),
-- Client manipulation
awful.key({ altkey }, "j", function () switch_to_client(-1) end),
awful.key({ altkey }, "k", function () switch_to_client(1) end),
awful.key({ altkey }, "1", function () switch_to_client(-1) end),
awful.key({ altkey }, "2", function () switch_to_client(1) end),
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(1) end),
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx(-1) end),
awful.key({ altkey }, "Tab", function() switch_to_client(0) end),
-- Layout manipulation
awful.key({ altkey, }, "F1", awful.tag.viewprev ),
awful.key({ altkey, }, "F2", awful.tag.viewnext ),
awful.key({ altkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
awful.key({ altkey, }, "l", function () awful.tag.incmwfact(0.05) end),
awful.key({ altkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end),
awful.key({ altkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
awful.key({ altkey, "Control" }, "h", function () awful.tag.incncol(1) end),
awful.key({ altkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
awful.key({ altkey, }, "e", function ()
myrc.keybind.push_menu(chord_mpd(), chord_menu_args)
end),
-- Tagset operations (Win+Ctrl+s,<letter> chords)
awful.key({ altkey, }, "F3", function ()
myrc.keybind.push_menu(chord_tags(), chord_menu_args)
end)
)
root.keys(globalkeys)
clientkeys = awful.util.table.join(
awful.key({ modkey }, "F1", function (c)
local tag = myrc.tagman.getn(-1)
awful.client.movetotag(tag, c)
awful.tag.viewonly(tag)
c:raise()
end),
awful.key({ modkey }, "F2", function (c)
local tag = myrc.tagman.getn(1)
awful.client.movetotag(tag, c)
awful.tag.viewonly(tag)
c:raise()
end),
awful.key({ altkey }, "F4", function (c)
c:kill()
end),
awful.key({ altkey }, "F5", function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
end),
awful.key({ altkey }, "F6", function (c)
dbg_client(c)
end),
-- Client keys
awful.key({ altkey , }, "3", function(c)
local menu = client_contex_menu(c)
menu_current(menu, contextmenu_args)
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)
)
--}}}
-- {{{ Hooks
-- Hook function to execute when focusing a client.
client.add_signal("focus", function (c)
c.border_color = beautiful.border_focus
end)
-- Hook function to execute when unfocusing a client.
client.add_signal("unfocus", function (c)
c.border_color = beautiful.border_normal
end)
-- Hook function to execute when a new client appears.
client.add_signal("manage", function (c, startup)
-- TODO: Handle menu closing on mouse movements
-- c:add_signal("mouse::enter", function(c)
-- function kill_mousemode_menu(m)
-- if m and (true ~= m.keygrabber) then m:hide() end
-- end
-- kill_mousemode_menu(mymainmenu)
-- kill_mousemode_menu(mycontextmenu)
-- end)
c:add_signal("mouse::enter", function(c)
menu_hide()
end)
c:add_signal("property::floating", function(c)
c.border_width = get_layout_border(c)
end)
local name = client_name(c)
if c.type == "dialog" then
save_snap(c, 'center')
end
local tag = get_tag(c, nil)
if tag ~= nil then