Last active
March 25, 2020 23:33
-
-
Save drunknbass/338d4d507f7f2fca020a44ff408af9c7 to your computer and use it in GitHub Desktop.
Toggle dark mode on currently running simulator
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/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Xcode 11.4 simulator added this to Menu Bar -> Features -> Toggle Appearance