From 403c68323336651492c76ef11c49c917aefef507 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Fri, 9 Sep 2022 14:11:48 +0100 Subject: [PATCH] home-manager/gui: Ensure sway is ready before graphical session --- home-manager/modules/gui/default.nix | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/home-manager/modules/gui/default.nix b/home-manager/modules/gui/default.nix index 00c4d23..98d8c93 100644 --- a/home-manager/modules/gui/default.nix +++ b/home-manager/modules/gui/default.nix @@ -32,6 +32,28 @@ in }; } (mkIf cfg.standalone { + systemd.user = { + services = { + wait-for-sway = { + Unit = { + Description = "Wait for sway to be ready"; + Before = "graphical-session.target"; + }; + Service = { + Type = "oneshot"; + ExecStart = toString (pkgs.writeShellScript "wait-for-sway.sh" '' + until ${pkgs.sway}/bin/swaymsg -t get_version -q; do + ${pkgs.coreutils}/bin/sleep 0.1 + done + ${pkgs.coreutils}/bin/sleep 0.5 + ''); + RemainAfterExit = true; + }; + Install.RequiredBy = [ "sway-session.target" ]; + }; + }; + }; + xdg = { userDirs = { enable = true; @@ -84,7 +106,7 @@ in "${mod}+d" = null; "${mod}+x" = "exec ${cfg.menu}"; "${mod}+q" = "kill"; - "${mod}+Shift+q" = "exec swaynag -t warning -m 'bruh you really wanna kill sway?' -b 'ye' 'swaymsg exit'"; + "${mod}+Shift+q" = "exec swaynag -t warning -m 'bruh you really wanna kill sway?' -b 'ye' 'systemctl --user stop graphical-session.target && swaymsg exit'"; }; menu = "rofi -show run";