diff --git a/users/richie/home/gui/default.nix b/users/richie/home/gui/default.nix index 2a22b6b..2af3e71 100644 --- a/users/richie/home/gui/default.nix +++ b/users/richie/home/gui/default.nix @@ -7,6 +7,7 @@ ./firefox ./kitty.nix ./llm_tools.nix + ./t3_code ./vscode ]; diff --git a/users/richie/home/gui/t3_code/default.nix b/users/richie/home/gui/t3_code/default.nix new file mode 100644 index 0000000..9b5bff9 --- /dev/null +++ b/users/richie/home/gui/t3_code/default.nix @@ -0,0 +1,36 @@ +{ + config, + lib, + pkgs, + ... +}: +let + t3-code = pkgs.writeShellApplication { + name = "t3-code"; + runtimeInputs = with pkgs; [ + coreutils + kdePackages.kdialog + ]; + text = builtins.readFile ./launch.sh; + }; +in +{ + home = { + # AppImages are runnable from a shell as well + sessionPath = [ "${config.home.homeDirectory}/app_images" ]; + packages = [ t3-code ]; + }; + + # KDE builds its menu from desktop entries, not from PATH + xdg.desktopEntries.t3-code = { + name = "T3 Code"; + genericName = "Code Editor"; + comment = "Newest T3 Code AppImage in ~/app_images"; + exec = "${lib.getExe t3-code} %U"; + icon = "${./icon.png}"; + terminal = false; + categories = [ "Development" ]; + startupNotify = true; + settings.StartupWMClass = "t3code"; + }; +} diff --git a/users/richie/home/gui/t3_code/icon.png b/users/richie/home/gui/t3_code/icon.png new file mode 100644 index 0000000..54f96f8 Binary files /dev/null and b/users/richie/home/gui/t3_code/icon.png differ diff --git a/users/richie/home/gui/t3_code/launch.sh b/users/richie/home/gui/t3_code/launch.sh new file mode 100644 index 0000000..bfb1c42 --- /dev/null +++ b/users/richie/home/gui/t3_code/launch.sh @@ -0,0 +1,25 @@ +# Launch the newest T3 Code AppImage in the app image directory. +# +# The nightly builds carry the version in the file name, so the file to run is +# resolved at launch time rather than baked into the desktop entry. +# No shebang: this is wrapped by writeShellApplication, which supplies one. + +dir="${T3_CODE_DIR:-$HOME/app_images}" + +shopt -s nullglob +images=("$dir"/T3-Code-*.AppImage) + +if [ "${#images[@]}" -eq 0 ]; then + msg="No T3 Code AppImage found in $dir" + echo "$msg" >&2 + # launched from KDE there is no terminal to read, so say it on screen too + kdialog --error "$msg" || true + exit 1 +fi + +img="$(printf '%s\n' "${images[@]}" | sort -V | tail -n1)" +[ -x "$img" ] || chmod +x "$img" + +# --no-sandbox matches the AppImage's own desktop entry; binfmt hands the +# AppImage off to appimage-run. +exec "$img" --no-sandbox "$@"