-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.lua
More file actions
36 lines (29 loc) · 805 Bytes
/
Copy pathwidget.lua
File metadata and controls
36 lines (29 loc) · 805 Bytes
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
-- Minimal stateful widget: left-click toggles its local state.
local enabled = false
local widget
--- Renders the icon and label from the widget's current enabled state.
local function render()
local color = enabled and easybar.theme.ref.success or easybar.theme.ref.muted
widget:set({
icon = {
string = enabled and "●" or "○",
color = color,
},
label = {
string = enabled and "Enabled" or "Disabled",
color = color,
},
})
end
widget = easybar.add(easybar.kind.item, "example_widget", {
position = "right",
order = 50,
})
widget:subscribe(easybar.events.forced, render)
widget:subscribe(easybar.events.mouse.clicked, function(event)
if event.button == nil or event.button == easybar.events.mouse.left_button then
enabled = not enabled
render()
end
end)
render()