Running start up script not working in 4.0 and 4.1

I try to add bash commands to /rw/config/rc.local but they don’t execute.
This is very time consuming having to do them manually in every reboot…

Strange, the documentation says that scripts there should run on a VM startup: Config files | Qubes OS.

There’s no log?
I tried to add setxkbmap as I would run as a program in terminal and nothing happened.

Bumping this in request for a solution…

Try logging something inside /rw/config/rc.local and you probably will see the resulting file next boot:

echo test > /home/user/log

You might also use systemd-cat to log directly to system log used by journalctl.

Instead it might inproper execution context of setxkbmap with root user and VM.
I use setxkbmap in dom0 .config/autostart to have unified keyboard layout for all VMs.

No test file was created… how come?

Did you maybe just forget to chmod +x the script? Otherwise, see if there are any interesting errors at the end of

sudo journalctl -b -u qubes-misc-post

-rwxr-xr-x 1 root root 487 /rw/config/rc.local

$ sudo journalctl -b -u qubes-misc-post
– Journal begins at Sun 2021-11-28 10:51:16 EST, ends at Fri 2021-12-31 10:49:>
Dec 31 10:48:58 news systemd[1]: Starting Qubes misc post-boot actions…
Dec 31 10:48:58 news misc-post.sh[464]: Cannot open display “default display”
Dec 31 10:48:58 news systemd[1]: Finished Qubes misc post-boot actions.
lines 1-4/4 (END)

That error message is from setxkbmap. Try export DISPLAY=:0 in rc.local before you invoke it (or any other X11 client programs).

$ sudo journalctl -b -u qubes-misc-post
news systemd[1]: Starting Qubes misc post-boot actions…
news misc-post.sh[507]: Cannot open display “:0”
news echo[511]: test
news systemd[1]: Finished Qubes misc post-boot actions.

Didn’t work.

Just add to ~/.bashrc