You are not logged in.

#1 2021-04-07 13:31:00

RetiredTurtle
Member
Registered: 2019-01-20
Posts: 2

How to change between multiple keyboard layouts using the same key?

I am using DWM and I want to set mod + F1 as the keyboard layout change key. Basicly, I want it to be set as setxkbmap us if any other layout which is not US and ME are loaded. If I click mod + F1 and setxkbmap us is already loaded I want it to change to setxkbmap me . Same thing applies if the setxkbmap me is already loaded.

Offline

#2 2021-04-07 13:37:32

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 12,505

Re: How to change between multiple keyboard layouts using the same key?

Offline

#3 2021-04-07 13:51:35

seth
Member
Registered: 2012-09-03
Posts: 19,738

Re: How to change between multiple keyboard layouts using the same key?

The description doesn't sound like just toggling layouts.
If it is, defining a multi-layout config and toggling those layouts is *much* better - faster and it will not interfere w/ any xmodmap augmentation.

Otherwise try

#!/bin/sh
if [ "$(setxkbmap -query | awk '/layout/{print $2}')" = "us" ]; then
   setxkbmap -layout me
else
   setxkbmap -layout us
fi

Offline

#4 2021-04-07 13:59:51

RetiredTurtle
Member
Registered: 2019-01-20
Posts: 2

Re: How to change between multiple keyboard layouts using the same key?

Thank you both. This solved it.

Offline

Board footer

Powered by FluxBB