Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
boombatower opened this issue Nov 3, 2014 · 20 comments
Closed

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

boombatower opened this issue Nov 3, 2014 · 20 comments
Labels
lang: c++ Done in C++ code

Comments

@boombatower
Copy link
Contributor

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
Copy link
Member

mic-e commented Nov 3, 2014

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@boombatower
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

Terminal=true

for .desktop file to work

Spawned #106.

@TheJJ TheJJ added the lang: c++ Done in C++ code label Nov 4, 2014
@lilezek
Copy link

lilezek commented Nov 5, 2014

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
Copy link
Contributor Author

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

@TheJJ
Copy link
Member

TheJJ commented Nov 5, 2014

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
Copy link
Contributor

http://stackoverflow.com/a/2552458

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

@TheJJ
Copy link
Member

TheJJ commented Nov 5, 2014

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

@lilezek
Copy link

lilezek commented Nov 6, 2014

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
Copy link
Member

TheJJ commented Nov 6, 2014

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
Copy link
Member

TheJJ commented Nov 13, 2014

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang: c++ Done in C++ code
Projects
None yet
Development

No branches or pull requests

5 participants