Trying to create a .desktop file for a program and it requires a universal username path so instead of Exec=/home/john/myscript.sh
it's Exec=/home/$USER/myscript.sh
.
in .desktop files you need an exact path and $USER
does not work. Neither does $LOGNAME
.
.Desktop EXEC universal home path
^This did not work either (the edited solution not the one voted as). Because this solution did not work, it is not relevant to this question.
Not sure what else to try. If someone could chime in it'd help a lot. Thank you.
Here is my desktop file
[Desktop Entry]
Type=Application
Encoding=UTF-8
Version=1.0
Terminal=false
Exec=/bin/bash -c '/home/$USER/mycroft-core/start-mycroft.sh all'
Name=Mycroft AI
Icon=/usr/share/MycroftIcon/MycroftIcon.jpg
X-GNOME-Autostart-enabled=true
Edit: I had a typo in my code the solution provided by @mchild works:
The solution is: Exec=/bin/bash -c '/home/$USER/myscript.sh'
myscript.sh
in the/usr/local/bin
directory? – waltinator Jan 18 '20 at 04:30Exec=sh -c '$HOME/myscript.sh'
andExec=/bin/bash -c '/home/$USER/myscript.sh'
and it worked. Have you tested:Exec=/home/john/myscript.sh
to see if that works? If it doesn't execute when you use the full path, you will know that you have a different problem. I tested this on a desktop file in my Desktop directory. I had to right click on the file: > Properties > Permission > check the box for "allow executing as a program". Then, double-click the file on desktop and select to trust. – mchid Jan 19 '20 at 03:05Exec=/home/john/myscript.sh
One problem could be that themyscript.sh
file is not executable or you could have other lines in your file that are preventing the file from executing. Thanks! – mchid Jan 19 '20 at 03:08$USER
with my actual username – John Jan 20 '20 at 22:42