diff --git a/TimeZones-v2.41.zip b/TimeZones-v2.50.zip
similarity index 98%
rename from TimeZones-v2.41.zip
rename to TimeZones-v2.50.zip
index 7453906..c6df2a1 100644
Binary files a/TimeZones-v2.41.zip and b/TimeZones-v2.50.zip differ
diff --git a/TimeZones.alfredworkflow b/TimeZones.alfredworkflow
index b958b52..e41c764 100644
Binary files a/TimeZones.alfredworkflow and b/TimeZones.alfredworkflow differ
diff --git a/source/info.plist b/source/info.plist
index 074d4c2..279bda5 100644
--- a/source/info.plist
+++ b/source/info.plist
@@ -71,6 +71,19 @@
+ 408AA1A8-69F7-45E1-AF88-D3B90A40A00E
+
+
+ destinationuid
+ CAFFEE63-507B-4755-ADDC-20AFDF0CE87E
+ modifiers
+ 0
+ modifiersubtext
+
+ vitoclose
+
+
+
4D7626AC-9354-4ABF-B95D-9224BCC91DDA
@@ -431,7 +444,7 @@
config
alfredfiltersresults
-
+
alfredfiltersresultsmatchmode
0
argumenttreatemptyqueryasnil
@@ -453,9 +466,10 @@
queuemode
1
runningsubtext
- Fetching time data...
+ Fetchinig timiezones or checking for an upgrade...
script
- ./timezone_list.sh "{query}"
+ ./oneUpdater.sh 7
+./timezone_list.sh "{query}"
scriptargtype
0
scriptfile
@@ -1160,9 +1174,53 @@
version
1
+
+ config
+
+ argumenttype
+ 2
+ keyword
+ timezone upgrade
+ subtext
+ Normall, new versions are checked every 7 days
+ text
+ Check for a newer version
+ withspace
+
+
+ type
+ alfred.workflow.input.keyword
+ uid
+ 408AA1A8-69F7-45E1-AF88-D3B90A40A00E
+ version
+ 1
+
+
+ config
+
+ concurrently
+
+ escaping
+ 0
+ script
+ ./oneUpdater.sh 0
+ scriptargtype
+ 0
+ scriptfile
+
+ type
+ 0
+
+ type
+ alfred.workflow.action.script
+ uid
+ CAFFEE63-507B-4755-ADDC-20AFDF0CE87E
+ version
+ 2
+
readme
- TimeZones v2.41
+ TimeZones
2 November 2022
=====
@@ -1207,6 +1265,10 @@ CHANGELOG
All issues tracked on GitHub https://github.com/jaroslawhartman/TimeZones-Alfred/issues
+2.50
+2 November 2022
+* Automatised upgrades #46
+
2.41
2 November 2022
* Fixed Option + Enter does not remove a locale #51
@@ -1440,6 +1502,13 @@ v1.0
ypos
410
+ 408AA1A8-69F7-45E1-AF88-D3B90A40A00E
+
+ xpos
+ 290
+ ypos
+ 1405
+
4D5D6C9D-E596-4EB1-A0A7-634814560B7F
xpos
@@ -1573,6 +1642,13 @@ v1.0
ypos
1160
+ CAFFEE63-507B-4755-ADDC-20AFDF0CE87E
+
+ xpos
+ 495
+ ypos
+ 1405
+
D8D3E88A-E982-4F27-B3AA-46DAD6C5D87F
xpos
@@ -1630,10 +1706,10 @@ v1.0
1040
- userconfigurationconfig
+ variablesdontexport
version
- 2.41
+ 2.50
webaddress
https://jhartman.pl/tag/time-zones/
diff --git a/source/oneUpdater.sh b/source/oneUpdater.sh
new file mode 100755
index 0000000..1e3e807
--- /dev/null
+++ b/source/oneUpdater.sh
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+
+set -x
+
+# THESE VARIABLES MUST BE SET. SEE THE ONEUPDATER README FOR AN EXPLANATION OF EACH.
+readonly remote_info_plist='https://raw.githubusercontent.com/jaroslawhartman/TimeZones-Alfred/master/source/info.plist'
+readonly workflow_url='https://github.com/jaroslawhartman/TimeZones-Alfred/raw/master/TimeZones.alfredworkflow'
+readonly download_type='direct'
+readonly frequency_check="${1:-7}"
+
+# FROM HERE ON, CODE SHOULD BE LEFT UNTOUCHED!
+function abort {
+ echo "${1}" >&2
+ exit 1
+}
+
+function url_exists {
+ curl --silent --location --output /dev/null --fail --range 0-0 "${1}"
+}
+
+function notification {
+ local -r notificator="$(find . -type f -name 'notificator')"
+
+ if [[ -f "${notificator}" && "$(/usr/bin/file --brief --mime-type "${notificator}")" == 'text/x-shellscript' ]]; then
+ "${notificator}" --message "${1}" --title "${alfred_workflow_name}" --subtitle 'A new version is available'
+ 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
+ # Remote sanity check
+ if ! url_exists "${remote_info_plist}"; then
+ abort "'remote_info_plist' (${remote_info_plist}) appears to not be reachable."
+ fi
+
+ readonly tmp_file="$(mktemp)"
+ curl --silent --location --output "${tmp_file}" "${remote_info_plist}"
+ readonly remote_version="$(/usr/libexec/PlistBuddy -c 'print version' "${tmp_file}")"
+ rm "${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
+
+ readonly download_url="$(
+ if [[ "${download_type}" == 'github_release' ]]; then
+ osascript -l JavaScript -e 'function run(argv) { return JSON.parse(argv[0])["assets"].find(asset => asset["browser_download_url"].endsWith(".alfredworkflow"))["browser_download_url"] }' "$(curl --silent "https://api.github.com/repos/${workflow_url}/releases/latest")"
+ else
+ echo "${workflow_url}"
+ fi
+ )"
+
+ if url_exists "${download_url}"; then
+ notification 'Downloading and installingā¦'
+ readonly download_name="$(basename "${download_url}")"
+ curl --silent --location --output "${HOME}/Downloads/${download_name}" "${download_url}"
+ open "${HOME}/Downloads/${download_name}"
+ else
+ abort "'workflow_url' (${download_url}) appears to not be reachable."
+ fi
+fi
\ No newline at end of file