I need this bash script to start automatically at startup, as my user, not as root, because otherwise it won’t work.
#!/bin/sh
rpl='key <CAPS> \{ repeat=no, type\[group1\]=\"ALPHABETIC\", symbols\[group1\]=\[ Caps_Lock, Caps_Lock \],actions\[group1\]=\[LockMods\(modifiers=Lock\),Private\(type=3,data\[0\]=1,data\[1\]=3,data\[2\]=3\) \] \}'
# Create copy of kb description
xkbcomp -xkb $DISPLAY keyboardmap
# Replace CAPS
sed -i "s/key <CAPS>[^;]*/$rpl/" keyboardmap
# Apply
xkbcomp keyboardmap $DISPLAY
# Remove temp file
rm keyboardmap
It solves a problem that when you disable caps lock too fast you get stuff like AA Or HEllo or LInux. (First letter after disabling caps lock turns out still a capital, because there’s a delay.)
It comes with a service that supposedly you put in /etc/systemd/system
It’s this:
#
[Unit]
Description=Run caps lock fix
[Service]
Type=oneshot
#Especificar la carpeta donde estará el archivo capslock.sh
ExecStart=/bin/sh -c "/home/afoh/Documentos/Linux Caps Lock Fix/capslock.sh"
[Install]
WantedBy=multi-user.target
But it runs as root, and thus it ends up not working, it works best as my user.
So, I need a way to run that bash script at startup as my user, if possible preserving all my user variables, like working directory and such, so that the keyboardmap file is created there and removed once done, otherwise the file isn’t even created.
How can I do this?