Skip to content

Instantly share code, notes, and snippets.

@ruzz311
Created September 5, 2018 07:24
Show Gist options
  • Save ruzz311/35ce995297505828c7e68939c044f564 to your computer and use it in GitHub Desktop.
Save ruzz311/35ce995297505828c7e68939c044f564 to your computer and use it in GitHub Desktop.
Alfred workflow to toggle timezone between GMT and current location.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>com.madsendev.togglegmt</string>
<key>connections</key>
<dict>
<key>8E1C4B16-49E0-49CE-AA11-53CE3D9F3948</key>
<array>
<dict>
<key>destinationuid</key>
<string>770CE572-03AE-41DC-8B07-76E97D981650</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>90FEFFF9-348C-45F1-94A0-1879F74AA8DE</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>9A769E50-492F-43B6-91DE-3BAB06A1C51F</key>
<array>
<dict>
<key>destinationuid</key>
<string>8E1C4B16-49E0-49CE-AA11-53CE3D9F3948</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>D866DA1D-5E55-49F2-AF16-AB9C87C22355</key>
<array>
<dict>
<key>destinationuid</key>
<string>E79483F8-D2FC-4E68-8246-AEAE0F0A2DDD</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>E79483F8-D2FC-4E68-8246-AEAE0F0A2DDD</key>
<array>
<dict>
<key>destinationuid</key>
<string>9A769E50-492F-43B6-91DE-3BAB06A1C51F</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>Russell Madsen</string>
<key>description</key>
<string></string>
<key>disabled</key>
<false/>
<key>name</key>
<string>Toggle GMT</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>foo=$(pwd)
# replace all blanks
bar=$(echo "$foo" | sed 's/ /\\ /g')
echo "$bar/toggleGMT.sh"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>E79483F8-D2FC-4E68-8246-AEAE0F0A2DDD</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argumenttype</key>
<integer>2</integer>
<key>keyword</key>
<string>togglegmt</string>
<key>subtext</key>
<string>Between GMT and current location</string>
<key>text</key>
<string>Toggle current timezone</string>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.input.keyword</string>
<key>uid</key>
<string>D866DA1D-5E55-49F2-AF16-AB9C87C22355</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>applescript</key>
<string>on alfred_script(q)
-- display dialog q
-- display dialog fullPath
do shell script q with administrator privileges
end alfred_script</string>
<key>cachescript</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.action.applescript</string>
<key>uid</key>
<string>9A769E50-492F-43B6-91DE-3BAB06A1C51F</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>lastpathcomponent</key>
<false/>
<key>onlyshowifquerypopulated</key>
<true/>
<key>removeextension</key>
<false/>
<key>text</key>
<string>{var:toggleResult}</string>
<key>title</key>
<string>TimeZone Toggle Success</string>
</dict>
<key>type</key>
<string>alfred.workflow.output.notification</string>
<key>uid</key>
<string>770CE572-03AE-41DC-8B07-76E97D981650</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argument</key>
<string>{query}</string>
<key>variables</key>
<dict>
<key>toggleResult</key>
<string>{query}</string>
</dict>
</dict>
<key>type</key>
<string>alfred.workflow.utility.argument</string>
<key>uid</key>
<string>8E1C4B16-49E0-49CE-AA11-53CE3D9F3948</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>autopaste</key>
<false/>
<key>clipboardtext</key>
<string>{query}</string>
<key>transient</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.output.clipboard</string>
<key>uid</key>
<string>90FEFFF9-348C-45F1-94A0-1879F74AA8DE</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string></string>
<key>uidata</key>
<dict>
<key>770CE572-03AE-41DC-8B07-76E97D981650</key>
<dict>
<key>xpos</key>
<integer>680</integer>
<key>ypos</key>
<integer>50</integer>
</dict>
<key>8E1C4B16-49E0-49CE-AA11-53CE3D9F3948</key>
<dict>
<key>xpos</key>
<integer>490</integer>
<key>ypos</key>
<integer>60</integer>
</dict>
<key>90FEFFF9-348C-45F1-94A0-1879F74AA8DE</key>
<dict>
<key>xpos</key>
<integer>680</integer>
<key>ypos</key>
<integer>160</integer>
</dict>
<key>9A769E50-492F-43B6-91DE-3BAB06A1C51F</key>
<dict>
<key>xpos</key>
<integer>320</integer>
<key>ypos</key>
<integer>30</integer>
</dict>
<key>D866DA1D-5E55-49F2-AF16-AB9C87C22355</key>
<dict>
<key>xpos</key>
<integer>10</integer>
<key>ypos</key>
<integer>30</integer>
</dict>
<key>E79483F8-D2FC-4E68-8246-AEAE0F0A2DDD</key>
<dict>
<key>xpos</key>
<integer>170</integer>
<key>ypos</key>
<integer>30</integer>
</dict>
</dict>
<key>webaddress</key>
<string>Http://madsendev.com</string>
</dict>
</plist>
#!/bin/bash
# Use "/usr/sbin/systemsetup -listtimezones" to see a list of available list time zones.
TimeZone=$(/usr/sbin/systemsetup -gettimezone)
subtitle="GMT"
if [[ "$TimeZone" = *"GMT"* ]]; then
/usr/sbin/systemsetup -settimezone "America/Chicago"
/usr/sbin/systemsetup -setusingnetworktime on
# set time zone automatically using current location
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool true
subtitle="AUTO"
else
/usr/sbin/systemsetup -setusingnetworktime off
#Set an initial time zone
/usr/sbin/systemsetup -settimezone "GMT"
# disable time zone using current location
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool false
fi
echo "timezone.auto = $(/usr/bin/defaults read /Library/Preferences/com.apple.timezone.auto Active)"
#title="Completed GMT Toggle"
#subtitle="$(/usr/sbin/systemsetup -gettimezone)"
#lines=('test1', 'test2')
#/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -title "$title" -subtitle "New TZ = $subtitle" -message "${lines[*]}" -group "toggleGMT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment