Autostart script

Hello,
I am trying to make a autostart script with the following command.

xset r rate 250 70

I have tried making a /etc/rc.local file with

#! /bin/bash
/usr/local/sbin/my-startup.sh
exit 0

/usr/local/sbin/my-startup.sh

#! /bin/sh

xset r rate 250 70

both files has chmod +x

Hi @Xlippo,

I know that can be done with a systemd startup unit script. However, I’ve not done it yet. I have, however, an auto start script as well.

Just move/copy/symlink you script to ~/.config/plasma-workspace/env:

$ mv <currentScriptLocation>/my-startup.sh ~/.config/plasma-workspace/env/my-startup.sh

Well, that’s what I had to do for KDE anyway. Not sure 'bout other DEs. Neither to make it system-wide, but it’s limited to my user on purpose.

Hope this helps!

1 Like

Thank you!

I tried making a service as you said.

/etc/systemd/system/my-startup.service

[Unit]
Description=My Startup
PartOf=graphical-session-target

[Service]
ExecStart=/usr/local/sbin/my-startup.sh

[Install]
WantedBy=graphical-session.target


● my-startup.service - My Startup
     Loaded: loaded (/etc/systemd/system/my-startup.service; enabled; vendor preset: disabled)
     Active: inactive (dead)

Mar 03 15:45:18 manjaro systemd[1]: /etc/systemd/system/my-startup.service:3: Failed to add dependency on graphical-session-target, ignoring: Invalid argument

I have also tried with;

[Unit]
Description=My Startup

[Service]
ExecStart=/usr/local/sbin/my-startup.sh

[Install]
WantedBy=multi-user.target

But got error message that it cannot run xset r rate without graphical session. So it probably executed the file before graphical session started…?

I have also tried making a cron job

crontab -l                                                       
@reboot /usr/local/sbin/my-startup.sh

Xset requires xorg to be running. Your scripts run before xorg is online. Instead of systemd service, I suggest using your desktops inbuilt autostart functionality.

1 Like

Hi,

I made a .desktop file in ~/home/.config/autostart

[Desktop Entry]
Name=my-startup
Exec=’/home/r/.config/autostart/my-startup.sh’
Terminal=false
Type=Application
StartupNotify=false
X-GNOME-Autostart-enabled=true

What am I doing wrong?

When I do

exec '/home/r/.config/autostart/my-startup.sh'

in the terminal it works. Must mean something is wrong with the .desktop file…?

Solved. It needed these entries in the .desktop file. Thanks!

[Desktop Entry]
Name=my-startup
GenericName=my-startup
Comment=Startup script
Exec='/home/r/.config/autostart/my-startup.sh'
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.