mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19: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:
parent
65e5b835a9
commit
426ab2cf11
3 changed files with 26 additions and 14 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue