nix-config/modules/wm/hyprland/config/eww/eww_widgets.yuck
2025-04-14 00:46:57 +02:00

88 lines
4 KiB
Text

; -> WIDGETS FOR EWW <- ;
;;;; Imports
(include "/home/horseman/.config/eww/eww_variables.yuck")
;;;; Metric (cpu, ram, etc bars) constructor widget
(defwidget metric [label value ?onchange]
(box :orientation "h" :class "metric" :space-evenly false
(box :class "label" label)
(scale :min 0 :max 101 :active {onchange != ""} :value value :onchange onchange)))
;;;; Background Black Holder Widget
(defwidget power []
(centerbox :class "bg-box"
(box :orientation "h" :space-evenly false :valign "center" :halign "start" :spacing 5
(button :onclick "kitty -T 'confirm-script' ~/.config/eww/scripts/confirm.sh 'shutdown now' &" (image :path "images/shutdown.svg"))
(button :onclick "kitty -T 'confirm-script' ~/.config/eww/scripts/confirm.sh 'reboot' &" (image :path "images/reboot.svg"))
(button :onclick "hyprlock" (image :path "images/lock.svg"))
)
""
(box :orientation "h" :space-evenly false :valign "center" :halign "end" :spacing 5
(button :onclick "kitty pulsemixer &" (image :path {sound} ))
(button :onclick "" (image :path "images/ethernet.svg"))
)
)
)
;;;; User information fetch widget
(defwidget uinfo []
(box :class "uinfo" :orientation "v" :space-evenly false :halign "center" :valign "center"
(label :style "color: #5e81ac;" :text {host} :halign "center" :valign "center" :wrap "false" :limit-width 25)
(label :style "color: #efefef;" :text "─────────────" :halign "center" :valign "center" :wrap "false" :limit-width 25)
;; Tags for values
(box :orientation "h" :space-evenly "false" :spacing 10
(box :orientation "v" :class "fetch" :spacing 2
(image :path "images/workspace.svg")
(image :path "images/window.svg")
(image :path "images/date.svg")
(image :path "images/time.svg")
)
;; Fetch Values
(box :orientation "v" :class "fetch"
(label :style "color: #b48ead;" :halign "start" :text " Workspace ${workspace}")
(label :style "color: #ebcb8b;" :halign "start" :text " ${clients} Windows")
(label :style "color: #80a0c0;" :halign "start" :text " ${TODAY}")
(label :style "color: #b48ead;" :halign "start" :text " ${time}")
))))
;;;; System Information Widget
(defwidget sys []
(box :class "cpu" :orientation "v" :space-evenly false :halign "center" :valign "center"
(box :space-evenly false (image :path "images/cpu.svg")(metric :label "" :value {EWW_CPU.avg}) )
(box :space-evenly false (image :path "images/ram.svg")(metric :label "" :value {EWW_RAM.used_mem_perc}) )
(box :space-evenly false (image :path "images/disk.svg")(metric :label "" :value {EWW_DISK["/"].used_perc}) )
(box :space-evenly false :visible { hostname == "luna" } (image :path { EWW_BATTERY.BAT1.status == "Discharging" ? "images/battery.svg" : "images/charging.svg" })(metric :label "" :value {EWW_BATTERY.BAT1.capacity}) )
(box :space-evenly false :visible { hostname == "terra" } (image :path "images/gpu.svg")(metric :label "" :value gpu_load) )
)
)
;;;; Random Quote Widget
(defwidget quote []
(box :class "quote" :orientation "v" :space-evenly false :halign "center" :valign "center"
(label :class "quote-text" :text "${quote_text}" :wrap true)))
;;;; QuickSettings widget
(defwidget quicksettings []
(box :orientation "h" :space-evenly true :class "quicksettings" :spacing "10" :halign "center" :valign "center"
(button :onclick "playerctl previous &" (image :path "images/prev.svg"))
(button :onclick "playerctl play-pause &" (image :path "images/play.svg"))
(button :onclick "playerctl next &" (image :path "images/next.svg"))))
;;;; AppBar widget
(defwidget appbar []
(box :orientation "h" :space-evenly false :class "appbar" :spacing "10" :halign "center" :valign "center"
(button :onclick "firefox &" (image :path "images/firefox.svg"))
(button :onclick "kitty vim &" (image :path "images/vim.svg"))
(button :onclick "kitty &" (image :path "images/kitty.svg"))
)
)