Unable to permanently set `setxkbmap`

@rene is absolutely right. You can set this with the GUI of your desktop environment.

However, assuming that the GUI doesn’t work for some reason, here is a way to execute a script before/after waking up from sleep: by adding a systemd pre/post-sleep hook.

This article has more information on how to do this: https://wiki.archlinux.org/title/Power_management#Hooks_in_.2Fusr.2Flib.2Fsystemd.2Fsystem-sleep

Edit: If you are too lazy to read the article, here is basically how you do it.

  1. First, cd into /usr/lib/systemd/system-sleep/, which is the directory to place your script file so that systemd can find and execute them.
  2. Create a script inside the directory sudo touch setkeyboardmap
  3. Copy and paste this code into the /usr/lib/systemd/system-sleep/setkeyboardmap file you just created.
#!/bin/sh
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    #do nothing before going to sleep
    exit 0
    ;;
  post/*)
    echo "Waking up from $2..."
    # Run setkbxmap command after waking from sleep.
    setxkbmap us -variant intl
    ;;
esac
  1. Make the script executable with chmod