1 # given a package with a $name.desktop file, makes a copy
5 { name # name of the desktop file (without .desktop)
6 , package # package where the desktop file resides in
7 , srcPrefix ? "" # additional prefix that the desktop file may have in the 'package'
11 , prependExtraArgs ? []
12 , appendExtraArgs ? []
15 # the builder requires that
16 # $package/share/applications/$name.desktop
20 name = "autostart-${name}";
24 escapeArgs = args: lib.escapeRegex (lib.escapeShellArgs args);
25 prependArgs = lib.optionalString (prependExtraArgs != []) "${escapeArgs prependExtraArgs} ";
26 appendArgs = lib.optionalString (appendExtraArgs != []) " ${escapeArgs appendExtraArgs}";
28 mkdir -p $out/etc/xdg/autostart
29 target=${name}.desktop
30 cp ${package}/share/applications/${srcPrefix}${name}.desktop $target
31 ${lib.optionalString (prependExtraArgs != [] || appendExtraArgs != []) ''
32 sed -i -r "s/(Exec=)([^ \n]*) *(.*)/\1\2 ${prependArgs}\3${appendArgs}/" $target
35 echo "X-KDE-autostart-phase=${phase}" >> $target
36 ${lib.optionalString (after != null) ''echo "${after}" >> $target''}
37 ${lib.optionalString (condition != null) ''echo "${condition}" >> $target''}
38 cp $target $out/etc/xdg/autostart
41 # this will automatically put 'package' in the environment when you
42 # put its startup item in there.
43 propagatedBuildInputs = [ package ];