Autostart Login Script not Working

Hello all,
I’m trying to add a login script in KDE.
The command I want is : pactl set-sink-volume @DEFAULT_SINK@ 40%
I always want to have this volume at startup.
In terminal, this works.
So I tried to add this as a login script and logout script, just to be sure.
A file : ResetVolume.sh that contains :

#!/bin/bash
pactl set-sink-volume @DEFAULT_SINK@ 40%

Is there something I’m missing here ? This worked in MX Linux.
Should I change something in the Properties of this script at the “Program” or “Arguments” ?
In the General tab I see “Open with” Kate ? maybe that’s the problem ?

The problem is the file type “desktop configuration file”. However you created this file…

Simply create a textfile “ResetVolume.txt” and rename it to “ResetVolume.sh”. The result will be a file with type “shell-script”.

Hello, welcome to the openSUSE forums.

The file with the script should of course be readable and excutable by the user:

ls -l /home/flow/.config/autostart/ResetVolume.sh

(if I am correct in putting together the bits and pieces as you show them).

~/.config/autostart is expected to contain desktop configuration files (xxx.desktop) describing applications, not executable binaries or scripts.

With KDE, a good place for a startup script is in the directory

$HOME/.config/plasma-workspace/env

I use ~/bin to save the files and use systemsettings5-----Startup and shutdown------Autostart to add them at User login.

But I use a wait sequence inside the script:

stephan@linux64:~> cat ~/bin/pactl_loopback_load 
#!/bin/bash

wait 10
pactl load-module module-loopback latency_msec=1
stephan@linux64:~>
stephan@linux64:~> ls -al ~/bin/pactl_loopback_load
-rwxr-xr-x 1 stephan users 70  7. Jan 2023  /home/stephan/bin/pactl_loopback_load
stephan@linux64:~> 
stephan@linux64:~> cat ~/.config/autostart/pactl_loopback_load.desktop 
[Desktop Entry]
Exec=/home/stephan/bin/pactl_loopback_load
Icon=dialog-scripts
Name=pactl_loopback_load
Path=
Type=Application
X-KDE-AutostartScript=true
stephan@linux64:~> 

Thank you all for the answers
Let me just say, WOW ! I was not expecting so many answers and so fast. I’ve been told that SUSE English forums have very slow activity.
So with that being said, I will try all the solutions presented and get back with a feedback.
fyi, the moment I add I login script in KDE, this file is created ResetVolume.sh.desktop :

[Desktop Entry]
Comment[en_US]=
Comment=
Exec=/home/flow/ResetVolume.sh
GenericName[en_US]=
GenericName=
Icon=dialog-scripts
MimeType=
Name[en_US]=ResetVolume.sh
Name=ResetVolume.sh
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-KDE-AutostartScript=true
X-KDE-SubstituteUID=false
X-KDE-Username=

I don’t understand this one, I did not create the .desktop file in autostart if that’s the one you are referring to.
I created ResetVolume.sh and it works if I test it in konsole.

@nrickert I tried to copy ResetVolume.sh in $HOME/.config/plasma-workspace/env
I got the same results

This looks OK. So next step is to check whether your script is actually being invoked. Add something like

/usr/bin/logger "my script has been run"

to your script and check system logs after logging in

journalctl -b

look for the above string. Simple echo may suffice, but I am not sure where output goes.

List dependencies of autostart:

karl@erlangen:~> systemctl --user list-dependencies xdg-desktop-autostart.target
xdg-desktop-autostart.target
● ├─app-geoclue\x2ddemo\x2dagent@autostart.service
● ├─app-kaccess@autostart.service
○ ├─app-klipper@autostart.service
○ ├─app-konqy_preload@autostart.service
○ ├─app-org.kde.kalendarac@autostart.service

● ├─app-org.opensuse.opensuse_welcome@autostart.service

○ └─app-xprop\x2dkde\x2dfull\x2dsession@autostart.service
karl@erlangen:~> 

Show journal of “opensuse-welcome”:

karl@erlangen:~> journalctl --user -b -u "app-org.opensuse.opensuse_welcome*"
Sep 12 08:50:23 erlangen systemd[1083]: Starting Welcome...
Sep 12 08:50:23 erlangen systemd[1083]: Started Welcome.
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: QWebEngineUrlScheme::registerScheme: Scheme "qrc" already registered
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: checking if autostart is enabled
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: file exists
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: there is a file to disable, so it's disabled
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: Checking if we are live
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: file does not exist
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: We aren't live
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: qml: false
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: qml: KDE Gear, FreeRDP update in Tumbleweed https://news.opensuse.org/2023/09/07/kde-gear-freerdp-up-in-tw/
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: Property 'animations'' of object 'QQuickSequentialAnimation' has no notify signal and is not constant, value updates in HTML will be broken!
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: Property 'animations'' of object 'QQuickSequentialAnimation' has no notify signal and is not constant, value updates in HTML will be broken!
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: Checking if we are live
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: file does not exist
Sep 12 08:50:23 erlangen opensuse-welcome[3758]: We aren't live
Sep 12 08:59:57 erlangen opensuse-welcome[3758]: checking if autostart is enabled
Sep 12 08:59:57 erlangen opensuse-welcome[3758]: file exists
Sep 12 08:59:57 erlangen opensuse-welcome[3758]: there is a file to disable, so it's disabled
Sep 12 08:59:57 erlangen opensuse-welcome[3758]: enable autostart called
Sep 12 08:59:57 erlangen opensuse-welcome[3758]: file exists
Sep 12 08:59:57 erlangen opensuse-welcome[3758]: there was a file, so we removed it
Sep 12 09:00:00 erlangen systemd[1083]: app-org.opensuse.opensuse_welcome@autostart.service: Consumed 1.686s CPU time.
karl@erlangen:~> 

Is pulse or pipewire startet when the autostart script is executet?

Try a wait inside.

$ ls -l /home/flow/.config/autostart/ResetVolume.sh.desktop 
-rw------- 1 flow flow 131 sep 12 15:35 /home/flow/.config/autostart/ResetVolume.sh.desktop

The script must be executable.
See my post #6

I tried this,
Copied ResetVolume.sh into ~/bin
Added in Autostart as an Application, but with the same result.

Have you tried also an wait inside your Script?

Nice answer to me, but you seem to have changed a lot and I am not sure I still understand what you are doing.

How did you configure this in the first place? Did you use KDE > System Settings > Start and Stop > Autostart? And what did you do there?

Ok, I try to cope with all your changes. You seem to have put the script in ~/bin. Thus my original question changes to:

ls -l ~/bin/ResetVolume.sh

OK, this is the result :

  1. I modified the sh:
#!/bin/bash
/usr/bin/logger "my script has been run AAAAAAAA"
pactl set-sink-volume @DEFAULT_SINK@ 40% 20%
/usr/bin/logger "my script has been run BBBBBBBB"

This is what I got :

sep 12 15:50:13 DELL kded5[2142]: Delayed initialization.
sep 12 15:50:13 DELL systemd[2005]: Starting ResetVolume.sh…
sep 12 15:50:13 DELL systemd[2005]: Starting Double Commander…
sep 12 15:50:13 DELL flow[2370]: my script has been run AAAAAAAA
sep 12 15:50:13 DELL systemd[2005]: Starting Firefox…
*
*
*
*
sep 12 15:50:14 DELL ResetVolume.sh[2373]: Failed to get sink information: No such entity
sep 12 15:50:14 DELL flow[2437]: my script has been run BBBBBBBB

So this is starting to make some sense now

Good. So on the modern KDE all session management is performed using systemd. Could you please reboot, log in and immediately capture (as your own user, not as root) and post

journalctl --user -b --no-pager --full

This should show when your script and PA have been started.

You do not really need to reboot, it is just to reduce the amount of output (so it captures just one session).

Isn’t this the problem?

Failed to get sink information: No such entity

@DEFAULT_SINK@ seems no proper identifier. If you execute “pactl list” you should get the correct sink identifier.