311 lines
8.9 KiB
Plaintext
311 lines
8.9 KiB
Plaintext
;;; ─────────────────────────────────────────────
|
||
;;; Variables
|
||
;;; ─────────────────────────────────────────────
|
||
|
||
(deflisten workspaces-dp2
|
||
:initial "[]"
|
||
"python3 ~/.config/eww/scripts/get-workspaces.py DP-2")
|
||
|
||
(deflisten workspaces-hdmi
|
||
:initial "[]"
|
||
"python3 ~/.config/eww/scripts/get-workspaces.py 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 icons pxwidth]
|
||
(box
|
||
:orientation "h"
|
||
:width pxwidth
|
||
(button
|
||
:class {active ? "workspace-btn active" : urgent ? "workspace-btn urgent" : "workspace-btn"}
|
||
:onclick "hyprctl dispatch workspace ${id}"
|
||
:hexpand true
|
||
(box
|
||
:orientation "h"
|
||
:spacing 3
|
||
:halign "center"
|
||
:valign "center"
|
||
(label :text label :class "ws-label")
|
||
(for icon in icons
|
||
(image
|
||
:path icon
|
||
:image-width 16
|
||
:image-height 16))))))
|
||
|
||
|
||
(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}
|
||
:icons {ws.icons}
|
||
:pxwidth {ws.pxwidth}))))
|
||
|
||
;;; add this with your variables
|
||
(defvar clock-show-date false)
|
||
|
||
;;; replace your clock-widget
|
||
(defwidget clock-widget []
|
||
(button
|
||
:class "clock"
|
||
:onclick "eww update clock-show-date=${clock-show-date == 'true' ? 'false' : 'true'}"
|
||
(label
|
||
:class "clock-time"
|
||
:text {clock-show-date == "true" ? clock-date : 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 8 :space-evenly false :halign "start"
|
||
(workspaces-widget :workspaces workspaces-dp2))
|
||
(box :class "bar-center" :orientation "h" :spacing 12 :space-evenly false
|
||
|
||
(clock-widget)
|
||
)
|
||
(box :class "bar-right" :orientation "h" :spacing 8 :space-evenly false :halign "end"
|
||
(settings-menu)
|
||
(logout-menu)
|
||
(cpu-widget)
|
||
(mem-widget))))
|
||
|
||
(defwindow bar-dp2
|
||
:monitor 0
|
||
:geometry (geometry
|
||
:x "10px"
|
||
:y "8px"
|
||
:width "1920px"
|
||
: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
|
||
(workspaces-widget :workspaces workspaces-hdmi))
|
||
(box :class "bar-center" :orientation "h" :spacing 12 :space-evenly false
|
||
(logout-btn)
|
||
(clock-widget))
|
||
(box :class "bar-right" :orientation "h" :spacing 2 :space-evenly false :halign "end"
|
||
(settings-btn)
|
||
(cpu-widget)
|
||
(mem-widget))))
|
||
|
||
(defwindow bar-hdmi
|
||
:monitor 1
|
||
:geometry (geometry
|
||
:x "10px"
|
||
:y "8px"
|
||
:width "1920px"
|
||
:height "24px"
|
||
:anchor "top center")
|
||
:exclusive true
|
||
:layer "top"
|
||
:namespace "eww-bar"
|
||
(bar-hdmi))
|
||
|
||
|
||
(defvar logout-menu-open false)
|
||
(defvar settings-menu-open false)
|
||
|
||
(defwidget logout-menu []
|
||
(box
|
||
:class "center-menu-wrap"
|
||
:orientation "h"
|
||
:spacing 4
|
||
:space-evenly false
|
||
|
||
(revealer
|
||
:reveal {logout-menu-open == "true"}
|
||
:transition "slideright"
|
||
:duration "200ms"
|
||
(box
|
||
:class "center-menu"
|
||
:orientation "h"
|
||
:spacing 4
|
||
:space-evenly false
|
||
|
||
(button
|
||
:class "center-btn"
|
||
:tooltip "Lock"
|
||
:onclick "eww update logout-menu-open=false && hyprlock"
|
||
(label :text ""))
|
||
|
||
(button
|
||
:class "center-btn"
|
||
:tooltip "Reboot"
|
||
:onclick "eww update logout-menu-open=false && systemctl reboot"
|
||
(label :text ""))
|
||
|
||
(button
|
||
:class "center-btn"
|
||
:tooltip "Shutdown"
|
||
:onclick "eww update logout-menu-open=false && systemctl poweroff"
|
||
(label :text ""))
|
||
|
||
(button
|
||
:class "center-btn"
|
||
:tooltip "Logout"
|
||
:onclick "eww update logout-menu-open=false && hyprctl dispatch exit"
|
||
(label :text ""))))
|
||
(button
|
||
:class "center-btn"
|
||
:onclick "eww update logout-menu-open=${logout-menu-open == 'true' ? 'false' : 'true'} && eww update settings-menu-open=false"
|
||
(label :text {logout-menu-open == "true" ? "" : ""}))
|
||
|
||
))
|
||
|
||
(defwidget settings-menu []
|
||
(box
|
||
:class "center-menu-wrap"
|
||
:orientation "h"
|
||
:spacing 4
|
||
:space-evenly false
|
||
|
||
(revealer
|
||
:reveal {settings-menu-open == "true"}
|
||
:transition "slideright"
|
||
:duration "200ms"
|
||
(box
|
||
:class "center-menu"
|
||
:orientation "h"
|
||
:spacing 4
|
||
:space-evenly false
|
||
|
||
|
||
(theme-widget)
|
||
|
||
(volume-widget :on-click "bash ~/.config/eww/scripts/toggle-mixer.sh")
|
||
|
||
(network-widget)
|
||
|
||
(button
|
||
:class "center-btn"
|
||
:tooltip "Displays"
|
||
:onclick "eww update settings-menu-open=false && wdisplays"
|
||
(label :text ""))
|
||
|
||
))
|
||
|
||
(button
|
||
:class {settings-menu-open == "true" ? "center-btn active" : "center-btn"}
|
||
:onclick "eww update settings-menu-open=${settings-menu-open == 'true' ? 'false' : 'true'} && eww update logout-menu-open=false"
|
||
(label :text {settings-menu-open == "true" ? "" : ""}))
|
||
|
||
)) |