aboutsummaryrefslogtreecommitdiff
path: root/config.dot/awesome.link/widgets.lua
blob: 7cea6fda89202b71aa0380c24113c518d986683d (plain)
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
-- {{{ Misc widgets
dofile(configdir .. "/widgets/leds.lua")
dofile(configdir .. "/widgets/volume.lua")

if awful.util.file_readable(homedir .. "/.custom/awesome/awesompd.lua") then
  awesompd = true
  dofile(configdir .. "/widgets/awesompd.lua")
end
-- }}}

--{{---| Text clock widget |------------------------------------------------------------------------------

mytextclock = awful.widget.textclock({ align = "right" })

--{{---| Systray widget |------------------------------------------------------------------------------

mysystray = widget({ type = "systray" })

--{{---| Chat widget |------------------------------------------------------------------------------

chaticon       = widget ({type = "imagebox" })
chaticon.image = image(beautiful.widget_chat)
chaticon:buttons(awful.util.table.join(awful.button({ }, 1,
function () awful.util.spawn_with_shell(chat) end)))

--{{---| Mail widget |------------------------------------------------------------------------------

mailicon = widget ({type = "imagebox" })
mailicon.image = image(beautiful.widget_mail)
mailicon:buttons(awful.util.table.join(awful.button({ }, 1, 
function () awful.util.spawn_with_shell(mailmutt) end)))

--{{---| Music widget |-----------------------------------------------------------------------------

music       = widget ({type = "imagebox" })
music.image = image(beautiful.widget_music)
music:buttons(awful.util.table.join(
  awful.button({        }, 1, function () awful.util.spawn_with_shell(musicplr) end),
  awful.button({ modkey }, 1, function () awful.util.spawn_with_shell("ncmpcpp toggle") end),
  awful.button({        }, 3, function () couth.notifier:notify( couth.alsa:setVolume('Master','toggle')) end),
  awful.button({        }, 4, function () couth.notifier:notify( couth.alsa:setVolume('PCM','2dB+'))      end),
  awful.button({        }, 5, function () couth.notifier:notify( couth.alsa:setVolume('PCM','2dB-'))      end),
  awful.button({        }, 4, function () couth.notifier:notify( couth.alsa:setVolume('Master','2dB+'))   end),
  awful.button({        }, 5, function () couth.notifier:notify( couth.alsa:setVolume('Master','2dB-'))   end)))

--{{---| TaskWarrior widget |-----------------------------------------------------------------------

--task_warrior = blingbling.task_warrior.new(beautiful.widget_task)
--task_warrior:set_task_done_icon(beautiful.task_done_icon)
--task_warrior:set_task_icon(beautiful.task_icon)
--task_warrior:set_project_icon(beautiful.project_icon)

--{{---| MEM widget |-------------------------------------------------------------------------------

memwidget = widget({ type = "textbox" })
vicious.register(memwidget, vicious.widgets.mem, '<span background="#777E76" font="Terminus 12"> <span font="Terminus 9" color="#EEEEEE" background="#777E76">$2MB </span></span>', 13)
memicon = widget ({type = "imagebox" })
memicon.image = image(beautiful.widget_mem)

--{{---| CPU / sensors widget |---------------------------------------------------------------------

--cpuwidget = widget({ type = "textbox" })
--vicious.register(cpuwidget, vicious.widgets.cpu,
--'<span background="#4B696D" font="Terminus 12"> <span font="Terminus 9" color="#DDDDDD">$2% <span color="#888888">·</span> $3% </span></span>', 3)
--cpuicon = widget ({type = "imagebox" })
--cpuicon.image = image(beautiful.widget_cpu)
--sensors = widget({ type = "textbox" })
--vicious.register(sensors, vicious.widgets.sensors)
--tempicon = widget ({type = "imagebox" })
--tempicon.image = image(beautiful.widget_temp)
--blingbling.popups.htop(cpuwidget,
--{ title_color = beautiful.notify_font_color_1, 
--user_color = beautiful.notify_font_color_2, 
--root_color = beautiful.notify_font_color_3, 
--terminal   = "terminal --geometry=130x56-10+26"})

--{{---| FS's widget / udisks-glue menu |-----------------------------------------------------------

--fswidget = widget({ type = "textbox" })
--vicious.register(fswidget, vicious.widgets.fs,
--'<span background="#D0785D" font="Terminus 12"> <span font="Terminus 9" color="#EEEEEE">${/mnt/storage avail_gb}GB </span></span>', 8)
--udisks_glue = blingbling.udisks_glue.new(beautiful.widget_hdd)
--udisks_glue:set_mount_icon(beautiful.accept)
--udisks_glue:set_umount_icon(beautiful.cancel)
--udisks_glue:set_detach_icon(beautiful.cancel)
--udisks_glue:set_Usb_icon(beautiful.usb)
--udisks_glue:set_Cdrom_icon(beautiful.cdrom)
--awful.widget.layout.margins[udisks_glue.widget] = { top = 0}
--udisks_glue.widget.resize = false

--{{---| Battery widget |---------------------------------------------------------------------------  

baticon       = widget ({type = "imagebox" })
baticon.image = image(beautiful.widget_battery)
batwidget     = widget({ type = "textbox" })
vicious.register( batwidget, vicious.widgets.bat, '<span background="#92B0A0" font="Terminus 12"> <span font="Terminus 9" color="#FFFFFF" background="#92B0A0">$1$2% </span></span>', 1, "BAT0" )

--{{---| Net widget |-------------------------------------------------------------------------------

netwidget = widget({ type = "textbox" })
vicious.register(netwidget, 
vicious.widgets.net,
'<span background="#C2C2A4" font="Terminus 12"> <span font="Terminus 9" color="#FFFFFF">${eth0 down_kb} ↓↑ ${eth0 up_kb}</span> </span>', 3)
neticon       = widget ({type = "imagebox" })
neticon.image = image(beautiful.widget_net)
netwidget:buttons(awful.util.table.join(awful.button({ }, 1,
function () awful.util.spawn_with_shell(iptraf) end)))

--{{---| Normal clock |-------------------------------------------------------------------------------

clockwidget = widget({ type = "textbox" })
vicious.register(clockwidget, vicious.widgets.date,
'<span background="#777e76" font="Terminus 12"> <span font="Terminus 9" color="#FFFFFF">%d/%m/%Y %H:%M</span> </span>', 3)

--{{---| Binary Clock |-----------------------------------------------------------------------------

binaryclock                = {}
binaryclock.widget         = widget({type = "imagebox"})
binaryclock.w              = 42
binaryclock.h              = 16
binaryclock.show_sec       = true
binaryclock.color_active   = beautiful.binclock_fga
binaryclock.color_bg       = beautiful.binclock_bg
binaryclock.color_inactive = beautiful.binclock_fgi
binaryclock.dotsize        = math.floor(binaryclock.h / 5)
binaryclock.step           = math.floor(binaryclock.dotsize / 3)
binaryclock.widget.image   = image.argb32(binaryclock.w, binaryclock.h, nil)
if (binaryclock.show_sec) then binaryclock.timeout = 1 else binaryclock.timeout = 20 end 
binaryclock.DEC_BIN = function(IN) 
local B,K,OUT,I,D=2,"01","",0
while IN>0 do
I=I+1
IN,D=math.floor(IN/B),math.mod(IN,B)+1
OUT=string.sub(K,D,D)..OUT
end
return OUT
end
binaryclock.paintdot = function(val,shift,limit) 
local binval = binaryclock.DEC_BIN(val)
local l = string.len(binval)
local height = 0 
if (l < limit) then
for i=1,limit - l do binval = "0" .. binval end
end
for i=0,limit-1 do
if (string.sub(binval,limit-i,limit-i) == "1") then
binaryclock.widget.image:draw_rectangle(shift,
binaryclock.h - binaryclock.dotsize - height, 
binaryclock.dotsize, binaryclock.dotsize, true, binaryclock.color_active)
else
binaryclock.widget.image:draw_rectangle(shift,
binaryclock.h - binaryclock.dotsize - height, 
binaryclock.dotsize,binaryclock.dotsize, true, binaryclock.color_inactive)
end
height = height + binaryclock.dotsize + binaryclock.step
end
end
binaryclock.drawclock = function ()
binaryclock.widget.image:draw_rectangle(0, 0, binaryclock.w, binaryclock.h, true, binaryclock.color_bg)
local t = os.date("*t")
local hour = t.hour
if (string.len(hour) == 1) then
hour = "0" .. t.hour
end
local min = t.min
if (string.len(min) == 1) then
min = "0" .. t.min
end
local sec = t.sec
if (string.len(sec) == 1) then
sec = "0" .. t.sec
end
local col_count = 6
if (not binaryclock.show_sec) then col_count = 4 end
local step = math.floor((binaryclock.w - col_count * binaryclock.dotsize) / 8)
binaryclock.paintdot(0 + string.sub(hour, 1, 1), step, 2)
binaryclock.paintdot(0 + string.sub(hour, 2, 2), binaryclock.dotsize + 2 * step, 4)
binaryclock.paintdot(0 + string.sub(min, 1, 1),binaryclock.dotsize * 2 + 4 * step, 3)
binaryclock.paintdot(0 + string.sub(min, 2, 2),binaryclock.dotsize * 3 + 5 * step, 4)
if (binaryclock.show_sec) then
binaryclock.paintdot(0 + string.sub(sec, 1, 1), binaryclock.dotsize * 4 + 7 * step, 3)
binaryclock.paintdot(0 + string.sub(sec, 2, 2), binaryclock.dotsize * 5 + 8 * step, 4)
end
binaryclock.widget.image = binaryclock.widget.image
end
binarytimer = timer { timeout = binaryclock.timeout }
binarytimer:add_signal("timeout", function()
binaryclock.drawclock()
end)
binarytimer:start()

-- binaryclock.widget:buttons(awful.util.table.join(
--   awful.button({ }, 1, function () 
--   end)
-- ))

--{{---| Calendar widget |--------------------------------------------------------------------------

-- my_cal = blingbling.calendar.new({type = "imagebox", image = beautiful.widget_cal})
-- my_cal:set_cell_padding(4)
-- my_cal:set_title_font_size(9)
-- my_cal:set_title_text_color("#4F98C1")
-- my_cal:set_font_size(9)
-- my_cal:set_inter_margin(1)
-- my_cal:set_columns_lines_titles_font_size(8)
-- my_cal:set_columns_lines_titles_text_color("#d4aa00ff")
-- my_cal:set_link_to_external_calendar(true) --{{ <-- popup reminder

--{{---| Separators widgets |-----------------------------------------------------------------------

spr        = widget({ type = "textbox" })
spr.text   = ' '
sprd       = widget({ type = "textbox" })
sprd.text  = '<span background="#313131" font="Terminus 12"> </span>'
spr3f      = widget({ type = "textbox" })
spr3f.text = '<span background="#777e76" font="Terminus 12"> </span>'
arr1       = widget ({type = "imagebox" })
arr1.image = image(beautiful.arr1)
arr2       = widget ({type = "imagebox" })
arr2.image = image(beautiful.arr2)
arr3       = widget ({type = "imagebox" })
arr3.image = image(beautiful.arr3)
arr4       = widget ({type = "imagebox" })
arr4.image = image(beautiful.arr4)
arr5       = widget ({type = "imagebox" })
arr5.image = image(beautiful.arr5)
arr6       = widget ({type = "imagebox" })
arr6.image = image(beautiful.arr6)
arr7       = widget ({type = "imagebox" })
arr7.image = image(beautiful.arr7)
arr8       = widget ({type = "imagebox" })
arr8.image = image(beautiful.arr8)
arr9       = widget ({type = "imagebox" })
arr9.image = image(beautiful.arr9)
arr0       = widget ({type = "imagebox" })
arr0.image = image(beautiful.arr0)