.profile is not loaded on startup?

I added these two lines in ~/.profile
`
/usr/bin/setxkbmap -option “ctrl:swapcaps”

/usr/bin/xcape -e ‘Control_L=Super_L’
`

But it’s not automatically loaded on startup/login. I have to run source ./.profile manually every time. What is the cause & any fix?

It would probably be better to add those two commands to ~/.xinitrc. :thinking:

HI,

I may be mistaken but as this is a shortcut I think you could put

Exec=

Before the lines mentioned

Ex: Exec=/usr/bin/setxkbmap -option “ctrl:swapcaps”

Reboot the system

T+ = See you later

That would be a bad idea, because exec replaces the current process with the one it calls.

@Creto : Sorry, you are mistaken.
@Aragorn: Luckily the proposed change is not a call to exec but Exec= and would set a variable …

@Teeeeze Is zsh the shell you’re using? It uses ~/.zprofile instead of ~/.profile IIRC.

Understood. :+1: But then the content of the variable should be quoted, considering that there are spaces in those commands.

E.g.:

Exec='/usr/bin/setxkbmap -option “ctrl:swapcaps”'

Correct me if I’m wrong, but I believe that the shell used for initializing things like X11 would still be bash, rather than zsh. :thinking:

I don’t know actually. I do not use zsh but I’ve found (quite old) infos like this:
https://superuser.com/questions/187639/zsh-not-hitting-profile

I think if ./bash_profile or ./.bash_login exists the ./profile is ignored for login shell.

Grateful for the correction @freggel.doe

This is the bad custom of using debian’s

T+ = See you later

Using ~/profile is fine. Contents of ~/.zprofile:

emulate sh -c '. ~/.profile'

Thank you. I use bash.

Thank you for your suggestion. I tried putting the two lines in .bash_profile. But no luck…

Thank you for the suggestion. I’ve just tried and rebooted. It doesn’t work. Should I put prefix like Exec= to make it work properly?

Oh god. Thank you. I ended up solving the issue by adding the lines to ~/.bashrc
I don’t know why it doesn’t work in .bash_profile though

~/.bash_profile is read only upon login. ~/.bashrc is read every time you start a (bash) shell.

Hello @Teeeeze ,

This is just an idea… Correct me if am wrong :slight_smile:
According to

You are trying to swap CTRL with CapsLock
If so this is the way to do it… ArchWiki

Go to /etc/X11/xorg.conf.d/00-keyboard.conf and add Option "XkbOptions" "caps:swapcaps"

This is how its suppose to look

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us"
        Option "XkbOptions" "caps:swapescape"    <----- Here I swapped caps and escape
EndSection

Here you can find a list of possible swaps /usr/share/X11/xkb/rules/base.lst .
Just open it with your favorite editor and look through.

As for your ~/.profile it works just fine. The thing that you are trying to do is not suitable for that file.
Again this is just my opinion . :slight_smile:

Edit: Restart your PC or Laptop after. This is permanent change. For me it works just fine.

This is the only solution as for me

The answer to the .profile not being loaded is that .bash_profile is loaded instead.

But I wasn’t able to achieve what I wanted even with that. It temporarily works. To the change to take effect permanently, this is the only solution.

In case someone else reads my comment, I made a small typo :sweat_smile: Just saw it

It should be Option "XkbOptions" "ctrl:swapcaps"