Created
January 25, 2023 06:15
-
-
Save mohemohe/0878e572dad91d14768670f0aa25f2c3 to your computer and use it in GitHub Desktop.
watch-karabiner.1s.sh
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
#!/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