I see. Thank you for the details shared!
I've never experienced Linux Mint, but a quick Google shows an option "Caps Lock acts as Return" in the desktop environment (DE) settings. Is that the main idea?
Regarding the custom script case. Is it possible a system-wide service executes after your boot/startup script, slightly later, remapping it again?
We may try investigating. For instance, in a new terminal on the very system start, via xev, to try capture the moment it changes:
xev;
Or manually:
#! /usr/bin/env bash
declare s='' s2='';
while :;
do
s="$( xmodmap -pke | grep -E 'keycode\s+66'; )";
if [[ "$s" != "$s2" ]];
then
printf -- ' [%s] Changed from "%s" to "%s".\n' "$( date -- '+%F_%H-%M-%S'; )" "$s2" "$s";
s2="$s";
fi
sleep 1;
done
I would also try checking out logs:
journalctl --user -f | grep -E 'settings|keyboard|layout|xkb';
# Or: journalctl -f | grep ...
Edit 2026-06-13
-- xev -event mapping;
++ xev;
Thank you, @Flagstaff@programming.dev (source)