-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaglist.lua
157 lines (143 loc) · 4.71 KB
/
taglist.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
local awful = require("awful")
local gears = require("gears")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local wibox = require("wibox")
local function colorize_text(text, color)
return "<span foreground='" .. color .."'>" .. text .. "</span>"
end
local ntags = 9
local function taglist(s)
-- Create textboxes and set their buttons
local tag_text = {}
for i = 1, ntags do
table.insert(tag_text, wibox.widget.textbox())
tag_text[i]:buttons(
gears.table.join(
-- Left click - Tag back and forth
awful.button({ }, 1, function ()
local current_tag = s.selected_tag
local clicked_tag = s.tags[i]
if clicked_tag == current_tag then
awful.tag.history.restore()
else
clicked_tag:view_only()
end
end),
-- Right click - Move focused client to tag
awful.button({ }, 3, function ()
local clicked_tag = s.tags[i]
if client.focus then
client.focus:move_to_tag(clicked_tag)
end
end)
))
tag_text[i].font = beautiful.taglist_text_font
-- So that glyphs of different width always take up the same space in the taglist
tag_text[i].forced_width = dpi(25)
tag_text[i].align = "center"
tag_text[i].valign = "center"
end
local text_taglist = wibox.widget{
tag_text[1],
tag_text[2],
tag_text[3],
tag_text[4],
tag_text[5],
tag_text[6],
tag_text[7],
tag_text[8],
tag_text[9],
layout = wibox.layout.fixed.horizontal
}
text_taglist:buttons(
gears.table.join(
-- Middle click - Show clients in current tag
awful.button({ }, 2, function ()
awful.spawn.with_shell("rofi -show combi")
end),
-- Scroll - Cycle through tags
awful.button({ }, 4, function ()
awful.tag.viewprev()
end),
awful.button({ }, 5, function ()
awful.tag.viewnext()
end)
))
-- Shorter names (eg. tf = text_focused) to save space
local tf, tu, to, te, cf, cu, co, ce;
-- Set fallback values if needed
if beautiful.taglist_text_focused then
tf = beautiful.taglist_text_focused
tu = beautiful.taglist_text_urgent
to = beautiful.taglist_text_occupied
te = beautiful.taglist_text_empty
cf = beautiful.taglist_text_color_focused
cu = beautiful.taglist_text_color_urgent
co = beautiful.taglist_text_color_occupied
ce = beautiful.taglist_text_color_empty
else
-- Fallback values
tf = {"1", "2", "3", "4", "5", "6", "7", "8", "9"}
tu = tf
to = tf
te = tf
local ff = beautiful.fg_focus
local fu = beautiful.fg_urgent
local fo = beautiful.fg_normal
local fe = beautiful.fg_minimize
cf = {ff, ff, ff, ff, ff, ff, ff, ff, ff, ff}
cu = {fu, fu, fu, fu, fu, fu, fu, fu, fu, fu}
co = {fo, fo, fo, fo, fo, fo, fo, fo, fo, fo}
ce = {fe, fe, fe, fe, fe, fe, fe, fe, fe, fe}
end
local function update_widget()
for i = 1, ntags do
local tag_clients
if s.tags[i] then
tag_clients = s.tags[i]:clients()
end
if s.tags[i] and s.tags[i].selected then
tag_text[i].markup = colorize_text(tf[i], cf[i])
elseif s.tags[i] and s.tags[i].urgent then
tag_text[i].markup = colorize_text(tu[i], cu[i])
elseif tag_clients and #tag_clients > 0 then
tag_text[i].markup = colorize_text(to[i], co[i])
else
tag_text[i].markup = colorize_text(te[i], ce[i])
end
end
end
client.connect_signal("unmanage", function(c)
update_widget()
end)
client.connect_signal("untagged", function(c)
update_widget()
end)
client.connect_signal("tagged", function(c)
update_widget()
end)
client.connect_signal("screen", function(c)
update_widget()
end)
awful.tag.attached_connect_signal(s, "property::selected", function ()
update_widget()
end)
awful.tag.attached_connect_signal(s, "property::hide", function ()
update_widget()
end)
awful.tag.attached_connect_signal(s, "property::activated", function ()
update_widget()
end)
awful.tag.attached_connect_signal(s, "property::screen", function ()
update_widget()
end)
awful.tag.attached_connect_signal(s, "property::index", function ()
update_widget()
end)
awful.tag.attached_connect_signal(s, "property::urgent", function ()
update_widget()
end)
return text_taglist
end
return taglist