From 189014264b1d99f65dc42e977ab3db4c229ac64b Mon Sep 17 00:00:00 2001 From: EdenQwQ Date: Sun, 9 Mar 2025 11:14:04 +0800 Subject: [PATCH] optimize autostart --- home/default.nix | 2 +- home/programs/desktop/niri/autostart.nix | 18 ++++-------------- home/programs/desktop/scripts/tofi/powermenu | 1 + 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/home/default.nix b/home/default.nix index 1ef20ee..4f3a6c5 100644 --- a/home/default.nix +++ b/home/default.nix @@ -40,7 +40,7 @@ lib.hm.dag.entryAfter [ "niri-transition" ] # bash '' - run --quiet ${pkgs.systemd}/bin/systemctl --user restart waybar.service + run --quiet ${pkgs.systemd}/bin/systemctl --user reload waybar.service ''; }; diff --git a/home/programs/desktop/niri/autostart.nix b/home/programs/desktop/niri/autostart.nix index c5a1d0d..af2d207 100644 --- a/home/programs/desktop/niri/autostart.nix +++ b/home/programs/desktop/niri/autostart.nix @@ -12,6 +12,7 @@ let swww clash-meta wlsunset + systemd killall ]; extraShellCheckFlags = [ ]; @@ -27,7 +28,7 @@ let swww-daemon & clash-meta -d ~/.config/clash & wlsunset -s 00:00 -S 00:00 -t 5000 -T 5001 & - niri-blur-wallpaper & + systemctl --user start waybar.service blueman-applet.service 'app-nm\\x2dapplet@autostart.service' app-org.fcitx.Fcitx5@autostart.service niri-blur-wallpaper.service ''; }; niri-blur-wallpaper = pkgs.writers.writePython3Bin "niri-blur-wallpaper" { doCheck = false; } '' @@ -130,21 +131,16 @@ in systemd.user.services.niri-blur-wallpaper = { Unit = { Description = "Niri Blur Wallpaper"; - BindsTo = [ "graphical-session.target" ]; - Before = [ "graphical-session.target" ]; - Wants = [ "graphical-session-pre.target" ]; - After = [ "graphical-session-pre.target" ]; + After = [ "graphical-session.target" ]; + PartOf = [ "graphical-session.target" ]; }; Install = { WantedBy = [ "graphical-session.target" ]; - Wants = [ "xdg-desktop-autostart.target" ]; - After = [ "xdg-desktop-autostart.target" ]; }; Service = { Type = "simple"; ExecStart = "${niri-blur-wallpaper}/bin/niri-blur-wallpaper"; Restart = "on-failure"; - RestartSec = "5s"; }; }; home.activation.restart-niri-blur-wallpaper = @@ -153,11 +149,5 @@ in ''run --quiet ${pkgs.systemd}/bin/systemctl --user restart niri-blur-wallpaper''; programs.niri.settings.spawn-at-startup = [ { command = [ "${niri-autostart}/bin/niri-autostart" ]; } - { - command = [ - "fcitx5" - "-d" - ]; - } ]; } diff --git a/home/programs/desktop/scripts/tofi/powermenu b/home/programs/desktop/scripts/tofi/powermenu index 2e6f072..53bace2 100755 --- a/home/programs/desktop/scripts/tofi/powermenu +++ b/home/programs/desktop/scripts/tofi/powermenu @@ -16,6 +16,7 @@ elif [ "$entry" = "mode" ]; then elif [ "$entry" = "exit" ]; then if [ "$(~/scripts/tofi/confirm "exit?")" = "yes" ]; then doas killall swhkd swhks + systemctl --user stop waybar.service blueman-applet.service 'app-nm\\x2dapplet@autostart.service' app-org.fcitx.Fcitx5@autostart.service niri-blur-wallpaper.service wayland-logout fi fi