Skip to content

Instantly share code, notes, and snippets.

@drunknbass
Last active March 25, 2020 23:33
Show Gist options
  • Save drunknbass/338d4d507f7f2fca020a44ff408af9c7 to your computer and use it in GitHub Desktop.
Save drunknbass/338d4d507f7f2fca020a44ff408af9c7 to your computer and use it in GitHub Desktop.
Toggle dark mode on currently running simulator
#! /bin/sh
booted_uuids=`xcrun simctl list devices | \
grep "(Booted)" | \
grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})"`
all_uuids=($(echo $booted_uuids | tr ";" "\n"))
last_uuid=${all_uuids[${#all_uuids[@]}-1]}
exit_cleanly() {
osascript -e 'tell application "Terminal" to quit' &
exit
}
# exit if no simulator uuid are found
if [ 0 == ${#all_uuids[@]} ]; then
exit_cleanly
fi
if [ "dark" == `xcrun simctl ui $last_uuid appearance` ]; then
xcrun simctl ui $last_uuid appearance light
else
xcrun simctl ui $last_uuid appearance dark
fi
exit_cleanly
@drunknbass
Copy link
Author

Xcode 11.4 simulator added this to Menu Bar -> Features -> Toggle Appearance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment