Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installed .desktop file to have user's home directory path inserted

Wording the title was a little tricky, but here's the situation. I am making a install.sh file for my game which is written in Python. I am trying to create a game folder with all assets instead of making this a module for Python. I may be doing things the hard way, but this method seems to work well.

The install.sh copies the game's directory to the HOME folder and moves a .desktop file and game's icon to the appropriate places (ie. desktop, applications folder). The issue is, this .desktop file uses Icon=~/.local/share/icons/game.png and Exec=~/Game/game.sh which causes the icon not to show up in the .desktop file or menu nor does the game shortcut execute. I replaced the ~ with $HOME and I get the same issue. However, if I change it to /home/(my account) instead of ~ or $HOME it will work perfectly and show the icon.

Is there a way to make the install bash file create this .desktop file dynamically if a user installs the game? Or is there some way of getting this to work that I am unaware of?

EDIT: Better explanation... ish.

like image 877
Gramps Avatar asked Jan 19 '26 11:01

Gramps


1 Answers

Alternatively, put ~/.local/share/applications in the premade .desktop file, and then sed 's/~/$HOME/g' appname.desktop > $HOME/.local/share/applications/appname.desktop in the installer script, or invoke that from your language interpreter as a shell exec.

It's a real shame that more projects with GUIs don't do this. These desktop files also need a 'wmClass' element in them in order to allow for the launcher to also be a window tab. I've manually fixed several applications for my convenience this way.

like image 120
Louki Sumirniy Avatar answered Jan 22 '26 01:01

Louki Sumirniy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!