Environment variable for selected object?

Forum rules
Before you post please read how to get help
Level 1
Level 1
Posts: 5
Joined: Thu Feb 16, 2012 9:26 am

Environment variable for selected object?

Postby tchocolo » Mon Jul 09, 2012 2:10 pm

I am trying to write a bash script that will write a nautilus desktop config file (.desktop extention) for the currently selected object.
I have had some sucess using nautilus scipts because they have the environment variable $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
-perfect! using this I can create a nautilus-script (stored in ~/.gnome2/nautilus-scripts) to create a .desktop file when I right-click on an object which acts very much like a windows shortcut!

I now want to do this from a keyboard shortcut which would trigger this bash file but listing bash enviroment variables with
there is nothing relevent.
Can anyone suggest anything please, I am a relative noob (2years with Linux) but dont hold back.

Level 1
Level 1
Posts: 5
Joined: Thu Feb 16, 2012 9:26 am

Re: Environment variable for selected object?

Postby tchocolo » Thu Aug 16, 2012 12:09 pm

I am surprised that no one has come across this, Even if you dont have the solution I would welcome comments on the usefulness of this because I am sure I am not the only one who organises his data in the following way:
If you have a home server or NAS and possibly the same storage mirrored with the same structure on more than one site.
and you have hetrogenous (ie mixed Linux/Windows/Mac) clients so you map the networked storage on each client so that all paths are consistent.
Then being able to create browser links to related areas of your storage eg a link in Storage/Projects/Music/Tune Analysis/Swing'48
to Storage/Documents/Music/Scores/Swing'48.pdf and Media/Audio/Albums/Rocky Grasset/Swing'48.mp3
that are followable in any of the client operating systems is very useful!
.desktop files are the only thing able to fulfill these criteria as they are just text files so you can make a .desktop link handler script in windows or mac.
They work across all mapped networked and local drives (hard links and sym links of course wont in a self consistent manner) and although windows shortcut links work they are shell scripts so very hard to make work in other environments (even using wine is not consistent).
Making them easy to create is my final step. The standard linux method is horribly convoluted: ie.
find the file or folder in nautilus, press ctrl L to get the path, highlight it press ctrl c to copy it then right click on the desktop (only place you can create them) select create launcher, select type=link, paste the path into the url field, select icon, create, then move the .desktop file to your desired location!
-whew! -no thanks!
Currently I just have to right click the target, select scripts, makeLauncher-here.sh
but I want to just highlight the target and press a key combo - hence my origional post.
RFC-Request For Comments.

Return to “Scripts & Bash”