1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

xdg-desktop-entries: reflect changes in makeDesktopItem API (#2496)

Based on nixpkgs commit c4b3aa62608d592d8a983be685f7e82000f4de30
stringBool is not needed because makeDesktopItem handles converting boolean parameters to string,
and noDisplay and prefersNonDefaultGPU parameters have been added.
This commit is contained in:
cwyc 2022-01-04 22:58:20 -05:00 committed by GitHub
parent 65e5b835a9
commit 426ab2cf11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 14 deletions

View file

@ -17,11 +17,8 @@ let
# and `extraDesktopEntries` by `settings`, # and `extraDesktopEntries` by `settings`,
# to match what's commonly used by other home manager modules. # 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;", # `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: # Descriptions are taken from the desktop entry spec:
# https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys # https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys
@ -89,6 +86,23 @@ let
default = null; 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 { extraConfig = mkOption {
description = '' description = ''
Extra configuration. Will be appended to the end of the file and Extra configuration. Will be appended to the end of the file and
@ -123,26 +137,20 @@ let
#formatting helpers #formatting helpers
ifNotNull = a: a': if a == null then null else a'; ifNotNull = a: a': if a == null then null else a';
stringBool = bool: if bool then "true" else "false";
semicolonList = list: semicolonList = list:
(concatStringsSep ";" list) + ";"; # requires trailing semicolon (concatStringsSep ";" list) + ";"; # requires trailing semicolon
#passes config options to makeDesktopItem in expected format #passes config options to makeDesktopItem in expected format
makeFile = name: config: makeFile = name: config:
pkgs.makeDesktopItem { pkgs.makeDesktopItem {
name = name; inherit name;
type = config.type; inherit (config)
exec = config.exec; type exec icon comment terminal genericName startupNotify noDisplay
icon = config.icon; prefersNonDefaultGPU;
comment = config.comment;
terminal = config.terminal;
desktopName = config.name; desktopName = config.name;
genericName = config.genericName;
mimeType = ifNotNull config.mimeType (semicolonList config.mimeType); mimeType = ifNotNull config.mimeType (semicolonList config.mimeType);
categories = categories =
ifNotNull config.categories (semicolonList config.categories); ifNotNull config.categories (semicolonList config.categories);
startupNotify =
ifNotNull config.startupNotify (stringBool config.startupNotify);
extraEntries = config.extraConfig; extraEntries = config.extraConfig;
extraDesktopEntries = config.settings; extraDesktopEntries = config.settings;
}; };

View file

@ -16,6 +16,8 @@ with lib;
mimeType = [ "text/html" "text/xml" ]; mimeType = [ "text/html" "text/xml" ];
categories = [ "Network" "WebBrowser" ]; categories = [ "Network" "WebBrowser" ];
startupNotify = false; startupNotify = false;
noDisplay = false;
prefersNonDefaultGPU = false;
extraConfig = '' extraConfig = ''
[X-ExtraSection] [X-ExtraSection]
Exec=foo -o Exec=foo -o

View file

@ -8,6 +8,8 @@ Icon=test
Keywords=calc;math Keywords=calc;math
MimeType=text/html;text/xml; MimeType=text/html;text/xml;
Name=Test Name=Test
NoDisplay=false
PrefersNonDefaultGPU=false
StartupNotify=false StartupNotify=false
Terminal=true Terminal=true
Type=Application Type=Application