Sway support removed. Moved I38 specific scripts out of the branch covered by dex.
This commit is contained in:
1 parent
45eb3ae4fc
commit
3a9c2ab6f1
13 files changed
+147
-449
No files matched your search
+13
-44
@@ -19,58 +19,27 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Detect if we're on Wayland or X11
|
||||
if [[ -n "${WAYLAND_DISPLAY}" ]]; then
|
||||
usingWayland=true
|
||||
else
|
||||
usingWayland=false
|
||||
fi
|
||||
|
||||
get_kbdlayout() {
|
||||
if [[ "$usingWayland" == "true" ]]; then
|
||||
# Sway: Get keyboard layout from input devices
|
||||
# This gets the xkb_active_layout_name from the first keyboard
|
||||
layout=$(swaymsg -t get_inputs | jq -r '.[] | select(.type=="keyboard") | .xkb_active_layout_name' | head -n 1)
|
||||
echo "$layout"
|
||||
else
|
||||
# i3: Use setxkbmap
|
||||
layout=$(setxkbmap -query | grep -oP 'layout:\s*\K([\w,]+)')
|
||||
variant=$(setxkbmap -query | grep -oP 'variant:\s*\K(\w+)')
|
||||
echo "$layout" "$variant"
|
||||
fi
|
||||
layout=$(setxkbmap -query | grep -oP 'layout:\s*\K([\w,]+)')
|
||||
variant=$(setxkbmap -query | grep -oP 'variant:\s*\K(\w+)')
|
||||
echo "$layout" "$variant"
|
||||
}
|
||||
|
||||
set_kbdlayout() {
|
||||
eval "array=($1)"
|
||||
read -r -a array <<< "$1"
|
||||
|
||||
if [[ "$usingWayland" == "true" ]]; then
|
||||
# Sway: Switch to next keyboard layout
|
||||
# Sway cycles through layouts configured in the config, so we just trigger next
|
||||
swaymsg input type:keyboard xkb_switch_layout next &&
|
||||
spd-say -P important -Cw "${array[@]}"
|
||||
else
|
||||
# i3: Use setxkbmap
|
||||
setxkbmap "${array[@]}" &&
|
||||
spd-say -P important -Cw "${array[@]}"
|
||||
fi
|
||||
setxkbmap "${array[@]}" &&
|
||||
spd-say -P important -Cw "${array[@]}"
|
||||
}
|
||||
|
||||
cycle() {
|
||||
if [[ "$usingWayland" == "true" ]]; then
|
||||
# Sway: Just switch to next layout (Sway handles cycling internally)
|
||||
swaymsg input type:keyboard xkb_switch_layout next
|
||||
currentLayout=$(get_kbdlayout)
|
||||
spd-say -P important -Cw "$currentLayout"
|
||||
else
|
||||
# i3: Cycle through provided layouts
|
||||
currentLayout=$(get_kbdlayout | xargs)
|
||||
layouts=("$@" "$1") # add the first one at the end so that it cycles
|
||||
index=0
|
||||
while [ "${layouts[$index]}" != "$currentLayout" ] && [ $index -lt "${#layouts[@]}" ]; do index=$((index + 1)); done
|
||||
nextIndex=$((index + 1))
|
||||
nextLayout=${layouts[$nextIndex]}
|
||||
set_kbdlayout "$nextLayout"
|
||||
fi
|
||||
currentLayout=$(get_kbdlayout | xargs)
|
||||
layouts=("$@" "$1") # add the first one at the end so that it cycles
|
||||
index=0
|
||||
while [ "${layouts[$index]}" != "$currentLayout" ] && [ $index -lt "${#layouts[@]}" ]; do index=$((index + 1)); done
|
||||
nextIndex=$((index + 1))
|
||||
nextLayout=${layouts[$nextIndex]}
|
||||
set_kbdlayout "$nextLayout"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user