Autostart with parameters

Hi guys! Recently installed an application that’s adding custom RPC in discord while doing smth on the internet (app name is PreMID if you wonder).

I added it to autostart, but soon realized that it won’t run correctly without parameter --no-sandbox. How could I add this parameter to autostart to run app correctly?

You would need to define your own desktop entry file for that application. The desktop entry specification contains all the information you need. Refer to the Exec key (the command to run and its parameters are specified there as a string)

https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables

2 Likes

I’ve already tried it. Autostart is removing my parameters

In what sense? What autostart application are you using btw? Something like dex?

I’m assuming that you’ve already added the modified .destkop for that application to the ~/.config/autostart directory?

I added autostart in KDE settings app

I didn’t know that I must use some third-party app to get autostart working fine

Not exactly. You’re using a desktop environment, which has its own way to autostart applications. Lightweight tools like dex are only needed if you don’t run a desktop environment (if you’re using a window manager like dwm or i3, for example).

Can you share the output of

$ ls -l /etc/xdg/autostart

And also

$ ls -l ~/.config/autostart

Yup. As you can see, your KDE GUI application added the premid.desktop into your ~/.config/autostart directory.

Can you share the contents of that file?

[Desktop Entry]
Type=Application
Version=1.0
Name=premid
Comment=premidstartup script
Exec=/opt/premid/premid --hidden
StartupNotify=false
Terminal=false

I tried to add --no-sandbox to Exec line. But after rebooting, system still gives me errors about starting the app and somehow removing --no-sandbox

That doesn’t sound right. Which application is overwriting the desktop file? Is it because you didn’t add the --no-sandbox flag inside kde’s GUI and the GUI will overwrite that desktop file with its settings everytime?

Can you try to run the premid executable from the command line with the --no-sandbox flag? Are there still errors?

$ /opt/premid/premid --no-sandbox

Yes, it’s running pefrectly when i execute it with --no-sandbox or launching it via launch menu (i edited entry to contain --no-sandbox)

I think there’s no such setting in system setting to write custom parameters

Yeah. I think this is the issue. Because you set the autostart definition in the KDE GUI, KDE will use that same setting in the GUI to create the ~/.config/autostart/premid.desktop every time the desktop environment starts. That’s why the changes you made manually to the desktop file keeps disappearing—because the GUI is overwritting it with its own settings (without --no-sandbox) every time.

What you need to do is go to the KDE GUI and remove the setting. After that, add the desktop file for premid into ~/.config/autostart yourself.

1 Like

I’m very impressed rn. I didn’t expect that solution to my problem was so simple…

Thank you very much! I really appreciate it

No problem. And welcome to the forum.

1 Like

Suddenly it stopped working and started to remove my params again…

That makes no sense at all. The settings gui should not modify any file that it is not configured to modify. Take a screenshot of your KDE autostart settings.

Hey! Here it is.

Sorry for ignoring, I was busy last 2 days

What’s currently inside /etc/xdg/autostart?