LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 10-02-2012, 02:31 PM   #1
rocketb
LQ Newbie
 
Registered: Apr 2012
Location: Florida
Distribution: RHEL, CentOS, Fedora
Posts: 15

Rep: Reputation: Disabled
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.

- rocketb
 
Old 10-04-2012, 02:38 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
"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.
http://standards.freedesktop.org/des...exec-variables

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.
 
Old 10-04-2012, 07:20 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Quote:
It would be extremely convenient if I could launch some scripts from a CD.
that is a very BAD idea

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
Code:
sh ProgramName.sh
 
Old 10-07-2012, 11:30 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.

http://www.reactivated.net/writing_udev_rules.html
 
Old 10-17-2012, 09:40 AM   #5
rocketb
LQ Newbie
 
Registered: Apr 2012
Location: Florida
Distribution: RHEL, CentOS, Fedora
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by David the H. View Post
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.
 
Old 10-17-2012, 09:45 AM   #6
rocketb
LQ Newbie
 
Registered: Apr 2012
Location: Florida
Distribution: RHEL, CentOS, Fedora
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by David the H. View Post
"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.
http://standards.freedesktop.org/des...exec-variables
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.
 
  


Reply

Tags
gnome, launcher



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
relative/absolute paths? mkohler Linux - Newbie 3 11-13-2010 03:45 AM
bash: ln and relative paths tortle Programming 8 05-10-2010 05:50 AM
Absolute and relative paths Gins Linux - General 6 11-08-2008 08:48 PM
periods in relative paths? kuplo Linux - Newbie 2 01-10-2006 05:19 AM
program that generates relative paths? TheMaXX Linux - Software 1 10-21-2003 02:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration