feat: make kitty boot in single instance mode

This commit is contained in:
2026-04-27 23:15:08 +02:00
parent 61971e2b37
commit 85cf1d92ca
2 changed files with 38 additions and 5 deletions
+36 -3
View File
@@ -1,7 +1,24 @@
{ config, ... }:
{ lib, config, ... }:
let
repo = config.repo;
kittySingleInstance =
pkgs:
pkgs.symlinkJoin {
name = "kitty-single";
paths = [ pkgs.kitty ];
meta = pkgs.kitty.meta;
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
# Wrap the binary to always launch as a single instance
wrapProgram $out/bin/kitty --add-flags "-1"
# Patch the .desktop file for strict app launchers like Vicinae
rm $out/share/applications/kitty.desktop
sed 's/Exec=kitty/Exec=kitty -1/g' ${pkgs.kitty}/share/applications/kitty.desktop > $out/share/applications/kitty.desktop
'';
};
mkTerminal =
{
desktopEntryName,
@@ -103,7 +120,7 @@ in
{
programs.kitty = {
enable = true;
package = pkgs.kitty;
package = kittySingleInstance pkgs;
font = {
name = "JetBrains Mono";
size = 11;
@@ -156,6 +173,22 @@ in
color17 ${palette.terminal.color17}
'';
};
systemd.user.services.kitty-daemon = {
Unit = {
Description = "Kitty Terminal Daemon";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Service = {
# Use the wrapped package (which already includes -1)
# Start it hidden and run an infinite dummy process so the instance stays alive
ExecStart = "${lib.getExe (kittySingleInstance pkgs)} --start-as=hidden ${pkgs.coreutils}/bin/tail -f /dev/null";
Restart = "on-failure";
};
};
};
flake.modules.homeManager.primary-terminal-foot = mkTerminal {
@@ -166,7 +199,7 @@ in
flake.modules.homeManager.primary-terminal-kitty = mkTerminal {
desktopEntryName = "kitty";
packageFor = pkgs: pkgs.kitty;
packageFor = pkgs: kittySingleInstance pkgs;
terminalModule = config.flake.modules.homeManager.terminal-kitty;
};
}
+2 -2
View File
@@ -54,8 +54,8 @@ in
homeModules.sops
homeModules.git
homeModules.ssh-client
homeModules.primary-terminal-foot
homeModules.terminal-kitty
homeModules.primary-terminal-kitty
homeModules.terminal-foot
homeModules.theme
homeModules.vicinae
homeModules.noctalia