v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
657 stars 58 forks source link

yad chokes on KDE .desktop files with "Path[$e]=" #155

Open jlittledc opened 2 years ago

jlittledc commented 2 years ago

My KDE plasma (version 5.22.5) generates .desktop files with the key

Path[$e]=

yad is "Unable to parse file" on these with

Invalid key name: Path[$e]

Maybe yad could ignore these entries. A simple workaround is to make a copy and delete the Path[$e]= line.

v1cont commented 2 years ago

kde guys: we make our own standard. with blackjack and hookers...

ok, i take a look at this problem, but don't promise anything. now i use glib's desktop entry parser and don't want to reinvent the wheel by doing my own implementation

is there any description of all nonstandard extension which kde uses in desktop files?

Misko-2083 commented 2 years ago

It must be some old KDE standard. Here it is:

So-called “Shell Expansion” can be used to provide more dynamic default values. With shell expansion the value of a configuration key can be constructed from the value of an environment variable or from the output of a shell command. To enable shell expansion for a configuration entry, the key must be followed by [$e]. Normally the expanded form is written into the user's configuration file after first use. To prevent that, it is recommend to lock the configuration entry down by using [$ie]. The user can't change it then of course.

In the following example the value for the Host entry is determined by the output of the hostname program. This setting is also locked down to ensure that the value is always determined dynamically.

The value for the Email entry is determined by filling in the values of the $ USER and $ HOST environment variables. When joe is logged in on joes_host this will result in a value equal to joe@joes_host. The setting is not locked down.

[Mail Settings] Host[$ie]=$(hostname) Email[$e]=${USER}@${HOST}

Therefore Path[$e]= tell it to use the shell expansion for the keyname Path. Example: Path[$e]=$HOME/SomePath/ If this is added to one of the desktop entries in /usr/share/applications gtk-launch will fail to recognise the app.

gtk-launch mousepad.desktop
gtk-launch: no such application mousepad.desktop

Also if Path is $HOME it will not be shell expanded

gtk-launch mousepad.desktop
gtk-launch: error launching application: Failed to change to directory “$HOME” (No such file or directory)

Maybe it's simpler to just change Path[$e]=$HOME to Path=/home/user/whatever_path