Skip to content

Instantly share code, notes, and snippets.

@mohemohe
Created January 25, 2023 06:15
Show Gist options
  • Save mohemohe/0878e572dad91d14768670f0aa25f2c3 to your computer and use it in GitHub Desktop.
Save mohemohe/0878e572dad91d14768670f0aa25f2c3 to your computer and use it in GitHub Desktop.
watch-karabiner.1s.sh
#!/bin/bash
current="$(lsappinfo info -only name "$(lsappinfo front)" | cut -d'=' -f2)"
case "$current" in
'"Parsec"' | '"Parallels Desktop"' ) profile="PC" ;;
* ) profile="Default" ;;
esac
if [[ ! -e /tmp/watch-karabiner ]]; then
touch /tmp/watch-karabiner
fi
if [[ "$(cat /tmp/watch-karabiner)" != "${profile}" ]]; then
echo "${profile}" >| /tmp/watch-karabiner
'/Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli' --select-profile "${profile}"
/opt/homebrew/bin/terminal-notifier -title "Karabiner-Elements" -message "プロファイルを '${profile}' に変更しました"
fi
echo "🎹"
echo '---'
echo "Detect: ${current}"
echo "Profile: \"${profile}\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment