Sample Header Ad - 728x90

How to get under Linux Mint LMDE5, the path of a launcher through bash commands stored in the launcher?

3 votes
1 answer
292 views
Linux Mint LMDE5 is a Debian derivative. On the desktop you can create launchers p.e. via GUI, with which you can not only link something, but also store smaller bash code in it. After creating, the launcher can moved to other folder. Location of the follow .sh file and launcher: /home/user_name/desktop/a/b/c With the following code you can print the path to a bash file when you execute it. Content of the .sh file: #!/bin/bash script_path=$(dirname "$(readlink -f "$0")")"/" echo "$script_path" sleep 100 Output of the .sh file: /home/user_name/desktop/a/b/c **The not working launcher "solution":** Content of the launcher file: bash -c 'launcher_path=$(dirname "$(readlink -f "$0")")"/"; echo "$launcher_path"; sleep 100' Output of launcher by terminal: /home/user_name/ # but that should be: /home/user_name/desktop/a/b/c **What does "launcher" mean:** This is a .desktop file, which is common on Linux Mint and LMDE. The file has similarities in structure and tasks to a ".lnk" file under Windows. Two How too`s for creating "launcher" by Linux Mint GUI: * https://community.linuxmint.com/tutorial/view/2074 * https://www.youtube.com/watch?v=0CFNCkMKp44 Sample content of a "launcher" (.desktop file): [Desktop Entry] Name=test Exec=bash -c 'xed /home/user/desktop/sample_file.txt' Comment= Terminal=true Icon=cinnamon-panel-launcher Type=Application Name[de_DE]=Sample for a launcher file, which open a textfile, which is located on desktop. **Concretization:** Only a suitable modification of the following command line of the launcher is searched: bash -c 'launcher_path=$(dirname "$(readlink -f "$0")")"/"; echo "$launcher_path"; sleep 100' It is not looking for any additional scripts or modifications of the operating system.
Asked by Alfred.37 (129 rep)
Apr 1, 2023, 05:42 PM
Last activity: Apr 5, 2023, 03:10 PM