Using relative paths in GNOME launcher - workarounds?
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using relative paths in GNOME launcher - workarounds?
It would be extremely convenient if I could launch some scripts from a CD. I usually launch these scripts using GNOME desktop launchers. I would like the launcher to be able to look at its own working directory, and launch a script in a directory beneath it. The problem is, the launcher file syntax doesn't understand relative paths. Which would force me to use absolute paths, which means the CD always has to have the same mount point. If I could use relative paths, it wouldn't matter, and everything could be copied to the hard drive and everything would still work.
Launcher can't understand this because it doesn't understand shell variables, but this is basically what I want:
Exec=$PWD/scripts/myscript
or
Exec=./scripts/myscript
I tried using a command like this in the launcher:
Exec=bash -c "$PWD/scripts/myscript"
However, when bash is called, it is a new instance of bash, and so the working directory becomes default (/home/username), not the directory that contains the launcher.
I've nearly resigned myself to having to having to use absolute paths, but if anyone can figure out a way to trick launchers into doing what I want, it would be appreciated.
"Launchers" generally use the standardized desktop file syntax. In this syntax the exec line accepts %f style entries to stand for file/directory names passed to them.
I don't know if you can get it to do what you want, though. I don't even know if there is a "working directory" involved. But I suggest taking a read of the above.
To be fair, I didn't see anything saying he wanted autorun, just that he wanted to be able to manually launch a script that exists on a cd from a desktop icon or something.
Actually, I'm not completely sure I understand the entire problem. I think it has to do with the disc device being variable, so he can't have his desktop file point to it directly.
A better solution would perhaps then be to configure udev to create a specific device symlink for his drive and/or certain cds. Then he would always be ensured of a permanent path.
To be fair, I didn't see anything saying he wanted autorun, just that he wanted to be able to manually launch a script that exists on a cd from a desktop icon or something.
Actually, I'm not completely sure I understand the entire problem. I think it has to do with the disc device being variable, so he can't have his desktop file point to it directly.
A better solution would perhaps then be to configure udev to create a specific device symlink for his drive and/or certain cds. Then he would always be ensured of a permanent path.
Correct, I don't want autorun, I just want to be able to launch the script on the cd from a desktop launcher.
I briefly looked at that udev rules page, but that seems to be able device naming, which isn't really the problem. The device is always /dev/cdrom. The mount point is the variable, as GNOME creates a mount point using the label of the cd (e.g. /media/mydiscname). I can use that path in the script, however, I will have to make sure that the CDs are always made with the same volume label. Also, it would break if copied to the hard drive.
Essentially, I'm trying to make it really easy for the end user. I want them to pop in the CD, double-click on the script they need, and they're done. Also, trying to avoid any pitfalls in the future if someone other than myself has to modify the CD.
"Launchers" generally use the standardized desktop file syntax. In this syntax the exec line accepts %f style entries to stand for file/directory names passed to them.
The %k variable almost does what I want. However it also includes the name of the desktop launcher as well. For example, it would translate to "/media/discname/launcher.desktop". I need to call a script from "/media/discname/scripts/scriptname.bash". If I could strip out that launcher name, it'd be perfect.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.