Script put in autostart doesn't work


-i created a folder home/username/bin
-nano filename


nvidia-settings -a “[gpu:0]/GpuPowerMizerMode=1”

-made it executable under the file properties/permissions menu
-verified it works by launching it through the terminal ./filename
-added it to autostart in kde settings("add login script)

do i need to rename this file and put .sh as its extension?
do i need to put this file in $HOME/.config/autostart/ ?
do i need to run systemctl enable or the sorts?

Hi @linub,

Since you put this post in the KDE Plasma section, I’m going to assume this is for KDE. And sinceeis it an nVidia thing, I’'m also going to assume it needs to run arfter KDE has started.

  1. Create the script in ~/.config/plasma-workspace/env as your normal user:
nano ~/.config/plasma-workspace/env/
  1. Create the script as mentioned abose. My shebang is different from yours, though, so you might want to change it a bit. My scrriptt is:
#!/bin/env bash
export RCLONE_CONFIG_PASS='<somePassword>' && echo 'rClone configuration password set!' || echo 'Problem setting rClone configuration password'
  1. Save and exit your editor. If you’re using nano then that is Ctrl+W for save, followed by Ctrl+X` for exit.

  2. Ensure the permissions are correct. Still in the terminal, set the permissions to 0644:

chmod 0644 ~/.config/plasma-workspace/env/

In theory, that should be all that’s necessary.

  1. Confirm this by going to System SettingsAutostart. It should show the newly created script at the bottom. You can then simply reboot to further confirm it is working.

Well, that’s how mine was setup anyway, I trust yours will be the same.


this seems more complex than what I’ve seen done online;

about the permissions:i looked what was chmod 0644

and in my file’s properties it seems right:owner can view&modify,groups&others can only view.

also you mention this should be done after KDE has started and according to the kde manual:

-Scripts and desktop files set to run on Startup are copied or symlinked in $HOME/.config/autostart and will be run during Plasma startup.

-Scripts set on to be ran on Shutdown are copied or symlinked in the $HOME/.config/plasma-workspace/shutdown directory and will be automatically run during Plasma shutdown after the user has logged out.

-Scripts set to run at Pre-Plasma Startup are copied or symlinked in $HOME/.config/plasma-workspace/env and are sourced during Plasma startup (the start kde script will look for scripts here).

what i will try and do is create this script and put .sh at it’s creation; nano
i assumed this would get done automatically once i made it to be executable.

No, in Linux a files extension doesn’t necesarily have any bearing on its functionality. (Yes, that took a while for me to wrap y head around as well.) a file.exe can be executed even if it’s named fileexe if it has the executable permission.

That’s where the shebang come in (The first line, the one starting with #!). It tells the computer which interpreter to use to execute the script. So it’s not really executed itself, rather it’s read y the computer and fed into the bash interpreter to execute. Or that’s how I understand it really. So that’s why it doesn’t need executable permissions itself.

But it does. Without the executable permissions it would be just another file containing some data.

It does. And it does not. Can be complicated, I know.

The thing is, that script file itself isn’t actually executed as such. Not really.

It’s just a normal bash file whose contents gets read and passed on to an interpreter, which is actually just interpreting and executing the commands in the script. You can actually achieve what the script does in the command line. Not easily, no, but it can be done. Hence why I say the script itself doesn’t need to be executable.

If you want to run it by appending ./ in front of it, or perhaps some method I’m unaware of, you need to specify the shebang line, the first line, the one starting with #! with the full path path to the interpreter.

For example, the following shebang will cause the file/scrippt to be read and exected by bash:


That will have the same effect as passing the script to bash in the terminal:

$ bash <fileName>

Where <fileName> is the full path and filename of the script.

Also, as example,

#! /usr/bin/php

Will cause the file to be executed/run by the PHP interpreter.

And since the shebang starts with # it is read as a comment by the interpreter and not executed itself. So the file that is marked as executable, and contains a shebang as well can still be passed to the bash interpreter, as in the above demonstration . However, if it doesn’t contain either the shebang or is set to executable, it cannot be run as an executable, by appending #! or by another means.

My only guess as to why the file would only need 644 permissions to execute on startup is that it’s not executed itself, but rather by passing the script to thee interpreter.


Also see Introduction to Bash for Beginners

i managed to make it work;
it was a matter of creating the file with a .sh extension,make it executable(sudo chmod +x filename),
put it in home/username/bin(which is in $Path-i think that’s necessary),
then adding a “login script” in KDE autostart,which put a symlink in ~/.config/autostart-scripts/ which is the location for executing scripts at login for shell scripts.

now i wonder two things:
-what would happen if i run my laptop on “integrated(cpu)” through optimus manager;
the script would run anyway, so will it just generate an error of some sort?
-how can i pause/disable this script temporarily?is just through removing it from the autostart menu in kde?a check box or toggle button would be nice.


I manage the auto start with the KDE system settings, look below, I added mntray in the past

left clic on the mntary icon give you more option…

1 Like