From d8f75f167aeb238f7e94030b501d957481d19c36 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Tue, 2 Mar 2021 09:31:22 +0100 Subject: [PATCH] sway: Manage waybar with systemd --- users/simon/modules/sway.nix | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/users/simon/modules/sway.nix b/users/simon/modules/sway.nix index 1b70af0..f32017e 100644 --- a/users/simon/modules/sway.nix +++ b/users/simon/modules/sway.nix @@ -164,9 +164,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable { "--locked ${cfg.modifier}+q" = ''exec 'test $(swaymsg -t get_outputs | ${pkgs.jq}/bin/jq "[.[].dpms] | any") = "true" && swaymsg "output * dpms off" || swaymsg "output * dpms on"''; }; - bars = [ - { command = "waybar"; } - ]; + bars = [ ]; # managed as systemd user unit assigns = { "2" = [ @@ -253,7 +251,6 @@ lib.mkIf nixosConfig.sbruder.gui.enable { alacritty # terminal brightnessctl # control screen brightness sway-contrib.grimshot # screenshots - (waybar.override { pulseSupport = true; }) # better status bar FIXME: Remove override with 21.03 (https://github.com/NixOS/nixpkgs/pull/98490) wdisplays # graphical output manager ]; @@ -460,6 +457,26 @@ lib.mkIf nixosConfig.sbruder.gui.enable { ''; }; + systemd.user.services.waybar = { + Unit = { + Description = "Highly customizable Wayland bar for Sway and Wlroots based compositors."; + Documentation = "https://github.com/Alexays/Waybar/wiki/"; + PartOf = [ "sway-session.target" ]; + }; + + Install.WantedBy = [ "sway-session.target" ]; + + Service = { + # ensure sway is already started, otherwise workspaces will not work + ExecStartPre = "${config.wayland.windowManager.sway.package}/bin/swaymsg"; + # FIXME: Remove override with 21.05 (https://github.com/NixOS/nixpkgs/pull/98490) + ExecStart = "${pkgs.waybar.override { pulseSupport = true; }}/bin/waybar"; + ExecReload = "${pkgs.utillinux}/bin/kill -SIGUSR2 $MAINPID"; + Restart = "on-failure"; + RestartSec = "1s"; + }; + }; + programs.mako = { enable = true;