I am trying to use xmodmap to swap caps and escape. I put the xmodmap ~/.Xmodmap command in my .zshrc. But whenever I start a new shell, the xmod settings are swapped again. So I tried to wrap the xmodmap command in a condition that checks for a global variable, but I just can't get it to work.
if [ ! "$CAPS_MAPPED" = true ]; then # check if CAPS_LOCKED is empty
echo 'mapping'
xmodmap ~/dotfiles/.xmodmap # call xmodmap
export readonly CAPS_MAPPED=true # assign global var
fi
I tried different variations but just don't get what to do as I am fairly inexperienced with shell scripts.