I have a little one-line keyboard customization in my ~/.profile that is intended to make my caps lock key function as escape when pressed or ctrl when held.

# Map Caps Lock to Esc/Ctrl
setxkbmap -option 'caps:ctrl_modifier' && xcape -e 'Control_L=Escape;Caps_Lock=Escape'

It works… but only if I manually run source ~/.profile. The weird thing is that it kinda works without the manual intervention, but the caps lock also activates. This does not happen after manually sourcing.

I thought this file was automatically sourced at login. If that’s the case, shouldn’t the customization work automatically without the file having to be manually sourced? Is there some service that needs to be running before this command fires that is not yet running when the file is automatically sourced? Struggling to understand what’s happening here… 🤔

  • RadDevon@lemmy.zipOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    4 months ago

    I found a solution that seems to be working. Forgot where I saw this, or I’d give credit. Maybe StackOverflow?

    Anyway, the solution was to write a separate shell script for my keymaps with a sleep 2 at the top. The, I run it as a startup application with this command: /bin/bash -c "sh /home/me/.keymaps.sh"

    Apparently, the desktop environment must be loaded in order for the keymaps to take, so having it in my profile was running the command too early.