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… 🤔

  • pnutzh4x0rA
    link
    fedilink
    English
    arrow-up
    2
    ·
    4 months ago

    If you are using gdm as your login manager, you can put the command in ~/.xprofile… which is sourced by gdm3.

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

      Hmm. I don’t seem to have that file, so I guess that means I’m not using gdm? I haven’t changed the login manager, so it’s whatever comes out of the box with current Pop_os.

      • pnutzh4x0rA
        link
        fedilink
        English
        arrow-up
        2
        ·
        4 months ago

        If you are using Pop!_OS 22.04, then you are using gdm. You can just create the file if it doesn’t exist.

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

          Ah, OK. I’ll give this a shot. I found a solution (posted in the comments), but I don’t love it because it depends on a sleep and isn’t deterministic. Thanks!

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

            For anyone who happens to find this later, putting it in ~/.xprofile did not work for me, so I’ll still with the other solution I posted here for now.