working on eww

This commit is contained in:
2026-03-11 16:02:26 +01:00
parent f33211449f
commit 9e01d35ce4
9 changed files with 1038 additions and 330 deletions
+90
View File
@@ -0,0 +1,90 @@
(defvar colors
@(eww -c
(defvar base "#1E1E2E")
(defvar text "#CDD6F4")
(defvar lavender "#B4BEFE")
(defvar blue "#89B4FA")
(defvar green "#A6E3A1")
(defvar yellow "#F9E2AF")
(defvar red "#F38BA8")
(defvar surface0 "#313244")
(defvar surface1 "#45475A")
)
)
;; Main bar widget
(defwidget bar []
(box :class "bar" :orientation "h" :space-evenly false
;; Left: Workspaces (Hyprland)
(box :class "workspaces" :orientation "h"
(label :class "workspace" :id "workspace_1" :text "1")
(label :class "workspace" :id "workspace_2" :text "2")
(label :class "workspace" :id "workspace_3" :text "3")
(label :class "workspace" :id "workspace_4" :text "4")
(label :class "workspace" :id "workspace_5" :text "5")
)
;; Center: Empty (placeholder for alignment)
(box :halign "center" :hexpand true)
;; Right: System modules
(box :class "right-items" :orientation "h" :spacing 8
;; Idle inhibitor
(button :class "idle-inhibitor" :onclick "eww update idle_inhibitor_icon=' '; notify-send 'Idle inhibitor' 'Activated'"
:label (label :id "idle_inhibitor_icon" :text "󰒲"))
;; PulseAudio
(button :class "pulseaudio" :onclick "pavucontrol"
:label (label :id "pulseaudio_label" :text " 100%"))
;; Network
(button :class "network" :onclick "impala" :onclick-right "nm-connection-editor"
:label (label :id "network_label" :text "Disconnected ⚠"))
;; Battery
(button :class "battery" :label (label :id "battery_label" :text "100% 󰂄"))
;; Tray placeholder (requires external tray like waybar-tray)
(box :class "tray" :orientation "h" :spacing 4
(label :text "Tray"))
;; Clock
(button :class "clock" :onclick "flatpak run eu.betterbird.Betterbird -calendar"
:label (label :id "clock_label" :text "Mon, 01 Jan 2024 - 12:00"))
)
)
)
;; Window definition
(defwindow bar-window
:geometry (geometry :x 0 :y 0 :width 1920 :height 34 :anchor "top left")
:layer "top"
:exclusivity "ignore"
(bar)
)
;; Scripts to update dynamic content
(defpoll [1000] ;; Update every second
;; Update PulseAudio volume
(setq pulseaudio-volume (exec "pamixer --get-volume"))
(setq pulseaudio-muted (exec "pamixer --get-mute"))
(if (= pulseaudio-muted "true")
(eww update pulseaudio_label="")
(eww update pulseaudio_label=(strfmt "{}% {}" pulseaudio-volume (if (> (string->number pulseaudio-volume) 50) "" "")))
;; Update network status
(setq network-essid (exec "nmcli -t -f TYPE,NAME dev status | awk -F: '/wifi/{print $2}' | xargs -I {} sh -c 'nmcli -t -f SIGNAL dev wifi list ifname {} | awk -F: \"NR==2{print \\$1}\"'"))
(if (string-empty? network-essid)
(eww update network_label="Disconnected ⚠")
(eww update network_label=(strfmt " ({}%)" network-essid)))
;; Update clock
(eww update clock_label=(strftime "%a, %d %b %Y - %H:%M"))
;; Update battery status
(setq battery-capacity (exec "cat /sys/class/power_supply/BAT0/capacity"))
(setq battery-status (exec "cat /sys/class/power_supply/BAT0/status"))
(if (string= battery-status "Charging")
(eww update battery_label=(strfmt "{}% 󰂄" battery-capacity))
(eww update battery_label=(strfmt "{}% 󰁹" battery-capacity)))
)
@@ -0,0 +1,130 @@
/* Catppuccin Mocha theme for EWW */
:root {
--base: #1e1e2e;
--mantle: #181825;
--crust: #11111b;
--text: #cdd6f4;
--subtext1: #bac2de;
--subtext0: #a6adc8;
--overlay2: #9399b2;
--overlay1: #7f849c;
--overlay0: #6c7086;
--surface2: #585b70;
--surface1: #45475a;
--surface0: #313244;
--lavender: #b4befe;
--blue: #89b4fa;
--sapphire: #74c7ec;
--teal: #94e2d5;
--green: #a6e3a1;
--yellow: #f9e2af;
--peach: #fab387;
--maroon: #eba0ac;
--red: #f38ba8;
--mauve: #cba6f7;
--pink: #f5c2e7;
--flamingo: #f2cdcd;
--rosewater: #f5e0dc;
}
* {
all: unset;
font-family: "JetBrainsMono Nerd Font", monospace;
font-size: 12px;
color: var(--text);
}
window {
background-color: rgba(30, 30, 46, 0.9); /* --base with transparency */
border-radius: 8px;
padding: 0;
margin: 0;
border: 1px solid var(--surface0);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
box {
background-color: transparent;
padding: 4px 8px;
spacing: 8px;
}
label {
color: var(--text);
padding: 2px 6px;
}
button {
color: var(--text);
background-color: var(--surface1);
border-radius: 4px;
padding: 2px 8px;
transition: all 0.2s ease;
}
button:hover {
background-color: var(--surface2);
color: var(--lavender);
}
button:active {
background-color: var(--blue);
color: var(--crust);
}
/* Workspace buttons */
.workspace {
color: var(--subtext1);
background-color: transparent;
border-radius: 4px;
padding: 2px 8px;
margin: 0 2px;
}
.workspace.active {
background-color: var(--blue);
color: var(--base);
}
.workspace.urgent {
background-color: var(--red);
color: var(--crust);
}
.workspace.focused {
background-color: var(--lavender);
color: var(--base);
}
/* Clock */
#clock {
color: var(--peach);
padding: 2px 8px;
background-color: transparent;
}
/* System stats */
#cpu,
#ram,
#temp {
color: var(--green);
padding: 2px 8px;
background-color: transparent;
}
#volume {
color: var(--mauve);
}
#battery {
color: var(--green);
}
#battery.discharging {
color: var(--yellow);
}
#battery.critical {
color: var(--red);
}