Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard layout change fix and correction. Change of keybinds as well and now moved to UserConfigs directory #292

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/hypr/UserConfigs/UserKeybinds.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +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 # Changing the keyboard layout

# For passthrough keyboard into a VM
# bind = $mainMod ALT, P, submap, passthru
Expand Down
2 changes: 1 addition & 1 deletion config/hypr/UserConfigs/UserSettings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 35 additions & 2 deletions config/hypr/scripts/SwitchKeyboardLayout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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