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:
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.
See here for the format details.
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.
so bad that even Microsoft has ( by default) DISABLED auto run .
you DO not want a computer that can do that automatically
but if you must
do not try a *.desktop file
use a shell script
but by default it will NOT be executable ( you really do NOT want a script on a cd to just run )
so you will have to call it in the terminal
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.
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.
|All times are GMT -5. The time now is 04:20 PM.|