diff --git a/modules/misc/xdg-desktop-entries.nix b/modules/misc/xdg-desktop-entries.nix index ca61a998..c0b110fa 100644 --- a/modules/misc/xdg-desktop-entries.nix +++ b/modules/misc/xdg-desktop-entries.nix @@ -17,11 +17,8 @@ let # and `extraDesktopEntries` by `settings`, # to match what's commonly used by other home manager modules. - # `startupNotify` on makeDesktopItem asks for "true" or "false" strings, - # for usability's sake we ask for a boolean. - # `mimeType` and `categories` on makeDesktopItem ask for a string in the format "one;two;three;", - # for the same reason we ask for a list of strings. + # for usability's sake we ask for a list of strings. # Descriptions are taken from the desktop entry spec: # https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys @@ -89,6 +86,23 @@ let default = null; }; + noDisplay = mkOption { + description = '' + Means "this application exists, but don't display it in the menus". + This can be useful to e.g. associate this application with MIME types. + ''; + type = types.nullOr types.bool; + default = null; + }; + + prefersNonDefaultGPU = mkOption { + description = '' + If true, the application prefers to be run on a more powerful discrete GPU if available. + ''; + type = types.nullOr types.bool; + default = null; + }; + extraConfig = mkOption { description = '' Extra configuration. Will be appended to the end of the file and @@ -123,26 +137,20 @@ let #formatting helpers ifNotNull = a: a': if a == null then null else a'; - stringBool = bool: if bool then "true" else "false"; semicolonList = list: (concatStringsSep ";" list) + ";"; # requires trailing semicolon #passes config options to makeDesktopItem in expected format makeFile = name: config: pkgs.makeDesktopItem { - name = name; - type = config.type; - exec = config.exec; - icon = config.icon; - comment = config.comment; - terminal = config.terminal; + inherit name; + inherit (config) + type exec icon comment terminal genericName startupNotify noDisplay + prefersNonDefaultGPU; desktopName = config.name; - genericName = config.genericName; mimeType = ifNotNull config.mimeType (semicolonList config.mimeType); categories = ifNotNull config.categories (semicolonList config.categories); - startupNotify = - ifNotNull config.startupNotify (stringBool config.startupNotify); extraEntries = config.extraConfig; extraDesktopEntries = config.settings; }; diff --git a/tests/modules/misc/xdg/desktop-entries.nix b/tests/modules/misc/xdg/desktop-entries.nix index 098aa7ee..adb6e31e 100644 --- a/tests/modules/misc/xdg/desktop-entries.nix +++ b/tests/modules/misc/xdg/desktop-entries.nix @@ -16,6 +16,8 @@ with lib; mimeType = [ "text/html" "text/xml" ]; categories = [ "Network" "WebBrowser" ]; startupNotify = false; + noDisplay = false; + prefersNonDefaultGPU = false; extraConfig = '' [X-ExtraSection] Exec=foo -o diff --git a/tests/modules/misc/xdg/desktop-full-expected.desktop b/tests/modules/misc/xdg/desktop-full-expected.desktop index fd5ace1b..7776e8b7 100644 --- a/tests/modules/misc/xdg/desktop-full-expected.desktop +++ b/tests/modules/misc/xdg/desktop-full-expected.desktop @@ -8,6 +8,8 @@ Icon=test Keywords=calc;math MimeType=text/html;text/xml; Name=Test +NoDisplay=false +PrefersNonDefaultGPU=false StartupNotify=false Terminal=true Type=Application