sway: Manage waybar with systemd

This commit is contained in:
Simon Bruder 2021-03-02 09:31:22 +01:00
parent c7349c4939
commit d8f75f167a
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -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;