1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

xdg-terminal-exec: init (#7527)

port xdg.terminal-exec from nixos to hm
This commit is contained in:
Viktor Titov 2025-07-25 17:54:38 +00:00 committed by GitHub
parent 80515f553d
commit 70c79ca6f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,49 @@
{
lib,
config,
pkgs,
...
}:
let
cfg = config.xdg.terminal-exec;
in
{
options = {
xdg.terminal-exec = {
enable = lib.mkEnableOption "xdg-terminal-exec, the [proposed](https://gitlab.freedesktop.org/xdg/xdg-specs/-/merge_requests/46) Default Terminal Execution Specification";
package = lib.mkPackageOption pkgs "xdg-terminal-exec" { nullable = true; };
settings = lib.mkOption {
type = with lib.types; attrsOf (listOf str);
default = { };
description = ''
Configuration options for the Default Terminal Execution Specification.
The keys are the desktop environments that are matched (case-insensitively) against `$XDG_CURRENT_DESKTOP`,
or `default` which is used when the current desktop environment is not found in the configuration.
The values are a list of terminals' [desktop file IDs](https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html#desktop-file-id) to try in order of decreasing priority.
'';
example = {
default = [ "kitty.desktop" ];
GNOME = [
"com.raggesilver.BlackBox.desktop"
"org.gnome.Terminal.desktop"
];
};
};
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile = lib.mapAttrs' (
desktop: terminals:
# map desktop name such as GNOME to `.config/gnome-xdg-terminals.list`, default to `.config/xdg-terminals.list`
lib.nameValuePair (
"${if desktop == "default" then "" else "${lib.toLower desktop}-"}xdg-terminals.list"
) { text = lib.concatLines terminals; }
) cfg.settings;
};
meta.maintainers = with lib.maintainers; [ nukdokplex ];
}