SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.63k stars 1.11k forks source link

Expand --data argument to allow for ~/ and such #95

Closed boombatower closed 9 years ago

boombatower commented 9 years ago

As per #81, the .desktop file would like to use the following command

openage --data="~/.openage/assets"

It appears that openage does not expand that and looks for literally ~/.openage/assets. Would be great to see it expand the argument.

mic-e commented 9 years ago

Expanding ~ the is shell's job. It's not expanded because in your invocation it's in the middle of the string.

You can instead use openage --data "~/.openage/assets", or openage --data="$HOME/.openage/assets".

boombatower commented 9 years ago

That's what I thought, but didn't seem to be working the way I expected. As makes sense now it appears the = sign messes things up since it can then parse the individual parts. So for example the following works:

openage --data ~/.openage/assets

The reason I added the quotes was the desktop file validator complained without them.

Assuming it doesn't like the above I think

"$HOME/.openage/assets"

with or without the equal sign is probably the best bet.

boombatower commented 9 years ago

The error I get if I do with or without equal, but with ~ outside of quotes is:

$ desktop-file-validate dist/openage.desktop 
dist/openage.desktop: error: value "openage --data ~/.openage/assets %u" for key "Exec" in group "Desktop Entry" contains a reserved character '~' outside of a quote
boombatower commented 9 years ago

Hmm, doesn't like $HOME either. and escape it obviously interprets as literal $.

$ desktop-file-validate dist/openage.desktop 
dist/openage.desktop: error: value "openage --data="$HOME/.openage/assets" %u" for key "Exec" in group "Desktop Entry" contains a non-escaped character '$' in a quote, but it should be escaped with two backslashes ("\\$")
boombatower commented 9 years ago

Even more fun with single quotes.

$ desktop-file-validate dist/openage.desktop 
dist/openage.desktop: error: value "openage --data='$HOME/.openage/assets' %u" for key "Exec" in group "Desktop Entry" contains a reserved character ''' outside of a quote
dist/openage.desktop: error: value "openage --data='$HOME/.openage/assets' %u" for key "Exec" in group "Desktop Entry" contains a reserved character '$' outside of a quote
dist/openage.desktop: error: value "openage --data='$HOME/.openage/assets' %u" for key "Exec" in group "Desktop Entry" contains a reserved character ''' outside of a quote
boombatower commented 9 years ago

I guess that's why you see loads of applications shipping with a core shell script. Then we could do something like...

Exec=openage.sh

Where openage.sh contains:

openage  --data ~/.openage/assets
boombatower commented 9 years ago

That or the asset manager should just be told a mode and it figures out where to look?

boombatower commented 9 years ago

The validator seems to also add

#!/usr/bin/env xdg-open

Which I've seen before and seems to match official spec, yet most projects and ones on my system don't have it.

boombatower commented 9 years ago

Ok, I figured out semi clever solution. Setting path, which will expand as expected. Obviously a load of different way to do this, but this seems sensible...and best of all it actually works (assuming you setup data, which I have symbolically link to dev clone).

[Desktop Entry]
Exec=openage --data=assets %u
Path=~/.openage/

Everyone good with that? Also means any config will be in working directory.

boombatower commented 9 years ago

Meh, except it prints a warning...not an error though!?

$ desktop-file-validate dist/openage.desktop                                 
dist/openage.desktop: warning: value "~/.openage/" for key "Path" in group "Desktop Entry" does not look like an absolute path
boombatower commented 9 years ago

Seems that openage will not load without a terminal available? One has to add

Terminal=true

for .desktop file to work

Spawned #106.

lilezek commented 9 years ago

I use $HOME/.openage/assets as my data folder and it works without any problem. As mic-e said, it is shell's work.

boombatower commented 9 years ago

Past that, read the comment. Issues are specific to .desktop files.

TheJJ commented 9 years ago

This is the shell's job, why do these damn freedesktop files ignore homedirs? Maybe they have some special replacement format chars, using args and homedirs seems to be a common usecase..

franciscod commented 9 years ago

http://stackoverflow.com/a/2552458

*nix: getenv("HOME") Windows: getenv("HOMEDRIVE") ++ getenv("HOMEPATH")

TheJJ commented 9 years ago

Kay, good idea. For the per-user dir that seems to be the way to go.

lilezek commented 9 years ago

I suggest to convert assets into that folder already. It doesn't make any sense that the folder created for the assets is not the program is using by default. Another way to go would be let the user input a path and then the converter writes down a config file ready to be read from openage, containing the path.

TheJJ commented 9 years ago

Yes, i'll try to invoke the conversion from the game binary as soon as possible (#29), the destination folder will be updated then.

TheJJ commented 9 years ago

The problem is the quotation. If you write --data=~/lol/folder/ it works, your shell just does not expand it in the quotation mark.

boombatower commented 9 years ago

yah didn't read my comments....we can close this.