@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.
- First,
cdinto/usr/lib/systemd/system-sleep/, which is the directory to place your script file so thatsystemdcan find and execute them. - Create a script inside the directory
sudo touch setkeyboardmap - Copy and paste this code into the
/usr/lib/systemd/system-sleep/setkeyboardmapfile 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
- Make the script executable with
chmod