nixos/home/env/config/eww/powermenu/eww.yuck

110 lines
3.9 KiB
Plaintext

(defwindow powermenu
:monitor 0
:stacking "fg"
:windowtype "normal"
:wm-ignore true
:geometry (geometry :width "100%" :height "100%")
(powermenu_layout))
(defpoll time :interval "5s"
:initial `date +'{"hour":"%H","min":"%M"}'`
`date +'{"hour":"%H","min":"%M"}'`)
(defpoll net :interval "100s"
:initial `N/A`
`nmcli -t -f SIGNAL,ACTIVE device wifi \
| awk -F':' '{if($2=="yes")print$1}'`)
(defpoll eth :interval "100s"
:initial `N/A`
`nmcli -t -f TYPE,STATE device status \
| awk -F':' '{if($2=="connected")print$1}'`)
(defwidget powermenu_layout []
(box :class "layout-box" :space-evenly false :orientation "vertical"
:style "background-image: url('./powermenu/wallpaper')"
(box :valign "start" :space-evenly false :spacing 25
(_sundial)
(_battery :status {EWW_BATTERY.BAT0.status}
:battery {EWW_BATTERY.BAT0.capacity})
(_network :strength net :offline "󰤭 " :excellent "󰤨 " :good "󰤥 "
:okay "󰤢 " :slow "󰤟 ")
(_network_ethernet :name eth)
(label :text "|" :class "sep")
(button :onclick "eww close powermenu" :class "close-btn" ""))
(box :space-evenly false :hexpand true :vexpand true
(box :spacing 15 :class "tm-box" :space-evenly false
:valign "end" :halign "start"
(label :text "󰥔 ")
(label :text "${time.hour} ${time.min}"))
(_buttons :shutdown "poweroff" :reboot "reboot"
:logout "loginctl kill-session self"
:shutdown_icon "󰐥 " :reboot_icon "󰤁 "
:logout_icon "󰍃 "))))
(defwidget _battery [battery status]
(box :class "bat-box" :space-evenly false :spacing 8
(label :text {
status == 'Charging' ? "󰂄" :
battery < 10 ? "󰁺" :
battery < 20 ? "󰁻" :
battery < 30 ? "󰁼" :
battery < 40 ? "󰁽" :
battery < 50 ? "󰁾" :
battery < 60 ? "󰁿" :
battery < 70 ? "󰂀" :
battery < 80 ? "󰂁" :
battery < 90 ? "󰂂" :
"󰁹"})))
(defwidget _network [strength offline excellent
good okay slow]
(box :class "net-box"
:space-evenly false
:spacing 8
(label :text {strength == "" ? offline :
strength < 26 ? slow :
strength < 51 ? okay :
strength < 76 ? good : excellent})))
(defwidget _network_ethernet [name]
(box :class "net-box"
:space-evenly false
:spacing 8
(label :text {name == "ethernet" ? "󰈁 " : "󰈂 "})))
(defwidget _buttons [shutdown shutdown_icon reboot
reboot_icon logout logout_icon]
(box :class "btns-box" :spacing 5
:vexpand true :hexpand true
:valign "end" :halign "end"
:space-evenly false
(button :onclick shutdown shutdown_icon)
(button :onclick reboot reboot_icon)
(button :onclick logout logout_icon)))
(defwidget _sundial []
(label :class "sundial-lbl" :halign "end" :hexpand true
:text {time.hour >= 2 && time.hour <= 4 ? "Early Morning" :
time.hour <= 5 ? "Dawn" :
time.hour >= 6
&& (time.hour <= 8 && time.min <= 59)
? "Morning" :
time.hour >= 9
&& (time.hour <= 11 && time.min <= 59)
? "Late Morning" :
time.hour == 12 && time.min <= 29
? "Midday" :
time.hour >= 12 && time.hour <= 16
? "Afternoon" :
time.hour > 16 && time.hour <= 17
? "Late Afternoon" :
(time.hour >= 17 && time.min <= 1)
|| (time.hour <= 18 && time.min <= 20)
? "Early Evening" :
time.hour >= 18 && time.hour <= 19
? "Dusk" :
time.hour > 19 && time.hour <= 21
? "Late Evening" :
time.hour > 21 ? "Night" : "Midnight"}))
;; vim:ft=yuck