Change osk to secondary action and make primary action to rotate between configured layouts
This commit is contained in:
parent
8ea36eb5bc
commit
16671eaec1
|
@ -1,10 +1,50 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
FILE=/home/jpm/.local/state/onscreen-keyboard
|
# Input name from `swaymsg -t get_inputs`
|
||||||
if [ -f $FILE ]; then
|
INPUTNAME="AT Translated Set 2 keyboard"
|
||||||
rm $FILE
|
|
||||||
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false
|
ACTIVELAYOUT=$(swaymsg -t get_inputs | jq -r ".[] | select(.name==\"$INPUTNAME\") | .xkb_active_layout_name")
|
||||||
else
|
|
||||||
touch $FILE
|
mapfile -t AVAILABLELAYOUTS < <( swaymsg -t get_inputs | jq -r ".[] | select(.name==\"$INPUTNAME\") | .xkb_layout_names" | sed 's/[][,]//g' | sed 's/^ *//g' | grep -P '.')
|
||||||
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
|
ACTIVEINDEX=0
|
||||||
|
for i in "${AVAILABLELAYOUTS[@]}"; do
|
||||||
|
if [[ "$i" == '"'$ACTIVELAYOUT'"' ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
((ACTIVEINDEX+=1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
ACTION=bar
|
||||||
|
if [ -n $1 ]; then
|
||||||
|
ACTION=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $ACTION == 'osk' ]]; then
|
||||||
|
FILE=/home/jpm/.local/state/onscreen-keyboard
|
||||||
|
if [ -f $FILE ]; then
|
||||||
|
rm $FILE
|
||||||
|
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false
|
||||||
|
else
|
||||||
|
touch $FILE
|
||||||
|
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
|
||||||
|
fi
|
||||||
|
elif [[ $ACTION == 'layout' ]]; then
|
||||||
|
# Simpler just to use 'next' to rotate input layouts
|
||||||
|
#((ACTIVEINDEX+=1))
|
||||||
|
#if [[ $ACTIVEINDEX -eq ${#AVAILABLELAYOUTS[@]} ]]; then
|
||||||
|
#ACTIVEINDEX=0
|
||||||
|
#fi
|
||||||
|
#swaymsg input type:keyboard $ACTIVEINDEX
|
||||||
|
swaymsg input type:keyboard xkb_switch_layout next
|
||||||
|
$0 bar
|
||||||
|
else
|
||||||
|
SHORT=$(echo $ACTIVELAYOUT | sed -r 's/.*\(([[:alpha:]]*)\).*/\1/')
|
||||||
|
if [[ $ACTIVEINDEX -ne 0 ]]; then
|
||||||
|
echo '{"text": "⌨ '$SHORT'", "tooltip": "Rotate keyboard layout", "class": "alternate"}'
|
||||||
|
else
|
||||||
|
echo '{"text": "⌨ '$SHORT'", "tooltip": "Rotate keyboard layout", "class": "primary"}'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue