- Only supporting up to four layouts
- With a full four layouts, it can be a pain to quickly toggle between two that I may want to use concurrently (which I might solve with a keyboard shortcut to toggle between the current & last-used layout, in addition to one to cycle through all layouts)
Code: Select all
#!/bin/bash
# Read kblist, a text file containing a list of layout,variant pairs
num=1
# Initialize lists of options with primary layout dvorak,
layouts=(dvorak)
variants=("")
while IFS= read -r line
do
# Read layout,variant from file
settings=(${line//,/ })
layouts[$num]=${settings[0]}
variants[$num]=${settings[1]}
num=`expr $num + 1`
done < [my path]/kblist1
# Cycle second through last options
numm=`expr $num - 1`
layout2=${layouts[1]}
variant2=${variants[1]}
numm=`expr $num - 1`
for n in `seq 2 $numm`; do
nm=`expr $n - 1`
layouts[$nm]=${layouts[$n]}
variants[$nm]=${variants[$n]}
done
layouts[$numm]=$layout2
variants[$numm]=$variant2
# Set layout with new second option
# This line is essentially all of what I have questions about
setxkbmap -layout ${layouts[0]},${layouts[1]} \
-variant ${variants[0]},${variants[1]}
# Save new order of layouts
for n in `seq 1 $numm`; do
echo ${layouts[$n]},${variants[$n]}
done > [my path]/kblist1
The problems I'm running into with this, which are basically coming out of shortcomings of how I'm using the setxkbmap command, are:
- Diverse operations such as connecting to Bluetooth speakers or disabling my touchpad (it has issues) reset the list of layout options (to the last thing I set using the keyboard settings window)
- When I use this, it reverts to the first option (Dvorak) which is a problem inasmuch as I'd prefer to follow the option I'm selecting in the Keyboard Layouts item on the panel. (I believe it didn't change back like that when I was using cinnamon; I recently switched to xfce but also rewrote parts of the above script when I did.) Not knowing a way to emulate the behavior of the change-layout shortcut from the command line, the obvious thing to do would be just to switch dvorak and the secondary layout. However, that changes the behavior of shortcuts, so that they're based on the layout I want to be secondary, rather than based on Dvorak. (That also wasn't a problem in cinnamon.)
- Set selection of layouts in a persistent way, like I can in the keyboard settings window, and
- Set the current layout option in a way that doesn't affect keyboard shortcuts, or equivalently select the layout to use for keyboard shortcuts in a way that doesn't affect the current layout option
Code: Select all
$ inxi -S
System: Host: ******** Kernel: 3.19.0-32-generic x86_64 (64 bit)
Desktop: Xfce 4.12.2 Distro: Linux Mint 17.3 Rosa