218 lines
6.4 KiB
Plaintext
218 lines
6.4 KiB
Plaintext
;;; ─────────────────────────────────────────────
|
||
;;; Variables
|
||
;;; ─────────────────────────────────────────────
|
||
|
||
(deflisten workspaces-dp2
|
||
:initial "[]"
|
||
"bash ~/.config/eww/scripts/get-workspaces.sh DP-2")
|
||
|
||
(deflisten workspaces-hdmi
|
||
:initial "[]"
|
||
"bash ~/.config/eww/scripts/get-workspaces.sh HDMI-A-1")
|
||
|
||
(deflisten active-window-dp2
|
||
:initial ""
|
||
"bash ~/.config/eww/scripts/get-active-window.sh DP-2")
|
||
|
||
(deflisten active-window-hdmi
|
||
:initial ""
|
||
"bash ~/.config/eww/scripts/get-active-window.sh HDMI-A-1")
|
||
|
||
(defpoll clock-time
|
||
:interval "1s"
|
||
"date '+%H:%M:%S'")
|
||
|
||
(defpoll clock-date
|
||
:interval "1s"
|
||
"date '+%A, %B %d %Y'")
|
||
|
||
(defpoll cpu-usage
|
||
:interval "2s"
|
||
"top -bn1 | grep 'Cpu(s)' | awk '{print int($2+$4)}'")
|
||
|
||
(defpoll mem-used
|
||
:interval "2s"
|
||
"free -g --si | awk '/Mem:/{printf \"%.1f\", $3}'")
|
||
|
||
(defpoll network-info
|
||
:interval "5s"
|
||
"bash ~/.config/eww/scripts/get-network.sh")
|
||
|
||
(defpoll volume-info
|
||
:interval "1s"
|
||
"bash ~/.config/eww/scripts/get-volume.sh")
|
||
|
||
(defpoll theme-info
|
||
:interval "2s"
|
||
"bash ~/.config/eww/scripts/get-theme.sh")
|
||
|
||
;;; ─────────────────────────────────────────────
|
||
;;; Helper Widgets
|
||
;;; ─────────────────────────────────────────────
|
||
|
||
(defwidget workspace-btn [id label active urgent output]
|
||
(button
|
||
:class {active ? "workspace-btn active" : urgent ? "workspace-btn urgent" : "workspace-btn"}
|
||
:onclick "hyprctl dispatch workspace ${id}"
|
||
:width 32
|
||
label))
|
||
|
||
(defwidget workspaces-widget [workspaces]
|
||
(box
|
||
:class "workspaces"
|
||
:orientation "h"
|
||
:spacing 2
|
||
(for ws in workspaces
|
||
(workspace-btn
|
||
:id {ws.id}
|
||
:label {ws.label}
|
||
:active {ws.active}
|
||
:urgent {ws.urgent}
|
||
:output {ws.output}))))
|
||
|
||
(defwidget window-widget [title]
|
||
(box
|
||
:class "window-title"
|
||
:orientation "h"
|
||
:space-evenly false
|
||
(label
|
||
:class "window-text"
|
||
:text {title}
|
||
:limit-width 20)))
|
||
|
||
(defwidget clock-widget []
|
||
(box
|
||
:class "clock"
|
||
:orientation "h"
|
||
:spacing 2
|
||
(label :text clock-time :class "clock-time")
|
||
))
|
||
|
||
(defwidget cpu-widget []
|
||
(box
|
||
:class "stat-pill"
|
||
:orientation "h"
|
||
:spacing 4
|
||
(label :text "${cpu-usage}%" :class "stat-value")))
|
||
|
||
(defwidget mem-widget []
|
||
(box
|
||
:class "stat-pill"
|
||
:orientation "h"
|
||
:spacing 4
|
||
(label :text "${mem-used}G" :class "stat-value")))
|
||
|
||
(defwidget network-widget []
|
||
(box
|
||
:class "stat-pill"
|
||
:orientation "h"
|
||
:spacing 4
|
||
(label :text {network-info == "offline" ? "Offline" :
|
||
network-info =~ "^wifi:.*" ? "${network-info}" :
|
||
"${network-info}"}
|
||
:class "stat-value"
|
||
:limit-width 20)))
|
||
|
||
(defwidget volume-widget [on-click]
|
||
(button
|
||
:class "stat-pill clickable"
|
||
:onclick on-click
|
||
(box
|
||
:orientation "h"
|
||
:spacing 4
|
||
(label
|
||
:text {volume-info =~ "^muted.*" ? "" :
|
||
volume-info =~ "^[0-9]" && volume-info < "34" ? "" :
|
||
volume-info =~ "^[0-9]" && volume-info < "67" ? "" : ""}
|
||
:class "stat-icon")
|
||
(label
|
||
:text {volume-info =~ "^muted.*" ? "Muted" : "${volume-info}%"}
|
||
:class "stat-value"))))
|
||
|
||
(defwidget theme-widget []
|
||
(button
|
||
:class "stat-pill clickable theme-btn"
|
||
:onclick "bash $HOME/.config/hypr/theme-cycle.sh next"
|
||
:onrightclick "bash $HOME/.config/hypr/theme-cycle.sh auto"
|
||
(label :text theme-info :class "theme-icon")))
|
||
|
||
(defwidget logout-btn []
|
||
(button
|
||
:class "center-btn"
|
||
:onclick "your-logout-command"
|
||
(label :text "")))
|
||
|
||
(defwidget settings-btn []
|
||
(button
|
||
:class "center-btn"
|
||
:onclick "your-settings-command"
|
||
(label :text "")))
|
||
|
||
;;; ─────────────────────────────────────────────
|
||
;;; Bar for DP-2 (workspaces 1–5)
|
||
;;; ─────────────────────────────────────────────
|
||
|
||
(defwidget bar-dp2 []
|
||
(centerbox
|
||
:orientation "h"
|
||
(box :class "bar-left" :orientation "h" :spacing 2 :space-evenly false :halign "start"
|
||
(workspaces-widget :workspaces workspaces-dp2)
|
||
(window-widget :title active-window-dp2))
|
||
(box :class "bar-center" :orientation "h" :spacing 12 :space-evenly false
|
||
(logout-btn)
|
||
(clock-widget)
|
||
(settings-btn))
|
||
(box :class "bar-right" :orientation "h" :spacing 6 :space-evenly false :halign "end"
|
||
(theme-widget)
|
||
(volume-widget :on-click "bash ~/.config/eww/scripts/toggle-mixer.sh")
|
||
(network-widget)
|
||
(cpu-widget)
|
||
(mem-widget))))
|
||
|
||
(defwindow bar-dp2
|
||
:monitor 0
|
||
:geometry (geometry
|
||
:x "10px"
|
||
:y "8px"
|
||
:width "1900px"
|
||
:height "24px"
|
||
:anchor "top center")
|
||
:exclusive true
|
||
:layer "top"
|
||
:namespace "eww-bar"
|
||
(bar-dp2))
|
||
|
||
;;; ─────────────────────────────────────────────
|
||
;;; Bar for HDMI-A-1 (workspaces 6–10)
|
||
;;; ─────────────────────────────────────────────
|
||
|
||
(defwidget bar-hdmi []
|
||
(centerbox
|
||
:orientation "h"
|
||
(box :class "bar-left" :orientation "h" :spacing 8 :space-evenly false :max-width 300
|
||
(workspaces-widget :workspaces workspaces-hdmi)
|
||
(window-widget :title active-window-hdmi))
|
||
(box :class "bar-center" :orientation "h" :spacing 12 :space-evenly false
|
||
(logout-btn)
|
||
(clock-widget)
|
||
(settings-btn))
|
||
(box :class "bar-right" :orientation "h" :spacing 6 :space-evenly false :halign "end"
|
||
(theme-widget)
|
||
(volume-widget :on-click "pavucontrol")
|
||
(network-widget)
|
||
(cpu-widget)
|
||
(mem-widget))))
|
||
|
||
(defwindow bar-hdmi
|
||
:monitor 1
|
||
:geometry (geometry
|
||
:x "10px"
|
||
:y "8px"
|
||
:width "1900px"
|
||
:height "24px"
|
||
:anchor "top center")
|
||
:exclusive true
|
||
:layer "top"
|
||
:namespace "eww-bar"
|
||
(bar-hdmi))
|