Autostart : Shell script not working on startup kde

I want to map my caps lock key to backspace and kde has this option in its settings but caps lock isn't converted purely to backspace since on holding the converted caps lock nothing happens. It only deletes one character on one key press however long the press may be.

So I wrote a script

setxkbmap -option caps:backspace
xmodmap -e "clear Lock"

and put it in autostart by GUI (as shown) Screenshot_20200419_215456 but it isn't working.
I don't have much experience in linux but I think this is a fairly simple task and thats why its bothering me so much.
Can you please tell where I might be wrong ?
Thank you

What does the entirety of the script contain ?
(shebang?)
Is it in your PATH to be called by its name alone?
(if not .. then you should supply the full path to the file)
Is it executable?
Does the script work when you run it yourself?

This is my full script.

#!/bin/sh

# Caps Lock to Backspace
setxkbmap -option caps:backspace
xmodmap -e "clear Lock"

I didnt quite understand what you meant by the PATH thing but as in the picture ,I posted earlier, I have placed the file run_on_startup.sh in ~/.config/autostart-scripts.
Yes it is executable and it works when I manually run it in konsole.

OK then .. by simply putting 'autostart-scripts.sh' in that startup preference .. the system has no idea what/where that is (because it isnt in your PATH .. where known executables are). So you should probably feed it the whole path like

./home/USERNAME/.config/autostart-scripts.sh

( also notice the . dot there .. thats often how we start scripts without a command. if you were in the same directory for example - ./autostart-scripts.sh )

or maybe with something like bash or exec

exec /home/USERNAME/.config/autostart-scripts.sh

(btw your posts go back and forth about the filename containing '.sh' .. obviously use whatever it is .. scripts dont require the .sh extension, and it should run without .. I just mean be sure to use whatever the correct filename is)

It might be a silly simple thing, but did you make the script executable?
Can be done with:
chmod +x ~/.config/autostart-scripts/run_on_startup.sh

I think we have that covered :wink:

Sorry. I must have missed that line.

I can't put the dot '.' when it asks for the filename as it says not an absolute path.
And about running the file manually, I run the file with just its name example if the file is in ~ I just type run_on_startup.sh and it runs perfectly.
Btw thanks for the info about files dont require .sh extension, I didnt know that before.

But it does not get executed even now on startup.
I really can't seem to find any error or how to find a way to know where could be the error.
Thank you for your help.

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

Forum kindly sponsored by