(scripts) added kb layout switcher for hyprland
This commit is contained in:
@@ -38,6 +38,7 @@ bind = $Mod, d, exec, $menu
|
|||||||
bind = $Mod, q, killactive,
|
bind = $Mod, q, killactive,
|
||||||
bind = $Mod SHIFT, q, forcekillactive
|
bind = $Mod SHIFT, q, forcekillactive
|
||||||
bind = $Mod, a, exec, audio-sink-switcher.sh
|
bind = $Mod, a, exec, audio-sink-switcher.sh
|
||||||
|
bind = $Mod, m, exec, hyprland-kb-layout-switcher.sh
|
||||||
bind = $Mod SHIFT, m, exec, hyprctl switchxkblayout all next
|
bind = $Mod SHIFT, m, exec, hyprctl switchxkblayout all next
|
||||||
|
|
||||||
## move focus
|
## move focus
|
||||||
@@ -162,8 +163,8 @@ bind = $Mod SHIFT, s, exec, slurp | grim -g - "$screenshot_directory/$(date '+%Y
|
|||||||
|
|
||||||
input {
|
input {
|
||||||
# keyboard
|
# keyboard
|
||||||
kb_layout = us, us
|
kb_layout = us, us, ch
|
||||||
kb_variant = basic, intl
|
kb_variant = basic, intl, basic
|
||||||
|
|
||||||
# mouse
|
# mouse
|
||||||
sensitivity = 0.5
|
sensitivity = 0.5
|
||||||
|
|||||||
@@ -36,10 +36,12 @@ select_audio_sink() {
|
|||||||
elif $(which fuzzel &>/dev/null); then
|
elif $(which fuzzel &>/dev/null); then
|
||||||
selection="$(printf "%s\n" "${names[@]//\"/}" | fuzzel --lines ${lines} --dmenu --select-index ${number})"
|
selection="$(printf "%s\n" "${names[@]//\"/}" | fuzzel --lines ${lines} --dmenu --select-index ${number})"
|
||||||
else
|
else
|
||||||
|
notify-send "sink-switcher" "requires either [rofi] or [fuzzel]"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${selection}" ]]; then
|
if [[ -z "${selection}" ]]; then
|
||||||
|
notify-send "sink-switcher" "selection failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ select_audio_sink() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "${number}" ]]; then
|
if [[ -z "${number}" ]]; then
|
||||||
echo "something went wrong.."
|
notify-send "sink-switcher" "something went wrong.."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
36
scripts/hyprland-kb-layout-switcher.sh
Normal file → Executable file
36
scripts/hyprland-kb-layout-switcher.sh
Normal file → Executable file
@@ -1,6 +1,38 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
function switch_kb_layout {
|
function switch_kb_layout {
|
||||||
layouts="$(hyprctl devices -j | grep -iP '"layout"' -m 1)"
|
devices="$(hyprctl devices -j)"
|
||||||
# TODO:
|
languages="$(echo "${devices}" | grep -ioP '(?<="layout": ").*(?=")' -m 1)"
|
||||||
|
variants="$(echo "${devices}" | grep -ioP '(?<="variant": ").*(?=")' -m 1)"
|
||||||
|
current="$(echo "${devices}" | grep -ioP '(?<="active_layout_index": ).*(?=,)' -m 1)"
|
||||||
|
|
||||||
|
languages=(${languages})
|
||||||
|
variants=(${variants})
|
||||||
|
|
||||||
|
number=$((${#languages[@]} - 1))
|
||||||
|
for n in $(seq 0 $number); do
|
||||||
|
layouts+=("${languages[$n]//,/} - ${variants[$n]//,/}")
|
||||||
|
done
|
||||||
|
|
||||||
|
if $(which fuzzel &>/dev/null); then
|
||||||
|
selection="$(printf "%s\n" "${layouts[@]}" | fuzzel --lines ${#layouts[@]} --dmenu --select-index ${current})"
|
||||||
|
else
|
||||||
|
notify-send "layout-switcher" "requires [fuzzel]"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for n in $(seq 0 $number); do
|
||||||
|
if [[ "${layouts[$n]}" == "${selection}" ]]; then
|
||||||
|
index=$n
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ -z "${index}" ]]; then
|
||||||
|
notify-send "layout-switcher" "selection failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
hyprctl switchxkblayout all "${index}" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_kb_layout
|
||||||
|
|||||||
Reference in New Issue
Block a user