Skip to content

Commit

Permalink
update OneUpdater to point at pirate-weather.alfredworkflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kejadlen committed May 27, 2021
1 parent bef4ca0 commit 07dc90b
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pirate-weather"
version = "4.0.0"
version = "4.0.1"
authors = ["Alpha Chen <[email protected]>"]

[dependencies]
Expand Down
144 changes: 136 additions & 8 deletions workflow/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>darksky</string>
<string>weather</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
Expand Down Expand Up @@ -279,6 +279,123 @@ fi</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>2</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>forecast</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string></string>
<key>script</key>
<string># THESE VARIABLES MUST BE SET. SEE THE ONEUPDATER README FOR AN EXPLANATION OF EACH.
readonly remote_info_plist='https://raw.githubusercontent.com/kejadlen/pirate-weather.alfredworkflow/master/workflow/info.plist'
readonly workflow_url='kejadlen/pirate-weather.alfredworkflow'
readonly download_type='github_release'
readonly frequency_check='4'
# FROM HERE ON, CODE SHOULD BE LEFT UNTOUCHED!
function abort {
echo "${1}" &gt;&amp;2
exit 1
}
function url_exists {
curl --silent --location --output /dev/null --fail --range 0-0 "${1}"
}
function notification {
readonly local notificator="$(find . -type d -name 'Notificator.app')"
if [[ -n "${notificator}" ]]; then
"${notificator}/Contents/Resources/Scripts/notificator" --message "${1}" --title "${alfred_workflow_name}" --subtitle 'A new version is available'
return
fi
readonly local terminal_notifier="$(find . -type f -name 'terminal-notifier')"
if [[ -n "${terminal_notifier}" ]]; then
"${terminal_notifier}" -title "${alfred_workflow_name}" -subtitle 'A new version is available' -message "${1}"
return
fi
osascript -e "display notification \"${1}\" with title \"${alfred_workflow_name}\" subtitle \"A new version is available\""
}
# Local sanity checks
readonly local_info_plist='info.plist'
readonly local_version="$(/usr/libexec/PlistBuddy -c 'print version' "${local_info_plist}")"
[[ -n "${local_version}" ]] || abort 'You need to set a workflow version in the configuration sheet.'
[[ "${download_type}" =~ ^(direct|page|github_release)$ ]] || abort "'download_type' (${download_type}) needs to be one of 'direct', 'page', or 'github_release'."
[[ "${frequency_check}" =~ ^[0-9]+$ ]] || abort "'frequency_check' (${frequency_check}) needs to be a number."
# Check for updates
if [[ $(find "${local_info_plist}" -mtime +"${frequency_check}"d) ]]; then
if ! url_exists "${remote_info_plist}"; then abort "'remote_info_plist' (${remote_info_plist}) appears to not be reachable."; fi # Remote sanity check
readonly tmp_file="$(mktemp)"
curl --silent --location --output "${tmp_file}" "${remote_info_plist}"
readonly remote_version="$(/usr/libexec/PlistBuddy -c 'print version' "${tmp_file}")"
if [[ "${local_version}" == "${remote_version}" ]]; then
touch "${local_info_plist}" # Reset timer by touching local file
exit 0
fi
if [[ "${download_type}" == 'page' ]]; then
notification 'Opening download page…'
open "${workflow_url}"
exit 0
fi
download_url="$([[ "${download_type}" == 'github_release' ]] &amp;&amp; curl --silent "https://api.github.com/repos/${workflow_url}/releases/latest" | grep 'browser_download_url' | head -1 | sed -E 's/.*browser_download_url": "(.*)"/\1/' || echo "${workflow_url}")"
if url_exists "${download_url}"; then
notification 'Downloading and installing…'
curl --silent --location --output "${HOME}/Downloads/${alfred_workflow_name}.alfredworkflow" "${download_url}"
open "${HOME}/Downloads/${alfred_workflow_name}.alfredworkflow"
else
abort "'workflow_url' (${download_url}) appears to not be reachable."
fi
fi</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string></string>
<key>title</key>
<string></string>
<key>type</key>
<integer>0</integer>
<key>withspace</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>E8F22EA9-54D4-4F7D-8AAB-5875A39AE683</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -344,7 +461,7 @@ fi</string>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>fo</string>
<string>darksky</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
Expand All @@ -357,8 +474,8 @@ fi</string>
<string></string>
<key>script</key>
<string># THESE VARIABLES MUST BE SET. SEE THE ONEUPDATER README FOR AN EXPLANATION OF EACH.
readonly remote_info_plist='https://raw.githubusercontent.com/kejadlen/dark-sky.alfredworkflow/master/workflow/info.plist'
readonly workflow_url='kejadlen/dark-sky.alfredworkflow'
readonly remote_info_plist='https://raw.githubusercontent.com/kejadlen/pirate-weather.alfredworkflow/master/workflow/info.plist'
readonly workflow_url='kejadlen/pirate-weather.alfredworkflow'
readonly download_type='github_release'
readonly frequency_check='4'
Expand Down Expand Up @@ -441,7 +558,7 @@ fi</string>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>E8F22EA9-54D4-4F7D-8AAB-5875A39AE683</string>
<string>0B8AA955-D21E-4AA4-B659-BF47EA6734F0</string>
<key>version</key>
<integer>3</integer>
</dict>
Expand Down Expand Up @@ -518,6 +635,17 @@ fi</string>
[dark-sky-lang]: https://darksky.net/dev/docs#forecast-request</string>
<key>uidata</key>
<dict>
<key>0B8AA955-D21E-4AA4-B659-BF47EA6734F0</key>
<dict>
<key>colorindex</key>
<integer>12</integer>
<key>note</key>
<string>OneUpdater</string>
<key>xpos</key>
<integer>25</integer>
<key>ypos</key>
<integer>310</integer>
</dict>
<key>2A5C0A87-204E-49EA-94A7-8E62BB4EFD8A</key>
<dict>
<key>xpos</key>
Expand All @@ -530,7 +658,7 @@ fi</string>
<key>xpos</key>
<integer>190</integer>
<key>ypos</key>
<integer>145</integer>
<integer>170</integer>
</dict>
<key>B9B6DB3D-FF10-4E82-B5F3-AC80EF058E0D</key>
<dict>
Expand Down Expand Up @@ -573,7 +701,7 @@ fi</string>
<key>xpos</key>
<integer>190</integer>
<key>ypos</key>
<integer>265</integer>
<integer>310</integer>
</dict>
</dict>
<key>variables</key>
Expand Down Expand Up @@ -604,7 +732,7 @@ fi</string>
<string>GOOGLE_API_KEY</string>
</array>
<key>version</key>
<string>4.0.0</string>
<string>4.0.1</string>
<key>webaddress</key>
<string>http://github.com/kejadlen/pirate-weather.alfredworkflow</string>
</dict>
Expand Down

0 comments on commit 07dc90b

Please sign in to comment.