0

I am new to Linux and start with the Mint. I use three keyboard layouts (Eng, Rus, Fr), but only two of them are of everyday use. In Windows, I was using the CapsLock to switch between the main two layouts (Eng and Rus), and Ctrl+Shift to rotate all three. Is it possible to implement the same in Cinnamon? I

0

toggle keyboardlayout

As shown in the Image, you can create a custom Keyboard shortcut in the Keyboard settings. You give the Shortcut a name and point to the script you are gonna create. They you'll assign the Key Capslock to it.

for rotating betwen the two you can create a script like this:

#!/bin/sh
# This shell script is PUBLIC DOMAIN. You may do whatever you want with it.

TOGGLE=$HOME/.toggle

if [ ! -e $TOGGLE ]; then
    touch $TOGGLE
    setxkbmap en
    rm $TOGGLE
    setxkbmap ru
fi

(don't forget to chmod +x the script to make it executable)

For rotating between three commands, someone at Stackoverflow answered that question.

Here's your bash script for switching between three or more languages:

# Script that rotates between English, Russian, French, and Finnish keyboards

# Name of the state file
state_file=$HOME/.keyboard_state

# Ensure that the state file exists; initialize it with 0 if necessary.
[ -f "$state_file" ] || printf '0\n' > "$state_file"

# Read the next keyboard to use
read state < "$state_file"

# Set the keyboard using the current state
case $state in
    0) setxkbmap en ;;
    1) setxkbmap ru ;;
    2) setxkbmap fr ;;
    3) setxkbmap fi ;;
esac

# Increment the current state.
# Could also use state=$(( (state + 1) % 4 ))
state=$((state + 1))
[ "$state" -eq 4 ] && state=0

# Update the state file for the next time the script runs.
printf '%s\n' "$state" > "$state_file"
| improve this answer | |
  • Thank you! I got the idea. But I have a trouble with the setxkbmap command. When I run it as setxkbmap us or setxkbmap ru even from the terminal, not from the script, something happens with the standard keyboard manager: the layout icon disappears from the panel (right bottom), and the shortcuts, e.g., Ctrl+Shift, do not work any more, until I restart. I have tried man setxkbmap, but have no idea. Can you help with it? – Arastas Aug 25 '19 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.