eww: refactor and add calendar widget

This commit is contained in:
stitchy 2024-11-28 10:06:31 +00:00
parent 4cd16133e9
commit 33f4d22664
Signed by: stitchy
SSH key fingerprint: SHA256:yz2SoxdnY67tfY5Jzb0f2v8f5W3o/IF359kbcquWip8

View file

@ -1,13 +1,11 @@
;;;; (defpoll time :interval "1s" 'date +%s') ;; VARIABLE DEFINITIONS
(defwidget clock []
(box :orientation "vertical"
:halign "center"
:valign "end"
(box :class "clock" {formattime(EWW_TIME, "%H")})
(box :class "clock" {formattime(EWW_TIME, "%M")})
))
;; Audio
(deflisten vol "cat ~/.cache/eww/vol && inotifywait -q -m -e close_write ~/.cache/eww/vol | while read -r filename event; do cat ~/.cache/eww/vol; done")
(defpoll micvol :interval "1m" "wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{print $2}'")
;; Workspace Stuff
(deflisten workspaces :initial "[]" "bash ~/.config/eww/scripts/get-workspaces") (deflisten workspaces :initial "[]" "bash ~/.config/eww/scripts/get-workspaces")
(deflisten current_workspace :initial "..." "bash ~/.config/eww/scripts/get-active-workspace") (deflisten current_workspace :initial "..." "bash ~/.config/eww/scripts/get-active-workspace")
(deflisten urgent_workspace :initial "..." "bash ~/.config/eww/scripts/get-urgent-workspaces") (deflisten urgent_workspace :initial "..." "bash ~/.config/eww/scripts/get-urgent-workspaces")
@ -21,6 +19,21 @@
(label :text "${workspace.id}") (label :text "${workspace.id}")
)))))) ))))))
;; Screen
(deflisten backlight "brightnessctl g && inotifywait -q -m -e modify /sys/class/backlight/intel_backlight/actual_brightness | while read -r filename event; do cat /sys/class/backlight/intel_backlight/actual_brightness; done")
;; Widgets
(defwidget clock []
(eventbox
:onhover "eww open cal"
(box :orientation "vertical"
:halign "center"
:valign "end"
(box :class "clock" {formattime(EWW_TIME, "%H")})
(box :class "clock" {formattime(EWW_TIME, "%M")})
)))
(defwidget circle [val prog sty char] (defwidget circle [val prog sty char]
(box :halign "center" (box :halign "center"
@ -43,24 +56,18 @@
:val {EWW_BATTERY.BAT1.capacity} :val {EWW_BATTERY.BAT1.capacity}
:char "󱐋")) :char "󱐋"))
(deflisten vol "cat ~/.cache/eww/vol && inotifywait -q -m -e close_write ~/.cache/eww/vol | while read -r filename event; do cat ~/.cache/eww/vol; done")
(defwidget volume [] (defwidget volume []
(circle :prog {vol * 7/10} (circle :prog {vol * 7/10}
:sty "font-size: 12; margin-right: 2px;" :sty "font-size: 12; margin-right: 2px;"
:val {vol + 1 - 1} :val {vol + 1 - 1}
:char "")) :char ""))
(defpoll micvol :interval "1m" "wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{print $2}'")
(defwidget mic [] (defwidget mic []
(circle :prog {micvol * 70} (circle :prog {micvol * 70}
:sty "margin-left: 1px;" :sty "margin-left: 1px;"
:val {micvol *100} :val {micvol *100}
:char "󰍬")) :char "󰍬"))
(deflisten backlight "brightnessctl g && inotifywait -q -m -e modify /sys/class/backlight/intel_backlight/actual_brightness | while read -r filename event; do cat /sys/class/backlight/intel_backlight/actual_brightness; done")
(defwidget brightness [] (defwidget brightness []
(circle :prog {(backlight / 960) * 7/10} (circle :prog {(backlight / 960) * 7/10}
:sty "font-size: 12; margin-right: 3px;" :sty "font-size: 12; margin-right: 3px;"
@ -73,6 +80,10 @@
(defwidget tray [] (defwidget tray []
(systray :orientation "v" :icon-size 20)) (systray :orientation "v" :icon-size 20))
;; Upper Level Widgets
(defwidget bar [] (defwidget bar []
(centerbox :orientation "vertical" (centerbox :orientation "vertical"
:halign "center" :halign "center"
@ -87,6 +98,13 @@
(tray) (tray)
(power)))) (power))))
(defwidget cal []
(eventbox
:onhoverlost "eww close cal"
(calendar)))
;; Windows
(defwindow bar (defwindow bar
:monitor 0 :monitor 0
@ -98,3 +116,13 @@
:exclusive true :exclusive true
:class "bar" :class "bar"
(bar)) (bar))
(defwindow cal
:monitor 0
:geometry (geometry :x "1%"
:y "5%"
:anchor "left center")
:stacking "fg"
:exclusive false
:class "bar"
(cal))