Created
January 14, 2024 18:05
-
-
Save humblehacker/06151a3c9b2bd4029b0236c322aacc78 to your computer and use it in GitHub Desktop.
Choose next Karabiner profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
alias kb="/Library/Application\ Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli" | |
# Get the list of items | |
IFS=$'\n' items=($(kb --list-profile-names)) | |
# Get the current item | |
current_item=$(kb --show-current-profile-name) | |
# Find the index of the current item | |
for i in {1..$#items}; do | |
if [[ "${items[$i]}" == "$current_item" ]]; then | |
current_index=$i | |
break | |
fi | |
done | |
# Determine the next index | |
if [[ $current_index -eq $#items ]]; then | |
next_index=1 | |
else | |
next_index=$((current_index + 1)) | |
fi | |
# Select the next item | |
next_profile="${items[$next_index]}" | |
kb --select-profile $next_profile | |
echo "$next_profile selected" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So Nice!!