Skip to content

Commit

Permalink
WIP: feat(sway): Add basic tray with EWW
Browse files Browse the repository at this point in the history
WIP because this needs to handle systems without a battery, and maybe
have a network icon.
  • Loading branch information
tlater-famedly committed Dec 16, 2024
1 parent 4813ce2 commit 607c030
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
19 changes: 19 additions & 0 deletions home-config/config/desktop/sway.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 5 additions & 0 deletions home-config/dotfiles/eww/eww.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* { all: unset; }

.tray-items {
font-size: 1.35em;
}
47 changes: 47 additions & 0 deletions home-config/dotfiles/eww/eww.yuck
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(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 / 25, 0)]
}
:tooltip "${jq(EWW_BATTERY, "first(.[])").capacity}%"))

(defwidget _clock []
(label :text { formattime(EWW_TIME, "%R") }
:tooltip { formattime(EWW_TIME, "%F") }))

0 comments on commit 607c030

Please sign in to comment.