Migrate graphical-session services to systemd

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-07-07 11:29:18 +03:00
parent 5308735a40
commit c3d89af891
11 changed files with 125 additions and 61 deletions

View File

@@ -15,3 +15,5 @@ App.config({
...forMonitors(bar), ...forMonitors(bar),
] ]
}); });
Utils.execAsync('systemd-notify --ready')

View File

@@ -20,7 +20,24 @@ in
output_path = "${hmConfig.xdg.configHome}/ags/theme.sass"; output_path = "${hmConfig.xdg.configHome}/ags/theme.sass";
}; };
wayland.windowManager.hyprland.initExtraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { systemd.user = {
targets.tray.Unit = {
BindsTo = [ "ags.service" ];
After = [ "graphical-session.target" "ags.service" ];
};
services.ags = {
Unit = {
Description = "Desktop widget shell";
BindsTo = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
Type = "notify";
NotifyAccess = "all";
ExecStart = lib.meta.getExe (pkgs.writeShellApplication {
name = "init-ags"; name = "init-ags";
runtimeInputs = with pkgs; [ runtimeInputs = with pkgs; [
inputs.ags.packages.${stdenv.hostPlatform.system}.default inputs.ags.packages.${stdenv.hostPlatform.system}.default
@@ -32,7 +49,12 @@ in
cliphist cliphist
libdbusmenu-gtk3 libdbusmenu-gtk3
]; ];
text = "ags &> /tmp/ags.log"; text = "exec ags";
})} &"; });
};
Install.WantedBy = [ "graphical-session.target" ];
};
};
}; };
} }

View File

@@ -6,7 +6,10 @@
home-manager.users.${user.name} = { home-manager.users.${user.name} = {
services.blueman-applet.enable = true; services.blueman-applet.enable = true;
systemd.user.services.mpris-proxy = { systemd.user.services = {
blueman-applet.Unit.After = [ "graphical-session.target" ];
mpris-proxy = {
Unit = { Unit = {
Description = "MPRIS proxy"; Description = "MPRIS proxy";
Requires = [ "sound.target" ]; Requires = [ "sound.target" ];
@@ -14,7 +17,8 @@
}; };
Service.ExecStart = "${pkgs.bluez}/bin/mpris-proxy"; Service.ExecStart = "${pkgs.bluez}/bin/mpris-proxy";
Intall.WantedBy = [ "default.target" ]; Install.WantedBy = [ "default.target" ];
};
}; };
}; };
} }

View File

@@ -30,7 +30,7 @@ in
theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication {
name = "reload-btop"; name = "reload-btop";
runtimeInputs = with pkgs; [ procps ]; runtimeInputs = with pkgs; [ procps ];
text = "pkill btop -SIGUSR2"; text = "exec pkill btop -SIGUSR2";
})} &"; })} &";
}; };
} }

View File

@@ -10,26 +10,44 @@ in
persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/cliphist" ]; persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/cliphist" ];
}; };
wayland.windowManager.hyprland = { systemd.user.services = {
initExtraConfig = '' cliphist-text = {
${lib.meta.getExe (pkgs.writeShellApplication { Unit = {
Description = "Clipboard manager (text)";
BindsTo = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service.ExecStart = lib.meta.getExe (pkgs.writeShellApplication {
name = "init-cliphist-text"; name = "init-cliphist-text";
runtimeInputs = with pkgs; [ wl-clipboard cliphist ]; runtimeInputs = with pkgs; [ wl-clipboard cliphist ];
text = "wl-paste --type text --watch cliphist store"; text = "exec wl-paste --type text --watch cliphist store";
})} & });
${lib.meta.getExe (pkgs.writeShellApplication { Install.WantedBy = [ "graphical-session.target" ];
};
cliphist-image = {
Unit = {
Description = "Clipboard manager (images)";
BindsTo = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service.ExecStart = lib.meta.getExe (pkgs.writeShellApplication {
name = "init-cliphist-image"; name = "init-cliphist-image";
runtimeInputs = with pkgs; [ wl-clipboard cliphist ]; runtimeInputs = with pkgs; [ wl-clipboard cliphist ];
text = "wl-paste --type image --watch cliphist store"; text = "exec wl-paste --type image --watch cliphist store";
})} & });
'';
settings.bind = [ Install.WantedBy = [ "graphical-session.target" ];
};
};
wayland.windowManager.hyprland.settings.bind = [
"$mod, v, exec, cliphist list | ${lib.meta.getExe pkgs.rofi-wayland} -cache-dir ${hmConfig.xdg.cacheHome}/rofi -dmenu -display-columns 2 | cliphist decode | wl-copy" "$mod, v, exec, cliphist list | ${lib.meta.getExe pkgs.rofi-wayland} -cache-dir ${hmConfig.xdg.cacheHome}/rofi -dmenu -display-columns 2 | cliphist decode | wl-copy"
"$mod_CTRL, v, exec, cliphist list | ${lib.meta.getExe pkgs.rofi-wayland} -cache-dir ${hmConfig.xdg.cacheHome}/rofi -dmenu -display-columns 2 | cliphist delete" "$mod_CTRL, v, exec, cliphist list | ${lib.meta.getExe pkgs.rofi-wayland} -cache-dir ${hmConfig.xdg.cacheHome}/rofi -dmenu -display-columns 2 | cliphist delete"
"$mod_CTRL_SHIFT, v, exec, cliphist wipe" "$mod_CTRL_SHIFT, v, exec, cliphist wipe"
]; ];
}; };
};
} }

View File

@@ -136,7 +136,7 @@ in
theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication {
name = "reload-hyprland"; name = "reload-hyprland";
runtimeInputs = with pkgs; [ hyprland ]; runtimeInputs = with pkgs; [ hyprland ];
text = "hyprctl reload"; text = "exec hyprctl reload";
})} &"; })} &";
home.sessionVariables.NIXOS_OZONE_WL = "1"; home.sessionVariables.NIXOS_OZONE_WL = "1";

View File

@@ -19,7 +19,7 @@ in
swappyWrapper = lib.meta.getExe (pkgs.writeShellApplication { swappyWrapper = lib.meta.getExe (pkgs.writeShellApplication {
name = "swappy-wrapper"; name = "swappy-wrapper";
runtimeInputs = with pkgs; [ swappy ]; runtimeInputs = with pkgs; [ swappy ];
text = "swappy -f \"$1\""; text = "exec swappy -f \"$1\"";
}); });
in in
[ [

View File

@@ -30,7 +30,7 @@ in
theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { theme.extraConfig = "${lib.meta.getExe (pkgs.writeShellApplication {
name = "reload-kitty"; name = "reload-kitty";
runtimeInputs = with pkgs; [ procps ]; runtimeInputs = with pkgs; [ procps ];
text = "pkill kitty -SIGUSR1"; text = "exec pkill kitty -SIGUSR1";
})} &"; })} &";
home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ]; home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ];

View File

@@ -76,7 +76,7 @@ in
name = "theme-matugen"; name = "theme-matugen";
runtimeInputs = with pkgs; [ matugen ]; runtimeInputs = with pkgs; [ matugen ];
text = '' text = ''
matugen image "${hmConfig.theme.configDir}/wallpaper" \ exec matugen image "${hmConfig.theme.configDir}/wallpaper" \
--type scheme-${hmConfig.theme.flavour} \ --type scheme-${hmConfig.theme.flavour} \
--mode "$(cat "${hmConfig.theme.configDir}/mode")" \ --mode "$(cat "${hmConfig.theme.configDir}/mode")" \
--contrast ${builtins.toString hmConfig.theme.contrast} --contrast ${builtins.toString hmConfig.theme.contrast}

View File

@@ -1,5 +1,8 @@
{ user ? throw "user argument is required" }: { ... }: { user ? throw "user argument is required" }: { ... }:
{ {
home-manager.users.${user.name}.services.network-manager-applet.enable = true; home-manager.users.${user.name} = {
services.network-manager-applet.enable = true;
systemd.user.services.network-manager-applet.Unit.After = [ "graphical-session.target" ];
};
} }

View File

@@ -2,6 +2,14 @@
let let
hmConfig = config.home-manager.users.${user.name}; hmConfig = config.home-manager.users.${user.name};
themeSwww = lib.meta.getExe (pkgs.writeShellApplication {
name = "theme-swww";
runtimeInputs = with pkgs; [
coreutils-full
swww
];
text = "exec swww img \"${hmConfig.theme.configDir}/wallpaper\"";
});
in in
{ {
home-manager.users.${user.name} = { home-manager.users.${user.name} = {
@@ -10,27 +18,34 @@ in
persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ]; persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ];
}; };
wayland.windowManager.hyprland.initExtraConfig = "${lib.meta.getExe (pkgs.writeShellApplication { systemd.user.services.swww = {
Unit = {
Description = "Wallpaper daemon";
BindsTo = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
Type = "forking";
ExecStart = lib.meta.getExe (pkgs.writeShellApplication {
name = "init-swww"; name = "init-swww";
runtimeInputs = with pkgs; [
coreutils-full
swww
];
text = ''
swww-daemon &> /tmp/swww.log
while ! swww query &> /dev/null; do
sleep 0.1
done
swww img "${hmConfig.theme.configDir}/wallpaper"
'';
})} &";
theme.extraConfig = lib.mkAfter "${lib.meta.getExe (pkgs.writeShellApplication {
name = "theme-swww";
runtimeInputs = with pkgs; [ swww ]; runtimeInputs = with pkgs; [ swww ];
text = "swww img \"${hmConfig.theme.configDir}/wallpaper\""; text = "exec swww init";
})} &"; });
ExecStartPost = themeSwww;
ExecStop = lib.meta.getExe (pkgs.writeShellApplication {
name = "kill-swww";
runtimeInputs = with pkgs; [ swww ];
text = "exec swww kill";
});
};
Install.WantedBy = [ "graphical-session.target" ];
};
theme.extraConfig = lib.mkAfter "${themeSwww} &";
}; };
} }