From e655afde553107b3413666f02c8f9744a6277385 Mon Sep 17 00:00:00 2001 From: tiyn Date: Wed, 28 Feb 2024 14:56:43 +0100 Subject: [PATCH] sxhkd: improved keymap key --- .config/sxhkd/sxhkdrc | 2 +- .local/bin/tools/change_keymap | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 .local/bin/tools/change_keymap diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index a3832fc..5dbfe99 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -30,7 +30,7 @@ super + backslash sound_toggle super + shift + l - setxkbmap -query | grep -q 'ru$' && $(setxkbmap de ; notify-send -u low 'SXHKD' 'Set keymap to german') || $(setxkbmap de ru ; notify-send -u low 'SXHKD' 'Set keymap to russian') + change_keymap super + shift + r pkill -usr1 -x sxhkd ; notify-send -u low 'SXHKD' 'Reloaded config' diff --git a/.local/bin/tools/change_keymap b/.local/bin/tools/change_keymap new file mode 100755 index 0000000..18555ad --- /dev/null +++ b/.local/bin/tools/change_keymap @@ -0,0 +1,14 @@ +#!/bin/sh +layout=$(setxkbmap -query | grep "layout" | awk '{print $NF}') #| grep -q 'ru$' && $(setxkbmap de ; notify-send -u low 'SXHKD' 'Set keymap to german') || $(setxkbmap de ru ; notify-send -u low 'SXHKD' 'Set keymap to russian') +variant=$(setxkbmap -query | grep "variant" | awk '{print $NF}') +echo $variant +if [ "$layout" = "de" -a "$variant" = "nodeadkeys" ] +then + setxkbmap de && notify-send -u low 'SXHKD' 'Set keymap to german' +elif [ "$layout" = "de" -a "$variant" = "" ] +then + setxkbmap de ru && notify-send -u low 'SXHKD' 'Set keymap to russian (german)' +elif [ "$layout" = "de" -a "$variant" = "ru" ] +then + setxkbmap de nodeadkeys && notify-send -u low 'SXHKD' 'Set keymap to german (nodeadkeys)' +fi