diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-02-11 09:36:04 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-02-11 09:36:04 +0100 |
commit | 832479d3fd4b9352bef2192705ec2f9d7b435fd2 (patch) | |
tree | 34675d6a07a24112b57502623f263901f5fa2382 | |
parent | 0b68330543c86dbbcbca81bcc1f2d30cff83e2fe (diff) |
Run astal as systemd user service and have it reload upon monitor events
-rw-r--r-- | configuration/home-manager/hyprland.nix | 75 | ||||
-rw-r--r-- | flake.nix | 3 |
2 files changed, 46 insertions, 32 deletions
diff --git a/configuration/home-manager/hyprland.nix b/configuration/home-manager/hyprland.nix index c545102..77bb675 100644 --- a/configuration/home-manager/hyprland.nix +++ b/configuration/home-manager/hyprland.nix @@ -33,9 +33,7 @@ in "$terminal" = "alacritty"; "$mod" = "SUPER"; - exec-once = [ - "astal-bar" - ]; + exec-once = [ ]; debug = { "disable_logs" = false; @@ -135,32 +133,6 @@ in }; }; - programs.waybar.enable = true; - programs.waybar.settings = { - mainBar = { - layer = "top"; - position = "bottom"; - # output = monitor-names; - modules-left = [ - "hyprland/workspaces" - ]; - modules-right = [ - "clock" - "battery" - ]; - - "hyprland/workspaces" = { - all-outputs = true; - format-icons = { - active = ""; - default = ""; - }; - format = "{id} {icon}"; - window-rewrite-default = "*"; - }; - }; - }; - services.hyprpaper.enable = true; services.hyprpaper.settings = { preload = [ "${wallpaper}" ]; @@ -277,4 +249,49 @@ in email = "jaspert.ras@gmail.com"; pinentry = pkgs.pinentry-gnome3; }; + + systemd.user.services.hypr-events = { + Unit = { + Description = "Listens on Hypr's socket2 for events and handles them"; + After = [ "graphical-session-pre.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + Type = "exec"; + ExecStart = pkgs.writeShellScript "hyprevents" '' + reload_astal() { + systemctl --user restart astal + } + + handle() { + case $1 in + monitoradded*) reload_astal ;; + monitorremoved*) reload_astal ;; + esac + } + + ${pkgs.socat}/bin/socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done + ''; + }; + }; + + systemd.user.services.astal = { + Unit = { + Description = "Runs the astal bar instance"; + After = [ "graphical-session-pre.target" ]; + }; + + Service = { + Type = "exec"; + ExecStart = "${inputs.astal-bar.packages.x86_64-linux.default}/bin/astal-bar"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; } @@ -37,7 +37,6 @@ home-manager, agenix, update-systemd-resolved, - astal-bar, ... }: { @@ -49,7 +48,6 @@ { environment.systemPackages = [ agenix.packages."x86_64-linux".default - astal-bar.packages."x86_64-linux".default ]; } home-manager.nixosModules.home-manager @@ -66,7 +64,6 @@ { environment.systemPackages = [ agenix.packages."x86_64-linux".default - astal-bar.packages."x86_64-linux".default ]; } home-manager.nixosModules.home-manager |