From 33f4d22664b0639d36b346cd94d1ebaf3543615e Mon Sep 17 00:00:00 2001 From: stitchy Date: Thu, 28 Nov 2024 10:06:31 +0000 Subject: [PATCH] eww: refactor and add calendar widget --- config/eww/eww.yuck | 94 +++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 33 deletions(-) diff --git a/config/eww/eww.yuck b/config/eww/eww.yuck index 00158fc..d9db5e7 100644 --- a/config/eww/eww.yuck +++ b/config/eww/eww.yuck @@ -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 current_workspace :initial "..." "bash ~/.config/eww/scripts/get-active-workspace") (deflisten urgent_workspace :initial "..." "bash ~/.config/eww/scripts/get-urgent-workspaces") @@ -21,6 +19,21 @@ (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] (box :halign "center" @@ -43,24 +56,18 @@ :val {EWW_BATTERY.BAT1.capacity} :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 [] (circle :prog {vol * 7/10} :sty "font-size: 12; margin-right: 2px;" :val {vol + 1 - 1} :char "")) -(defpoll micvol :interval "1m" "wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{print $2}'") - (defwidget mic [] (circle :prog {micvol * 70} :sty "margin-left: 1px;" :val {micvol *100} :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 [] (circle :prog {(backlight / 960) * 7/10} :sty "font-size: 12; margin-right: 3px;" @@ -73,28 +80,49 @@ (defwidget tray [] (systray :orientation "v" :icon-size 20)) + +;; Upper Level Widgets + + (defwidget bar [] (centerbox :orientation "vertical" - :halign "center" - :space-evenly false - (_workspaces) - (clock) - (box :orientation "vertical" :spacing -25 :valign "end" - (brightness) - (mic) - (volume) - (battery) - (tray) - (power)))) + :halign "center" + :space-evenly false + (_workspaces) + (clock) + (box :orientation "vertical" :spacing -25 :valign "end" + (brightness) + (mic) + (volume) + (battery) + (tray) + (power)))) +(defwidget cal [] + (eventbox + :onhoverlost "eww close cal" + (calendar))) + + +;; Windows (defwindow bar - :monitor 0 - :geometry (geometry :x "4px" - :y "1%" - :height "98%" - :anchor "left center") - :stacking "fg" - :exclusive true - :class "bar" + :monitor 0 + :geometry (geometry :x "4px" + :y "1%" + :height "98%" + :anchor "left center") + :stacking "fg" + :exclusive true + :class "bar" (bar)) + +(defwindow cal + :monitor 0 + :geometry (geometry :x "1%" + :y "5%" + :anchor "left center") + :stacking "fg" + :exclusive false + :class "bar" + (cal))