My system is Manjaro Linux. But I think this does not metter.
In settings panel I cannot make CapsLock
as keyboard layout changer.
Please help.
2 Answers
Install ibus
into your system.
Run it in some startup script:
ibus-daemon -drx
Now little hack. When you bind Caps_Lock to change layout, case will be change too.
To prevent it behavior, need map Caps option.
A one solution:
setxkbmap -option 'lv3:caps_switch_latch'
Go to ibus preferences to change required layouts and shortcuts.
When your press Caps it was defined as ISO_Level3_Shift
. All is done!
NOTE:
Edit /etc/X11/xorg.conf.d/00-keyboard.conf
for persistent xkb option
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbOptions" "lv3:caps_switch_latch"
EndSection
UPD:
After time I found two other ways, based on independent hotkey listener. First approach use xbindkeys and xdotool, it have a lag.
; layout
(xbindkey '(release "c:66") "xdotool key Super_L+space")
Second via D-Bus instead xdotool, described it here
#!/bin/sh
LANG=$(dbus-send \
--type=method_call \
--print-reply=literal \
--dest=com.deepin.daemon.InputDevices \
/com/deepin/daemon/InputDevice/Keyboard \
org.freedesktop.DBus.Properties.Get \
string:"com.deepin.daemon.InputDevice.Keyboard" \
string:"CurrentLayout" | awk '{print $2}')
if [[ $LANG = 'us;' ]]; then
dbus-send \
--type=method_call \
--dest=com.deepin.daemon.InputDevices \
/com/deepin/daemon/InputDevice/Keyboard \
org.freedesktop.DBus.Properties.Set \
string:"com.deepin.daemon.InputDevice.Keyboard" \
string:"CurrentLayout" \
variant:string:"ru;"
else
dbus-send \
--type=method_call \
--dest=com.deepin.daemon.InputDevices \
/com/deepin/daemon/InputDevice/Keyboard \
org.freedesktop.DBus.Properties.Set \
string:"com.deepin.daemon.InputDevice.Keyboard" \
string:"CurrentLayout" \
variant:string:"us;"
fi
Open dconf-editor
, navigate to the switch-layout key for deepin (it should be /com/deepin/dde/keybinding/system/switch-layout
) and set it to ['Caps_Lock']