Skip to content

Instantly share code, notes, and snippets.

@yi-jiayu
Last active January 27, 2023 15:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yi-jiayu/5383cd268a1aa038e50c863f3d814784 to your computer and use it in GitHub Desktop.
Save yi-jiayu/5383cd268a1aa038e50c863f3d814784 to your computer and use it in GitHub Desktop.
A script to quickly configure Hot Corners from a file on macOS (https://blog.jiayu.co/2018/12/quickly-configuring-hot-corners-on-macos/)
#!/usr/bin/env bash
set -e
config_dir=${HOTCORNERS_CONFIG_DIR:-$HOME/.hotcorners}
if [ -z "$1" ]; then
echo "usage: hotcorners profile" 1>&2
exit 1
fi
profile=$1
config_file_path=$config_dir/$profile
if [ ! -f "$config_file_path" ]; then
echo "couldn't find config file for profile $profile ($config_file_path)" 1>&2
exit 1
fi
awk -F\= '/^[^#]/ {cmd=sprintf("defaults write com.apple.dock %s -int %s", $1, $2); print cmd; system(cmd)}' $config_file_path
killall Dock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment