Skip to content

Instantly share code, notes, and snippets.

@stupidpupil
Created August 14, 2026 22:36
Show Gist options
  • Select an option

  • Save stupidpupil/bb9f432d90936c9078987e3349dff6a9 to your computer and use it in GitHub Desktop.

Select an option

Save stupidpupil/bb9f432d90936c9078987e3349dff6a9 to your computer and use it in GitHub Desktop.
karabiner_setled.sh
#!/opt/local/bin/bash
if [ $# != 1 ] && [ $# != 2 ]
then
cmd=${0##*/}
echo -e "Usage:\t$cmd <setleds argument>"
echo
echo "Example: $cmd +num"
exit 1
fi
cli="/Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli"
cwd="${BASH_SOURCE[0]%/*}"
def_profile=$("$cli" --show-current-profile-name)
no_kbd_profile="Keyboardfree"
if [ "$def_profile" = "$no_kbd_profile" ]
then
def_profile="Default profile"
fi
set_led_arg=$1
setInLoop () {
count=0
while "$cwd"/setleds "$set_led_arg" -name "tinkerBOY*" | grep -F -q -- "?num"
do
count=$((count+1))
if [[ $count == 20 ]]
then
return 1
fi
done
echo $count
return 0
}
egress () {
"$cli" --select-profile "$def_profile"
}
trap egress EXIT
exit_code=0
if true
then
"$cli" --select-profile "$no_kbd_profile"
if ! setInLoop
then
echo "Gave up waiting for setled command to work" >&2
exit_code=1
fi
fi
exit $exit_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment