-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspacer.lua
executable file
·77 lines (66 loc) · 1.87 KB
/
spacer.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
--[[
____
/ ___| _ __ __ _ ___ ___ _ __
\___ \| '_ \ / _` |/ __/ _ \ '__| - Simple separator widget for awesome wm
___) | |_) | (_| | (_| __/ | - https://github.com/cherrynoize/ctrl
|____/| .__/ \__,_|\___\___|_| - cherry-noize
|_|
]]--
-- Module imports
local awful = require "awful"
local wibox = require "wibox"
-- Import Ctrl modules
local config = require "ctrl.config"
-- Initialize separator variable and id
local sep = {}
sep.id = 1
sep.arator = wibox.widget {
markup = config.spacectl_markup,
align = config.spacectl_align,
opacity = config.spacectl_opacity,
left = config.spacectl_margin_left,
right = config.spacectl_margin_right,
top = config.spacectl_margin_top,
bottom = config.spacectl_margin_bottom,
widget = wibox.widget.textbox
}
function sep.switch(by)
if config.sep_list[sep.id + by] then
sep.id = sep.id + by
else
if sep.id > 1 then
sep.id = 1
else
sep.id = #config.sep_list
end
end
sep.update()
end
function sep.forward() sep.switch(1) end
function sep.back() sep.switch(-1) end
function sep.key(mod, key, f)
if config.dynamic_sep then
if not mod then mod = {modkey, "Control", "Shift"} end
if not key then key = "s" end
if f then
return awful.key(mod, key, function() f() end)
else
return sep.forward
end
end
end
function sep.update()
sep.arator:set_markup_silently("<span color='" .. config.spacectl_fg_color .. "'>" .. config.spacectl_prefix .. config.sep_list[sep.id] .. config.spacectl_suffix .. "</span>")
end
if config.dynamic_sep then
-- Mouse click events
sep.arator:buttons(awful.util.table.join(
awful.button({ }, 1, sep.forward),
awful.button({ }, 3, sep.back),
awful.button({ }, 5, sep.back),
awful.button({ }, 4, sep.forward)
))
end
-- Initialize widget
sep.update()
return sep