eww replacement of waybar

This commit is contained in:
samantha42
2026-04-20 20:37:54 +02:00
parent a240874719
commit 52fa42698f
14 changed files with 591 additions and 119 deletions

View File

@@ -1,49 +1,217 @@
(defpoll volume :interval "1s"
"wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{printf \"%d\", $2*100}'")
;;; ─────────────────────────────────────────────
;;; Variables
;;; ─────────────────────────────────────────────
(defpoll muted :interval "1s"
"wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -c MUTED || echo 0")
(deflisten workspaces-dp2
:initial "[]"
"bash ~/.config/eww/scripts/get-workspaces.sh DP-2")
(defpoll sink-inputs :interval "2s"
"~/.config/eww/scripts/get-sinks.sh")
(deflisten workspaces-hdmi
:initial "[]"
"bash ~/.config/eww/scripts/get-workspaces.sh HDMI-A-1")
(defwidget volume-overlay []
(box :class "volume-overlay" :orientation "v" :spacing 12 :space-evenly false
(box :class "header" :orientation "h" :space-evenly false :spacing 8
(label :class "header-icon" :text "󰕾")
(label :class "header-title" :text "Volume Mixer"))
(deflisten active-window-dp2
:initial ""
"bash ~/.config/eww/scripts/get-active-window.sh DP-2")
(box :class "sink-row" :orientation "v" :spacing 4
(box :orientation "h" :space-evenly false :spacing 8
(label :class "app-icon" :text "󰓃")
(label :class "app-name" :text "Master")
(label :class "app-vol" :text "${volume}%"))
(scale :class "vol-slider master-slider"
:min 0 :max 100 :value volume
:onchange "wpctl set-volume @DEFAULT_AUDIO_SINK@ {}%"))
(deflisten active-window-hdmi
:initial ""
"bash ~/.config/eww/scripts/get-active-window.sh HDMI-A-1")
(box :class "divider")
(defpoll clock-time
:interval "1s"
"date '+%H:%M:%S'")
(for sink in sink-inputs
(box :class "sink-row" :orientation "v" :spacing 4
(box :orientation "h" :space-evenly false :spacing 8
(label :class "app-icon" :text "󰓃")
(label :class "app-name" :text {sink.name})
(label :class "app-vol" :text "${sink.volume}%"))
(scale :class "vol-slider"
:min 0 :max 100 :value {sink.volume}
:onchange "wpctl set-volume ${sink.id} {}%")))
(defpoll clock-date
:interval "1s"
"date '+%A, %B %d %Y'")
(button :class "mute-btn ${muted == "1" ? "muted" : ""}"
:onclick "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
(label :text "${muted == "1" ? "󰝟 Muted" : "󰕾 Mute"}"))))
(defpoll cpu-usage
:interval "2s"
"top -bn1 | grep 'Cpu(s)' | awk '{print int($2+$4)}'")
(defwindow volume-mixer
:monitor 0
:geometry (geometry :x "0px" :y "40px"
:width "280px"
:anchor "top right")
:stacking "overlay"
:exclusive false
(volume-overlay))
(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 15)
;;; ─────────────────────────────────────────────
(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 610)
;;; ─────────────────────────────────────────────
(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))