From e66c4e6047da7d2b5edaad31439bceb6c4000cbc Mon Sep 17 00:00:00 2001 From: GrafMonteCarlo <53829166+vailrahmatulin@users.noreply.github.com> Date: Tue, 21 May 2024 18:41:20 +0700 Subject: [PATCH 1/4] Update SwitchKeyboardLayout.sh Changing the keyboard layout for all keyboards connected to the computer. --- config/hypr/scripts/SwitchKeyboardLayout.sh | 37 +++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/config/hypr/scripts/SwitchKeyboardLayout.sh b/config/hypr/scripts/SwitchKeyboardLayout.sh index 0145e2621..cbacd74fe 100755 --- a/config/hypr/scripts/SwitchKeyboardLayout.sh +++ b/config/hypr/scripts/SwitchKeyboardLayout.sh @@ -41,5 +41,38 @@ new_layout="${layout_mapping[next_index]}" hyprctl switchxkblayout "at-translated-set-2-keyboard" "$new_layout" echo "$new_layout" > "$layout_f" -# Notification for the new keyboard layout -notify-send -u low -i "$notif" "new KB_Layout: $new_layout" +# Created by T-Crypt + +get_keyboard_names() { + hyprctl devices -j | jq -r '.keyboards[].name' +} + +change_layout() { + local got_error=false + + while read -r name; do + hyprctl switchxkblayout "$name" next + if [[ $? -eq 0 ]]; then + echo "Switched the layout for $name." + else + >&2 echo "Error while switching the layout for $name." + got_error=true + fi + done <<< "$(get_keyboard_names)" + + if [ "$got_error" = true ]; then + >&2 echo "Some errors were found during the process..." + return 1 + fi + + return 0 # All layouts had been cycled successfully +} + +if ! change_layout; then + notify-send -u low -t 2000 'Keyboard layout' 'Error: Layout change failed' + >&2 echo "Layout change failed." + exit 1 +else + # Notification for the new keyboard layout + notify-send -u low -i "$notif" "new KB_Layout: $new_layout" +fi From 1f38a5f7c1139de7720b6432316921c55a350913 Mon Sep 17 00:00:00 2001 From: GrafMonteCarlo <53829166+vailrahmatulin@users.noreply.github.com> Date: Tue, 21 May 2024 18:43:53 +0700 Subject: [PATCH 2/4] Update UserSettings.conf Disabling Alt+Shift key interception --- config/hypr/UserConfigs/UserSettings.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/hypr/UserConfigs/UserSettings.conf b/config/hypr/UserConfigs/UserSettings.conf index b3193e49f..3783d36b3 100644 --- a/config/hypr/UserConfigs/UserSettings.conf +++ b/config/hypr/UserConfigs/UserSettings.conf @@ -99,7 +99,7 @@ input { kb_layout=us kb_variant= kb_model= - kb_options=grp:alt_shift_toggle + kb_options= kb_rules= repeat_rate=50 repeat_delay=300 From 51e9bd706830e920bc375983ab8599335a4ae37b Mon Sep 17 00:00:00 2001 From: GrafMonteCarlo <53829166+vailrahmatulin@users.noreply.github.com> Date: Tue, 21 May 2024 18:47:30 +0700 Subject: [PATCH 3/4] Update UserKeybinds.conf Assigning the Alt+Shift keys to trigger the script SwitchKeyboardLayouts.sh --- config/hypr/UserConfigs/UserKeybinds.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/hypr/UserConfigs/UserKeybinds.conf b/config/hypr/UserConfigs/UserKeybinds.conf index eede16694..7026084d8 100644 --- a/config/hypr/UserConfigs/UserKeybinds.conf +++ b/config/hypr/UserConfigs/UserKeybinds.conf @@ -27,7 +27,7 @@ bind = $mainMod, Z, exec, pypr zoom # Toggle Zoom # User Added Keybinds bind = $mainMod SHIFT, O, exec, $UserScripts/ZshChangeTheme.sh # Change oh-my-zsh theme - +bindn = ALT_L, SHIFT_L, exec, $scriptsDir/SwitchKeyboardLayout.sh # For passthrough keyboard into a VM # bind = $mainMod ALT, P, submap, passthru #submap = passthru From 543ac255b7387dd0d45d9b1dd8cbef78d49263dc Mon Sep 17 00:00:00 2001 From: GrafMonteCarlo <53829166+vailrahmatulin@users.noreply.github.com> Date: Tue, 21 May 2024 18:49:21 +0700 Subject: [PATCH 4/4] Update UserKeybinds.conf Assigning the Alt+Shift keys to trigger the script SwitchKeyboardLayouts.sh --- config/hypr/UserConfigs/UserKeybinds.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/hypr/UserConfigs/UserKeybinds.conf b/config/hypr/UserConfigs/UserKeybinds.conf index 7026084d8..9858558f9 100644 --- a/config/hypr/UserConfigs/UserKeybinds.conf +++ b/config/hypr/UserConfigs/UserKeybinds.conf @@ -27,7 +27,8 @@ bind = $mainMod, Z, exec, pypr zoom # Toggle Zoom # User Added Keybinds bind = $mainMod SHIFT, O, exec, $UserScripts/ZshChangeTheme.sh # Change oh-my-zsh theme -bindn = ALT_L, SHIFT_L, exec, $scriptsDir/SwitchKeyboardLayout.sh +bindn = ALT_L, SHIFT_L, exec, $scriptsDir/SwitchKeyboardLayout.sh # Changing the keyboard layout + # For passthrough keyboard into a VM # bind = $mainMod ALT, P, submap, passthru #submap = passthru