Unverified Commit c4e73af4 authored by Pol Dellaiera's avatar Pol Dellaiera Committed by GitHub
Browse files

Merge pull request #284161 from felschr/make-startupitem-extra-args

make-startupitem: add `prependExtraArgs` and `appendExtraArgs`
parents 327996d1 c9de424f
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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''}