nicks-nix-config/modules/ewwbar/eww-config/eww.yuck
2023-10-31 23:04:06 -07:00

163 lines
4.7 KiB
Text

(defwidget bar []
(centerbox :orientation "h"
(workspaces :current-idx current-workspace)
;; (music)
(center-clock)
(info)
))
(deflisten current-workspace :initial "1" "bash ./scripts/get-active-workspace")
(defwidget workspaces [current-idx]
(box
:halign "start"
:hexpand false
:class "bar-main"
:space-evenly true
:spacing "12"
:css "* {margin-left: 20px; margin-right: 20px;}"
(box
:class {current-idx == "1" ? "active-workspace" : "regular"}
(label :text ""))
(box
:class {current-idx == "2" ? "active-workspace" : "regular"}
(label :text ""))
(box
:class {current-idx == "3" ? "active-workspace" : "regular"}
(label :text ""))
(box
:class {current-idx == "4" ? "active-workspace" : "regular"}
(label :text ""))
(box
:class {current-idx == "5" ? "active-workspace" : "regular"}
(label :text ""))
(box
:class {current-idx == "6" ? "active-workspace" : "regular"}
(label :text ""))
(box
:class {current-idx == "7" ? "active-workspace" : "regular"}
(label :text ""))
(box
:class {current-idx == "8" ? "active-workspace" : "regular"}
(label :text ""))
(box
:class {current-idx == "9" ? "active-workspace" : "regular"}
(label :text ""))))
(defwidget info []
(box
:class "side-stuff"
:halign "end"
:space-evenly false
:spacing "25"
(box
:space-evenly false
:spacing "10"
(_volume :volume volume)
(_battery :status {EWW_BATTERY == "" ? "" : EWW_BATTERY.BAT0.status} :battery {EWW_BATTERY == "" ? "" : EWW_BATTERY.BAT0.capacity}))
(_network :strength net-strength :name net-name)
(sep)
(buttons)))
(defvar eww "eww -c $HOME/.config/eww")
(defwidget revealer-on-hover [toggle togglename ?transition ?duration]
(eventbox
:onhover "${eww} update ${togglename}=true"
:onhoverlost "${eww} update ${togglename}=false"
(box
:space-evenly false
(children :nth 0)
(revealer
:reveal toggle
:transition {transition ?: "slideright"}
:duration {duration ?: "300ms"}
(children :nth 1)))))
(defvar volume-visible false)
(defwidget _volume [volume]
(eventbox
:onscroll "./scripts/volume {} ${EWW_EXECUTABLE}"
:onclick "./scripts/volume toggle ${EWW_EXECUTABLE}"
(box
:hexpand false
:class {(volume ?: 90) > 100 ? "alert" : "regular"}
(revealer-on-hover
:toggle volume-visible
:togglename "volume-visible"
(label :text {volume <= 0 ? "󰝟 " :
volume < 33 ? "󰕿 " :
volume < 66 ? "󰖀 " :
volume < 99 ? "󰕾 " : "󱄡 "})
(label :text "${volume ?: "??"}%")
)
(volume_scale)
)))
(defvar battery-visible false)
(defwidget _battery [status battery]
(box
:hexpand false
:class {status == "" ? "regular" : battery < 20 ? "alert" : "regular"}
(revealer-on-hover
:toggle battery-visible
:togglename "battery-visible"
(label :text {status == 'Charging' || status == "" ? "󰚥" :
battery < 20 ? "󰁻" :
battery < 40 ? "󰁽" :
battery < 60 ? "󰁿" :
battery < 80 ? "󰂁" : "󰁹"})
(label :text "${battery}%"))))
(defvar network-visible false)
(defwidget _network [strength name]
(box
:hexpand false
:vexpand true
:class "regular"
(revealer-on-hover
:toggle network-visible
:togglename "network-visible"
:ransition "slidedown"
(label :text {strength == "" ? "󰤮 " :
strength < 26 ? "󰤟 " :
strength < 51 ? "󰤢 " :
strength < 76 ? "󰤥 " : "󰤨 "})
(label :text "${name} (${strength})"))))
(defwidget buttons []
(box
:halign "end"
:hexpand false
:space-evenly true
:spacing "15"
(box (button :onclick `hyprctl dispatch exit` "󰍃 "))
(box (button :onclick `reboot` " "))
(box (button :onclick `shutdown now` " "))))
(defwidget sep [] (box :hexpand false (label :class "sep" :text "|")))
(defpoll net-strength :interval "5s" :initial `N/A`
`nmcli -t -f SIGNAL,ACTIVE device wifi | awk -F':' '{if($2=="yes")print$1}'`)
(defpoll net-name :interval "60s" :initial "N/A" "nmcli -t -f NAME c show --active | head -n 1")
(deflisten music :initial ""
"playerctl --follow metadata --format '{{ artist }} - {{ title }}' || true")
(defwidget music []
(box :class "music"
:orientation "h"
:space-evenly false
:halign "center"
{music != "" ? "🎵${music}" : ""}))
(defpoll volume :interval "1s"
{"pw-volume status | jq '.percentage // -1'" ?: 500})
(include "windows.yuck")
(include "./modules/center-clock.yuck")
(defvar open_vol_osd false)
(defvar ANIM_DURATION "500ms")
(include "./modules/volume-osd.yuck")
(include "./dashboard/dashboard.yuck")