forked from Elv13/awesome-configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc.lua
632 lines (555 loc) · 22.6 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
-- Gears
local gears = require( "gears" )
local cairo = require( "lgi" ).cairo
local color = require( "gears.color" )
local glib = require( "lgi" ).GLib
local config = require( "forgotten" )
local utils = require( "utils" )
require("retrograde")
-- Awful
local awful = require( "awful" )
awful.rules = require( "awful.rules" )
local wibox = require( "wibox" )
local tyrannical = require( "tyrannical" )
require("awful.autofocus")
-- Shortcuts
require( "tyrannical.shortcut" )
require( "repetitive" )
local shorter = require( "shorter" )
-- Theme handling library
local beautiful = require( "beautiful" )
local blind = require( "blind" )
-- Widgets
local chopped = require( "chopped" )
local menubar = require( "menubar" )
local customButton = require( "customButton" )
local customMenu = require( "customMenu" )
local drawer = require( "drawer" )
local widgets = require( "widgets" )
local radical = require( "radical" )
local rad_task = require( "radical.impl.tasklist" )
local rad_taglist = require( "radical.impl.taglist" )
local collision = require( "collision" )
local alttab = require( "radical.impl.alttab" )
local rad_client = require( "radical.impl.common.client" )
local rad_tag = require( "radical.impl.common.tag" )
-- Data sources
local naughty = require( "naughty" )
local notifications = require( "extern.notifications" )
local vicious = require( "extern.vicious" )
-- local wirefu = require( "wirefu.demo.notification" )
-- Hardware
local wacky = require("wacky")
-- utils.profile.start()
-- debug.sethook(utils.profile.trace, "crl", 1)
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
-- }}}
vicious.cache( vicious.widgets.net )
vicious.cache( vicious.widgets.fs )
vicious.cache( vicious.widgets.dio )
vicious.cache( vicious.widgets.cpu )
vicious.cache( vicious.widgets.mem )
vicious.cache( vicious.widgets.dio )
-- Various configuration options
config.showTitleBar = false
config.themeName = "arrow"
config.noNotifyPopup = true
config.useListPrefix = true
config.deviceOnDesk = true
config.desktopIcon = true
config.advTermTB = true
config.scriptPath = awful.util.getdir("config") .. "/Scripts/"
config.scr = {
pri = 1,
sec = 3,
music = 4,
irc = 2,
media = 5,
}
-- Load the theme
config.load()
config.themePath = awful.util.getdir("config") .. "/blind/" .. config.themeName .. "/"
config.iconPath = config.themePath .. "Icon/"
beautiful.init(config.themePath .. "/themeZilla.lua")
-- This is used later as the default terminal and editor to run.
local titlebars_enabled = beautiful.titlebar_enabled == nil and true or beautiful.titlebar_enabled
terminal = "xterm"
editor = os.getenv("EDITOR") or "nano"
editor_cmd = terminal .. " -e " .. editor
-- Default modkey.
modkey = "Mod4"
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 ,
}
local layouts_all =
{
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 ,
}
-- Add Collision shortcuts
collision()
movetagL,movetagR = {}, {}
dofile(awful.util.getdir("config") .. "/baseRule.lua")
-- Create the "Show Desktop" icon
local desktopPix = customButton.showDesktop ( nil )
-- Create the clock
local clock = drawer.dateInfo ( nil )
-- clock.bg = beautiful.bar_bg_alternate or beautiful.bg_alternate
-- Create the volume box
local soundWidget = drawer.soundInfo ( 300 )
-- Create the net manager
local netinfo = drawer.netInfo ( 300 )
-- Create the memory manager
local meminfo = drawer.memInfo ( 300 )
-- Create the cpu manager
local cpuinfo = drawer.cpuInfo ( 300 )
-- Create the laucher dock
--local lauchDock = widgets.dock ( nil , {position="left",default_cats={"Tools","Development","Network","Player"}})
-- Create battery
local bat = widgets.battery()
-- Create notifications history
local notif = notifications()
-- Create keyboard layout manager
local keyboard = widgets.keyboard()
-- Create the addTag icon (depend on shifty rule)
local addTag = customButton.addTag ( nil )
-- Create some separators
local endArrow = chopped.get_separator {
weight = chopped.weight.FULL ,
direction = chopped.direction.RIGHT ,
sep_color = nil ,
left_color = beautiful.separator_color or beautiful.icon_grad ,
right_color = nil ,
}
local endArrow_alt2 = chopped.get_separator {
weight = chopped.weight.THIN ,
direction = chopped.direction.RIGHT ,
sep_color = beautiful.separator_color or beautiful.icon_grad or beautiful.fg_normal,
left_color = beautiful.bar_bg_alternate or beautiful.bg_alternate ,
right_color = nil ,
}
local endArrowR = chopped.get_separator {
weight = chopped.weight.THIN ,
direction = chopped.direction.LEFT ,
sep_color = beautiful.separator_color or beautiful.icon_grad or beautiful.fg_normal,
left_color = nil ,
right_color = beautiful.bar_bg_alternate or beautiful.bg_alternate ,
}
local arr_last_tag_w = chopped.get_separator {
weight = chopped.weight.THIN ,
direction = chopped.direction.RIGHT ,
sep_color = beautiful.separator_color or beautiful.icon_grad or beautiful.fg_normal,
left_color = nil ,
right_color = beautiful.bar_bg_alternate or beautiful.bg_alternate ,
margin = -beautiful.default_height/2
}
local endArrow2 = chopped.get_separator {
weight = chopped.weight.FULL ,
direction = chopped.direction.LEFT ,
sep_color = nil ,
left_color = nil ,
right_color = beautiful.separator_color or beautiful.icon_grad or beautiful.fg_normal,
}
local spacer_img = chopped.get_separator {
weight = chopped.weight.THIN ,
direction = chopped.direction.LEFT ,
sep_color = beautiful.separator_color or beautiful.icon_grad or beautiful.fg_normal,
left_color = nil ,
right_color = nil ,
}
local sep_end_menu = chopped.get_separator {
weight = chopped.weight.FULL ,
direction = chopped.direction.RIGHT ,
sep_color = nil ,
left_color = nil ,
right_color = beautiful.separator_color or beautiful.icon_grad or beautiful.fg_normal,
margin = -beautiful.default_height/2
}
local spacer5 = widgets.spacer({text = " ",width=5})
-- Imitate the Gnome 2 menubar
--
--[[
--
--
--
--
--
local bar_menu,bar_menu_w = radical.bar{
item_style = beautiful.bottom_menu_item_style or radical.item.style.arrow_prefix,
fg = beautiful.fg_normal,
fg_focus = beautiful.menu_fg_normal,
bg = beautiful.bottom_menu_bg,
disable_submenu_icon = true,
style = beautiful.bottom_menu_style,
spacing = beautiful.bottom_menu_spacing,
default_item_margins = beautiful.bottom_menu_default_item_margins,
default_margins = beautiful.bottom_menu_default_margins,
-- item_border_color = "#ff0000",
border_width = 2,
icon_transformation = beautiful.bottom_menu_icon_transformation or function(icon,data,item)
return gears.color.apply_mask(icon,beautiful.button_bg_normal or beautiful.bg_normal)
end,
}
bar_menu:add_colors_namespace("bottom_menu")
local app_menu = nil
local it = bar_menu:add_item {
text = "Apps",
icon = beautiful.awesome_icon,
tooltip = "Application menu",
bg_used = beautiful.bar_bg_buttons or beautiful.menu_bg_normal,
spacing = 8,
sub_menu = function()
if not app_menu then
app_menu = customMenu.appmenu (
{ -- Main menu
filter = true,
show_filter = true,
max_items = 20,
style = radical.style.classic,
item_style = radical.item.style.classic
}
,{ -- Sub menus
max_items = 20,
style = radical.style.classic,
item_style = radical.item.style.classic
})
end
return app_menu
end
}
it.state[radical.base.item_flags.USED] = true
it = bar_menu:add_item {
text = "Places",
icon = config.iconPath .. "tags/home.png",
tooltip = "Folder shortcuts",
sub_menu = customMenu.places.get_menu,
bg_used = beautiful.bar_bg_buttons or beautiful.menu_bg_normal,
}
it.state[radical.base.item_flags.USED] = true
it = bar_menu:add_item {text="Launch",
icon = config.iconPath .. "gearA.png",
tooltip = "Execute a command",
sub_menu = customMenu.launcher.get_menu,
bg_used = beautiful.bar_bg_buttons or beautiful.menu_bg_normal,
}
it.state[radical.base.item_flags.USED] = true
--
--
--
--
--
--
--]]
rad_taglist.taglist_watch_name_changes = true
-- Load the desktop "conky" widget
-- widgets.desktopMonitor(screen.count() == 1 and 1 or 2)
-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it
-- }}}
alttab.default_icon = config.iconPath .. "tags/other.png"
alttab.titlebar_path = config.themePath.. "Icon/titlebar/"
-- Create a wibox for each screen and add it
mypromptbox = {}
local wibox_top = {}
local wibox_bot = {}
local mytaglist = {}
local layoutmenu = {}
local delTag = {}
local lockTag = {}
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt()
-- Create the delTag button
delTag[s] = customButton.delTag ( s )
lockTag[s] = customButton.lockTag ( s )
-- Create the button to move a tag the next screen
movetagL[s] = customButton.tagmover(s,{ direction = "left", icon = config.iconPath .. "tags/screen_left.png" })
movetagR[s] = customButton.tagmover(s,{ direction = "right", icon = config.iconPath .. "tags/screen_right.png" })
-- Create the layout menu for this screen
layoutmenu[s] = customMenu.layoutmenu ( s,layouts_all )
-- Create the wibox
wibox_top[s] = awful.wibox({ position = "top" , ontop=false,screen = s,height=beautiful.default_height , bg = beautiful.bar_bg_normal or beautiful.bg_normal })
wibox_bot[s] = awful.wibox({ position = "bottom", ontop=false,screen = s,height=beautiful.default_height , bg = beautiful.bar_bg_normal or beautiful.bg_normal })
-- Create the tag control menu
local tag_control,tag_control_w = radical.bar{
item_style = beautiful.toolbox_item_style or radical.item.style.rounded,
item_layout = radical.item.layout.icon,
icon_transformation = beautiful.toolbox_icon_transformation,
icon_per_state = beautiful.toolbox_icon_per_state,
style = beautiful.toolbox_style,
default_item_margins = beautiful.toolbox_default_item_margins or {
LEFT = 0,
RIGHT = 0,
TOP = 0,
BOTTOM = 0,
},
default_margins = beautiful.toolbox_default_margins or {
TOP = 0,
BOTTOM = 0,
RIGHT = 5,
LEFT = 5,
}
}
tag_control:add_colors_namespace("toolbox")
-- tag_control:add_widgets {
-- addTag ,
-- delTag [s],
-- lockTag [s],
-- movetagL [s],
-- movetagR [s],
-- layoutmenu [s],
-- }
tag_control:add_items {
{icon = config.iconPath .. "tags/screen_left.png" , tooltip = "Move tag to the previous screen" },
{icon = config.iconPath .. "tags/screen_right.png" , tooltip = "Move tag to the next screen"},
{icon = config.iconPath .. "tags/cross2.png" , tooltip = "Add a new tag", button1=function()
awful.tag.viewonly(awful.tag.add("NewTag",{screen= (client.focus and client.focus.screen or mouse.screen) }))
end},
{icon = config.iconPath .. "tags/minus2.png" , tooltip = "Delete the current tag", button1=function()
awful.tag.delete(client.focus and awful.tag.selected(client.focus.screen) or awful.tag.selected(mouse.screen) )
end},
-- {icon = config.iconPath .. "layouts_small/spiral_d.png" , },
}
rad_tag.layout_item(tag_control,{screen=s,tooltip="Change layout"})
-- Top Wibox
wibox_top[s]:set_widgets {
{ --Left
rad_taglist(s)._internal.margin, --Taglist
{ -- Tag control buttons
{
{
arr_last_tag_w,
tag_control_w,
layout = wibox.layout.fixed.horizontal
},
layout = wibox.layout.margin(nil,1,4,0,0)
},
layout = wibox.widget.background(nil,beautiful.bar_bg_alternate or beautiful.bg_alternate)
}, --Buttons
endArrow_alt2 , --Separator
layout = wibox.layout.fixed.horizontal
},
nil, --Center
(s == config.scr.pri or s == config.scr.sec) and { -- Right, first screen only
endArrowR,
{ -- The background
{ -- The widgets
spacer5 ,
cpuinfo ,
spacer_img ,
meminfo ,
spacer_img ,
netinfo ,
spacer_img ,
soundWidget,
spacer_img ,
clock ,
},
layout = wibox.widget.background(nil,beautiful.bar_bg_alternate or beautiful.bg_alternate)
},
layout = wibox.layout.fixed.horizontal
} or nil,
layout = wibox.layout.align.horizontal
}
-- Bottom Wibox
wibox_bot[s]:set_widgets {
{ --Left
bar_menu_w ,
{
mypromptbox[s] ,
layout = wibox.widget.background(nil,beautiful.systray_icon_fg or beautiful.icon_grad)
},
sep_end_menu ,
desktopPix ,
endArrow ,
layout = wibox.layout.fixed.horizontal,
},
rad_task(s or 1)._internal.margin, --Center
{
endArrow2 ,
{ -- Right
{
spacer5 ,
keyboard ,
notif ,
bat ,
spacer5 ,
s == 1 and wibox.widget.systray(),
},
layout = wibox.widget.background(nil,beautiful.systray_bg_alt or beautiful.icon_grad or beautiful.fg_normal),
},
},
layout = wibox.layout.align.horizontal
}
end
-- Add the drives list on the desktop
-- if config.deviceOnDesk == true then
-- widgets.devices()
-- end
-- if config.desktopIcon == true then
-- for i=1,20 do
-- widgets.desktopIcon()
-- end
-- end
-- Add keyboard shortcuts
dofile(awful.util.getdir("config") .. "/shortcuts.lua")
-- {{{ Rules
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
keys = clientkeys,
buttons = clientbuttons } },
{ rule = { class = "Conky" },
properties = { border_width = 0,
border_color = beautiful.border_normal,} },
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup)
-- 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)
--Fix some wierd reload bugs
if c.size_hints.user_size and startup then
c:geometry({width = c.size_hints.user_size.width,height = c.size_hints.user_size.height, x = c:geometry().x})
end
if c.size_hints.max_height and c.size_hints.max_height < screen[c.screen].geometry.height/2 then
awful.client.setslave(c)
end
if not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
widgets.titlebar(c)
end
end)
client.connect_signal("tagged",function(c)
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
local tb = awful.titlebar(c,{size=beautiful.titlebar_height or 16})
if tb and tb.title_wdg then
local underlays = {}
for k,v in ipairs(c:tags()) do
underlays[#underlays+1] = v.name
end
tb.title_wdg:set_underlay(underlays,{style=radical.widgets.underlay.draw_arrow,alpha=1,color="#0C2853"})
end
end
end)
client.connect_signal("focus", function(c)
local tb = c:titlebar_top()
if tb and tb.title_wdg then
tb.title_wdg.data.image = beautiful.taglist_bg_image_selected
end
if not c.class == "URxvt" then
c.border_color = beautiful.border_focus
end
end)
client.connect_signal("unfocus", function(c)
local tb = c:titlebar_top()
if tb and tb.title_wdg then
tb.title_wdg.data.image = beautiful.tasklist_bg_image_selected or beautiful.taglist_bg_image_used
end
if not c.class == "URxvt" then
c.border_color = beautiful.border_normal
end
end)
-- When setting a client as "slave", use the first available slot instead of the last
awful.client._setslave = awful.client.setslave
function awful.client.setslave(c)
local t = awful.tag.selected(c.screen)
local nmaster = awful.tag.getnmaster(t) or 1
local cls = awful.client.tiled(c.screen) or client.get(c.screen)
local index = awful.util.table.hasitem(cls,c)
if index and index <= nmaster and #cls > nmaster then
c:swap(cls[nmaster+1])
else
awful.client._setslave(c)
end
end
require("radical.impl.tasklist.extensions").add("Running time",function(client)
local w = wibox.widget.base.make_widget()
w.fit = function(_,w,h)
return radical.widgets.underlay.fit("foo",{bg="#ff0000"}),h
end
w.draw = function(self, w, cr, width, height)
cr:set_source_surface(radical.widgets.underlay.draw("foo",{bg=beautiful.fg_normal,height=beautiful.default_height}))
cr:paint()
end
return w
end)
require("radical.impl.tasklist.extensions").add("Machine",function(client)
local w = wibox.widget.base.make_widget()
w.fit = function(_,w,h)
return radical.widgets.underlay.fit(client.machine,{bg="#ff0000"}),h
end
w.draw = function(self, w, cr, width, height)
cr:set_source_surface(radical.widgets.underlay.draw(client.machine,{bg=beautiful.fg_normal,height=beautiful.default_height}))
cr:paint()
end
return w
end)
require("radical.impl.taglist.extensions").add("Count",function(client)
local w = wibox.widget.base.make_widget()
w.fit = function(_,w,h)
return radical.widgets.underlay.fit("12",{bg="#ff0000"}),h
end
w.draw = function(self, w, cr, width, height)
cr:set_source_surface(radical.widgets.underlay.draw("12",{bg=beautiful.fg_normal,height=beautiful.default_height}))
cr:paint()
end
return w
end)
shorter.register_section("TYRANNICAL",{
foo = "bar",
bar = "foo"
})
shorter.register_section_text("REPETITIVE","gdfgdfgdfg dsfhg jsdghjsdf gdsfhj gdhj gjgj gjdf ghdjfh gjgdjgdjhg d dhjfg dhfjg dhfj gdhfgj sdhj fg")
-- require("wirefu.demo.notification")