Score:0

relative path or environment variable not works in /etc/xdg/autostart/?

ru flag

I make a auto-start script in /etc/xdg/autostart to make our product runs when boots.

the .desktop file looks like this:

[Desktop Entry]
Version=1.0
Name=autoStarter
Exec=sh /home/myname/Commands.sh
StartupNotify=false
NoDisplay=true
Type=Application
Categories=System;Utility;Archiving;
Name[zh_TW]=hello.desktop

What I want to do is use the auto-starter to call a bash script in user's home file. In the Exec part, I always use absolutely path and it works fine. But I find that I'm not able to change the absolutely path to relative path.

I tried these:

Exec= sh ~/Commands.sh
Exec= sh $HOME/Commands.sh
Exec= sh /home/$USER/Commands.sh

not worked

all of these commands work in terminal but fail when I put them to *.desktop file

what should I do?

muru avatar
us flag
`sh -c '~/Commands.sh'`, or `sh -c '$HOME/Commands.sh'`, assuming the scripts are executable.
ru flag
thank you for your response. I find that if I want to use sh command i have to re-write it again, so the command would like `sh -c ' sh ~/Commands.sh'`
muru avatar
us flag
Then your script is probably not executable. `chmod +x` should fix that.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.