Last active
August 29, 2015 14:21
-
-
Save brandondrew/dbed1910ec9ec2a331de to your computer and use it in GitHub Desktop.
Visit another user's OS X account, but get a sane working environment, and set it back to whatever state they had it before when you're done.
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 bash | |
# install: | |
# curl https://gist.githubusercontent.com/brandondrew/dbed1910ec9ec2a331de/raw/acbab5356c0022e54361e51eff3f9f44780ee842/visit | bash | |
# TODO: this script should | |
# * be writtten in Ruby | |
# * be a single script or app (`drop in` & `drop out`?) | |
# * generate the 'leave' script, based on current settings and differences | |
# * generate a complete state of defaults before your visit (so you can restore anything) | |
# * IF POSSIBLE, generate a leave script for any arbitrary change | |
# * be able to take any arbitrary set of key/value pairs (with domain! of course) and save the current value to leave.sh before setting the value to my preferred value | |
visit_script="/tmp/visit" | |
cat << 'END_VISITING_SCRIPT' > "$visit_script" | |
############################################################################################################## | |
# First we determine how we found the place before visiting, so we can restore it to its original state: | |
leave_script="/tmp/leave" | |
original_tap_to_click_setting=$(defaults read com.apple.AppleMultitouchTrackpad Clicking) | |
original_natural_swiping_setting=$(defaults read -globalDomain com.apple.swipescrolldirection) | |
cat << END_LEAVING_SCRIPT > "$leave_script" #/tmp/leave | |
##### LEAVING ##### | |
# tap to click | |
defaults write com.apple.AppleMultitouchTrackpad Clicking "${original_tap_to_click_setting}" | |
# natural swiping direction (the metaphor is that you're touching the media, not the scrollbar) | |
defaults write -globalDomain com.apple.swipescrolldirection "${original_natural_swiping_setting}" | |
echo "You should be all set. I've restored this user's previous settings." | |
END_LEAVING_SCRIPT | |
chmod u+x "${leave_script}" | |
echo "When you're ready to leave, just execute ${leave_script} from a shell" | |
############################################################################################################## | |
# then we set it up the way we want it, so that we can have a sane experience while we visit: | |
# tap to click | |
defaults write com.apple.AppleMultitouchTrackpad Clicking 1 | |
# natural swiping direction (the metaphor is that you're touching the media, not the scrollbar) | |
defaults write -globalDomain com.apple.swipescrolldirection 1 | |
# disable dashboard | |
# defaults write com.apple.dashboard mcx-disabled -boolean YES | |
# expand Save dialogs by default: | |
# defaults write -g NSNavPanelExpandedStateForSaveMode -boolean true | |
END_VISITING_SCRIPT | |
chmod u+x "${visit_script}" | |
bash "${visit_script}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment