make-desktopitem: make genericName optional
This commit is contained in:
parent
d1d9186b6b
commit
f099df3c80
@ -1,36 +1,48 @@
|
||||
{stdenv}:
|
||||
{stdenv, lib}:
|
||||
{ name
|
||||
, type ? "Application"
|
||||
, exec
|
||||
, icon ? ""
|
||||
, comment ? ""
|
||||
, icon ? null
|
||||
, comment ? null
|
||||
, terminal ? "false"
|
||||
, desktopName
|
||||
, genericName
|
||||
, mimeType ? ""
|
||||
, genericName ? null
|
||||
, mimeType ? null
|
||||
, categories ? "Application;Other;"
|
||||
, startupNotify ? null
|
||||
, extraEntries ? ""
|
||||
, extraEntries ? null
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "${name}.desktop";
|
||||
buildCommand = ''
|
||||
|
||||
buildCommand = let
|
||||
|
||||
optionalEntriesList = [{k="Icon"; v=icon;}
|
||||
{k="Comment"; v=comment;}
|
||||
{k="GenericName"; v=genericName;}
|
||||
{k="MimeType"; v=mimeType;}
|
||||
{k="StartupNotify"; v=startupNotify;}];
|
||||
|
||||
valueNotNull = {k, v}: v != null;
|
||||
entriesToKeep = builtins.filter valueNotNull optionalEntriesList;
|
||||
|
||||
mkEntry = {k, v}: k + "=" + v;
|
||||
optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep;
|
||||
|
||||
in
|
||||
''
|
||||
mkdir -p $out/share/applications
|
||||
cat > $out/share/applications/${name}.desktop <<EOF
|
||||
[Desktop Entry]
|
||||
Type=${type}
|
||||
Exec=${exec}
|
||||
Icon=${icon}
|
||||
Comment=${comment}
|
||||
Terminal=${terminal}
|
||||
Name=${desktopName}
|
||||
GenericName=${genericName}
|
||||
MimeType=${mimeType}
|
||||
Categories=${categories}
|
||||
${optionalEntriesString}
|
||||
${if extraEntries == null then ''EOF'' else ''
|
||||
${extraEntries}
|
||||
${if startupNotify == null then ''EOF'' else ''
|
||||
StartupNotify=${startupNotify}
|
||||
EOF''}
|
||||
'';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user