Score:0

Cant Set up an autostart scipt

do flag

I have been trying to set up an autostart script to start on the Desktop login (Kubuntu)

I tried adding my script through the startup applications GUI, and it did add it, but the script wasnt working. and by that, nothing have been hapening

so I manually created a .desktop file, and moved it to ~/.config/autostart/

which can be seen here:

[Desktop Entry]
 Comment[en_GB]=A startup scipt to start a minecraft server on Desktop log in 
 Comment=A startup scipt to start a minecraft server on Desktop log in
 Exec=/home/awakenmagic/Desktop/StartMCServer.sh
 GenericName[en_GB]=
 GenericName=
 Icon= MimeType= Name[en_GB]=Maciej Name=Maciej Path=
 StartupNotify=true
 Terminal=false
 TerminalOptions= Type=Application
 X-DBUS-ServiceName=
 X-DBUS-StartupType=
 X-GNOME-Autostart-enabled=true
 X-KDE-SubstituteUID=false
 X-KDE-Username=

and then I tried to see manually what is the output when its beeing ran. So I ran this command to start that script:

~/.config/autostart/ServerStartup.desktop start

and this popped up:

/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 1: [Desktop: command not found 
/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 2: `Comment[en_GB]': not a valid identifier 
/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 2: startup: command not found 
/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 3: startup: command not found 
/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 16: X-DBUS-ServiceName=: command not found 
/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 17: X-DBUS-StartupType=: command not found 
/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 18: X-GNOME-Autostart-enabled=true: command not found 
/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 19: X-KDE-SubstituteUID=false: command not found 
/home/awakenmagic/.config/autostart/ServerStartup.desktop: line 20: X-KDE-Username=: command not found

I have been getting the same errors when using the autostart default .desktop file that it created, and the same thing has happened

can somebody help?

thanks

EDIT1:

I wanted to create that autostart, which will start my script file on start, so that .desktop file, with the executable path to my actual script has been created in the ~/.config/autostart/ folder, when I added that script through the GUI to be started on log in, and it gave me those errors

EDIT2:

I did test my script without the startup, and it worked fine, with no problem, it started my server in a tmux session,I dont understart why I got those errors like [Desktop: Command not found, or Comment[en_GB]`: not a valid indendifier

thats the scipt from my .sh:

#!/bin/bash
tmux new -s MCServer 'cd MinecraftServer/; bash --init-file ./run.sh'

Could that be maybe because I have it move directory to "MinecraftServer", and startup scripts start from a different directory or something simmilar and not "Desktop"?

I am still learnign a lot of things about linux, its a little painful haha

EDIT3:

Is there a way to see what is the output of that script that is trying to be ran? I can try to read the output and figure out what is causing the issue, I might have coded something wrong?

user535733 avatar
cn flag
A .desktop file is NOT a script. They are different entities with different purposes and different syntax. They are not interchangeable nor interoperable.
user535733 avatar
cn flag
This seems like a classic [XY Question](https://en.wikipedia.org/wiki/XY_problem). The REAL problem is that your script "wasnt working," but instead you are asking about a different approach (.desktop file) that is even MORE complex and likely won't work at all. Fixing your original script is likely much simpler, and maintainable.
Score:0
uz flag

Just go to the application drawer and type 'Startup' (using dutch GUI here so just guessing what is in your language) or something that will open the list of applications to be started after login. Then add one and point to your script /home/awakenmagic/Desktop/StartMCServer.sh in the command-line field. Then give it a name and possibly a description for future reference.

There is no need to create a .desktop file first as the given script is already executable (I presume, otherwise make it execuable with chmod u+x).

When adding an entry in the list of start-up applications, Ubuntu will create a .desktop file for you. They are stored in ~/.config/autostart. You could have a look afterwards what the created .desktop file looks like.

If you do create a desktop file (for whatever reason) put it in the right folder (e.q. ~/.local/share/applications) and it will appear in your application drawer.

The given .desktop-file in your question seems wrong as there are a lot of entries on the same line, that should be separated by a newline. For example:

Icon= MimeType= Name[en_GB]=Maciej Name=Maciej Path=

should be

Icon= 
MimeType= 
Name[en_GB]=Maciej 
Name=Maciej 
Path=

See the official documentation on Desktop entry files here

Hope this helps for this problem and others in the future :).

I sit in a Tesla and translated this thread with Ai:

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.