An alternative way, mostly for developers, is to create self-contained desktop launchers. The idea is to use a launcher that includes a tag under which there is the script; the launcher executes a command that:
- put the script into a temporary file
- run the script which deletes itself
Of course, the script should delete itself, for this reason, it's a good practice to start the script with rm $0
. Note that if the script needs to read the script itself, you will need to use rm $0
somewhere else...
You can use the following example stolen from my project:
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Launch Assistance
Comment=A simple app to setup remote assistance
Exec=ttt=/tmp/$(date +"%s%N").sh; tail -n+$(awk '/^#__SCRIPT__#/ {print NR + 1; exit 0; }' %k) %k > $ttt ; sh $ttt;
Icon=computer
Terminal=true
Type=Application
Categories=Network;Internet;Utilities;Administration;Settings;
#__SCRIPT__#
rm "$0"
# Put here the script
# note that if the script needs to read $0, you will have to edit it