mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 03:30:45 +00:00
Merge pull request #284161 from felschr/make-startupitem-extra-args
make-startupitem: add `prependExtraArgs` and `appendExtraArgs`
This commit is contained in:
commit
c4e73af4dd
|
@ -8,6 +8,8 @@
|
|||
, after ? null
|
||||
, condition ? null
|
||||
, phase ? "2"
|
||||
, prependExtraArgs ? []
|
||||
, appendExtraArgs ? []
|
||||
}:
|
||||
|
||||
# the builder requires that
|
||||
|
@ -18,10 +20,17 @@ stdenv.mkDerivation {
|
|||
name = "autostart-${name}";
|
||||
priority = 5;
|
||||
|
||||
buildCommand = ''
|
||||
buildCommand = let
|
||||
escapeArgs = args: lib.escapeRegex (lib.escapeShellArgs args);
|
||||
prependArgs = lib.optionalString (prependExtraArgs != []) "${escapeArgs prependExtraArgs} ";
|
||||
appendArgs = lib.optionalString (appendExtraArgs != []) " ${escapeArgs appendExtraArgs}";
|
||||
in ''
|
||||
mkdir -p $out/etc/xdg/autostart
|
||||
target=${name}.desktop
|
||||
cp ${package}/share/applications/${srcPrefix}${name}.desktop $target
|
||||
${lib.optionalString (prependExtraArgs != [] || appendExtraArgs != []) ''
|
||||
sed -i -r "s/(Exec=)([^ ]*) (.*)/\1\2 ${prependArgs}\3${appendArgs}/" $target
|
||||
''}
|
||||
chmod +rw $target
|
||||
echo "X-KDE-autostart-phase=${phase}" >> $target
|
||||
${lib.optionalString (after != null) ''echo "${after}" >> $target''}
|
||||
|
|
Loading…
Reference in a new issue