eww: Better workspaces

This commit is contained in:
2024-05-15 23:22:39 +02:00
parent f4b52e2836
commit 6540833edc
3 changed files with 39 additions and 18 deletions

View File

@ -33,7 +33,7 @@
(defwidget bottom []
(box :orientation "v"
:valign "end"
:class "bottom"
:class "bottom"
:space-evenly false
(vpn)
(speaker)
@ -49,11 +49,27 @@
(box :orientation "v"
:valign "start"
:class "workspaces"
:space-evenly: false
(for workspace in workspaces_json
(button :visible {workspace.monitor == monitor} :class 'workspace ${workspace.class}'
(label :text '${workspace.id}'))
)))
:space-evenly: false
; can't use a for loop here because that breaks css animations
(workspace :n 1)
(workspace :n 2)
(workspace :n 3)
(workspace :n 4)
(workspace :n 5)
(workspace :n 6)
(workspace :n 7)
(workspace :n 8)
(workspace :n 9)
(workspace :n 10)
(workspace :n 11)
(workspace :n 12)
))
(defwidget workspace [n]
(button :visible {jq(workspaces, '.["${n}"] != null')}
:class 'workspace ${workspaces[n].class}'
(label :text n))
)
(defwidget speaker []
(eventbox
@ -61,7 +77,7 @@
:onhoverlost "${EWW_CMD} update show_volume=false"
(box :orientation "v"
:class "thingy volbox ${show_volume ? "active" : ""}"
:space-evenly false
:space-evenly false
(revealer :transition "slidedown"
:reveal show_volume
(scale :orientation "v"
@ -83,7 +99,7 @@
(button :valign "end"
:class "vpn thingy ${vpn_status.class}"
:onclick "${vpn_status.on_click}"
:tooltip "${vpn_status.tooltip}"
:tooltip "${vpn_status.tooltip}"
(label :text "${vpn_status.icon}")
))
@ -100,7 +116,7 @@
(box :orientation "v"
:valign "end"
:class "thingy"
:visible {bat_charge != ""}
:visible {bat_charge != ""}
(label :text "BAT")
(circular-progress
:thickness 4.0
@ -110,7 +126,6 @@
bat_charge < 15 ? "battery-gauge low" :
"battery-gauge"
}
;:style {bat_charge < 15 ? "color: red;" : ""}
)
;(label :text "${bat_charge}%")
))
@ -138,7 +153,7 @@
(button :orientation "v"
:valign "end"
:class "thingy pwrbtn clickable"
:onclick "${EWW_CMD} open --toggle pwrctl"
:onclick "${EWW_CMD} open --toggle pwrctl"
(label :text "⏻")
))
@ -160,7 +175,7 @@
(defvar show_volume false)
(defpoll workspaces_json :interval "1s" "eww-workspaces")
(defpoll workspaces :interval "1s" "eww-workspaces")
(defpoll volume_out :interval "1s" "pamixer --get-volume")
(defpoll vpn_status :interval "1s" "mullvad-status")
(defpoll current_minute :interval "1s" "date +%M")