From ab9b8b306a526402081d81b26e6655a842c67784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Mon, 16 Dec 2024 17:30:33 +0800 Subject: [PATCH] WIP: feat(sway): Add basic tray with EWW WIP because this needs to handle systems without a battery, and maybe have a network icon. --- home-config/config/desktop/sway.nix | 19 ++++++++++++ home-config/dotfiles/eww/eww.scss | 5 +++ home-config/dotfiles/eww/eww.yuck | 48 +++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 home-config/dotfiles/eww/eww.scss create mode 100644 home-config/dotfiles/eww/eww.yuck diff --git a/home-config/config/desktop/sway.nix b/home-config/config/desktop/sway.nix index b683dc3e..05e855a4 100644 --- a/home-config/config/desktop/sway.nix +++ b/home-config/config/desktop/sway.nix @@ -91,6 +91,25 @@ in }; }; + programs.eww = { + enable = true; + configDir = ../../dotfiles/eww; + }; + + systemd.user.services.eww = { + Unit = { + Description = "System tray"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${config.programs.eww.package}/bin/eww daemon --no-daemonize"; + ExecStartPost = "${config.programs.eww.package}/bin/eww open tray"; + }; + Install.WantedBy = [ "graphical-session.target" ]; + }; + systemd.user.services.swaylock = { Unit.Description = "Lock screen"; Service.ExecStart = "${config.programs.swaylock.package}/bin/swaylock"; diff --git a/home-config/dotfiles/eww/eww.scss b/home-config/dotfiles/eww/eww.scss new file mode 100644 index 00000000..716c571f --- /dev/null +++ b/home-config/dotfiles/eww/eww.scss @@ -0,0 +1,5 @@ +* { all: unset; } + +.tray-items { + font-size: 1.35em; +} diff --git a/home-config/dotfiles/eww/eww.yuck b/home-config/dotfiles/eww/eww.yuck new file mode 100644 index 00000000..4f4ea917 --- /dev/null +++ b/home-config/dotfiles/eww/eww.yuck @@ -0,0 +1,48 @@ +(defwindow tray + :monitor 0 + :geometry (geometry :height "0%" + :width "0%" + :anchor "bottom left") + :stacking "bottom" + :exclusive true + :focusable false + + (_tray_items)) + +(defwidget _tray_items [] + (box :class "tray-items" + + :spacing 3 + :vexpand true + :hexpand true + :valign "center" + :halign "start" + :space-evenly false + + (_battery_icon) + (_clock) + "|" + (systray :spacing 5 + :orientation "horizontal" + :space-evenly false))) + +(defvar battery_icons `[ + "", + "", + "", + "", + "", + "" +]`) + +(defwidget _battery_icon [] + (label :text { + jq(EWW_BATTERY, "first(.[])").status == "Charging" ? + "" : + battery_icons[round(jq(EWW_BATTERY, "first(.[])").capacity / 20, 0)] + } + :tooltip "${jq(EWW_BATTERY, "first(.[])").capacity}%")) + +(defwidget _clock [] + (label :text { formattime(EWW_TIME, "%R") } + :tooltip { formattime(EWW_TIME, "%F") }))