Xfce Forum

Sub domains
 

You are not logged in.

#1 2012-09-30 16:04:50

rrice
Member
From: Cleveland, OH
Registered: 2012-09-30
Posts: 1
Website

Using Environment Variables in Launchers

Hi,

I am trying to use environment variables in a custom launcher.

I tried to use this command line as the command:

exo-open --working-directory $HOME/src --launch TerminalEmulator

but when I try to execute the launcher, I get this error message in a modal box:

----
Failed to launch preferred application for category "TerminalEmulator".

Failed to change to directory '$HOME/src' (No such file or directory).
----

I was expecting that environment variables are supported directly. The command specified does work in a bash shell as expected. The launcher fails even if "Run in terminal" is checked.

Is there a way that I can use environment variable in a launcher or is this a bug?

Thanks,
Ralph

----
System info:

ralph@goten:~$ xfce4-about --version
xfce4-about 4.8.3 (Xfce 4.8)

Copyright (c) 2008-2011
	The Xfce development team. All rights reserved.

Please report bugs to <[url]http://bugzilla.xfce.org[/url]>.
Translators list from 2011-09-18 00:00:09.
ralph@goten:~$ uname -a
Linux goten 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

----

EDIT:  I did find a workaround. It came to me when I realized that my command was not executed in a shell. So, I could wrap the entire command line in a shell call:

bash -c 'exec exo-open --working-directory $HOME/src --launch TerminalEmulator'

Additionally, I can even export more environment variables, too:

bash -c 'export NAME=rrice;exec exo-open --working-directory $HOME/src --launch TerminalEmulator'

It seems weird, but it works for now.

Last edited by rrice (2012-09-30 21:07:02)

Offline

#2 2014-05-17 21:48:30

dirdi
Member
Registered: 2014-05-17
Posts: 3
Website

Re: Using Environment Variables in Launchers

I have not the exact same problem, but a related: Indeed, the above mentioned workaround works for the Exec key, but (of course) not for other keys, e.g. the Icon key.

Here's how my app.desktop file looks like:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Categories=Network
Exec=/bin/sh -c "$HOME/opt/app/app"
Name=App
Icon=/home/user/opt/app/icon.png

Is there a way to load the icon directly from the users $HOME directory?

I have read the spec[0] for .desktop files, but did not find a solution =/

[0] http://standards.freedesktop.org/deskto … atest.html

Offline

#3 2014-05-17 22:03:28

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,987

Re: Using Environment Variables in Launchers

It should work just by specifying the full path to the icon:

Icon=/home/toz/d.png

If however, you're looking to use the $USER environment variable there, then I have to ask why? Just place the icon in a location that everyone has access to (i.e. /usr/share/icons) and specify the full path.

Or perhaps I'm not fully understanding the issue...


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#4 2014-05-17 22:26:41

dirdi
Member
Registered: 2014-05-17
Posts: 3
Website

Re: Using Environment Variables in Launchers

@ToZ: Thanks for your very fast reply!

Yes, i want to use an environment variable like $USER or $HOME, because the system is used by many users and every user may have his own version of this program. And i want to avoid to create a specific app.desktop file for every user, but have a generic one to copy into users $HOME/.local/share/applications/ directory.

Last edited by dirdi (2014-05-17 23:39:34)

Offline

#5 2014-05-17 22:58:24

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,987

Re: Using Environment Variables in Launchers

In that case, would it not be useful to have one copy of the icon in a system directory accessible by all (i.e. /usr/share/icons) so that each user doesn't need to have a copy of the icon in their home directory?


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#6 2014-05-17 23:31:05

dirdi
Member
Registered: 2014-05-17
Posts: 3
Website

Re: Using Environment Variables in Launchers

I thought it would be nice to have all files of the program in one place and not scattered across the whole filesystem. However, as it seems there is not a simple solution for this problem, i created a symlink $HOME/.icons/app.png (see [0]) linking to ../opt/app/icon.png (/usr/share/icons is not an option, since i have no root privileges).

app.desktop:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Categories=Network
Exec=/bin/sh -c "$HOME/opt/app/app"
Name=App
Icon=app.png

Not very elegant, but i think i have wasted enough time on this and at least i have avoided to create a specific app.desktop file for every user xD

[0] http://standards.freedesktop.org/icon-t … ory_layout

@ToZ: Thanks for your help smile

Offline

Board footer

Powered by FluxBB