Variables in .desktop files

Please post all general support questions for LXDE here.

Variables in .desktop files

Postby Sworddragon » Wed Oct 13, 2010 10:59 pm

I'm trying to modify the .desktop files in ~/.local/share/applications and have some problems with the variables. I thought %f stands for the current file and %u for the url (this is the directory or?). But all variables that I have tried (%f, %F, %u, %U) have all the same value. It's the path to the file including the filename.

Just an example:

My mimeapps.list has the content:

Code: Select all

[Added Associations]
text/plain=test.desktop;



My ~/.local/share/applications/test.dektop has the content:

Code: Select all
[Desktop Entry]
Type=Application
Name=test
Exec=lxterminal -e python /home/sworddragon/Data/test.py --var1 %u --var2 test2
NoDisplay=true



I have in ~/Data a test.py with the content:

Code: Select all
import optparse

arguments = optparse.OptionParser()
arguments.add_option('--var1', dest = 'var1')
arguments.add_option('--var2', dest = 'var2')
(option, arguments) = arguments.parse_args()

print(option.var1)
raw_input('')


And in ~/Data is an empty click.txt for testing.

If I right click the click.txt and select test lxterminal show me /home/sworddragon/Data/click.txt. I don't know how to access the directory with a variable.
Sworddragon
 
Posts: 5
Joined: Wed Oct 13, 2010 10:42 pm

Re: Variables in .desktop files

Postby Marty Jack » Thu Oct 14, 2010 2:30 am

Sorry, there is no field code that expands to the directory of a file.

http://standards.freedesktop.org/deskto ... atest.html section "the Exec key"
Marty Jack
 
Posts: 381
Joined: Mon Mar 23, 2009 6:14 am

Re: Variables in .desktop files

Postby Sworddragon » Fri Oct 15, 2010 10:50 pm

Maybe there is another way to solve my problem. I want to decompress an archive with 7z and the data should be saved in the same directory where the archive is.

mimeapps.list:

Code: Select all

[Added Associations]
application/x-7z-compressed=7z - decompress.desktop;



7z - decompress.desktop:

Code: Select all
[Desktop Entry]
Type=Application
Name=7z - decompress
Exec=lxterminal --working-directory=/home/sworddragon/Data -e 7z x %f
NoDisplay=true



Currently the data is every time saved in /home/sworddragon/Data independent of the path of the archive. I thought I can make this:

Code: Select all
[Desktop Entry]
Type=Application
Name=7z - decompress
Exec=lxterminal --working-directory=%u -e 7z x %f
NoDisplay=true



But %u isn't the directory and if there is no variable for it is there then a way to solve this problem?
Sworddragon
 
Posts: 5
Joined: Wed Oct 13, 2010 10:42 pm


Return to General Help

Who is online

Users browsing this forum: No registered users and 1 guest