feat: make kitty boot in single instance mode
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user