Skip to content

Commit

Permalink
version 1.5
Browse files Browse the repository at this point in the history
Alfred 5
  • Loading branch information
giovannicoppola committed Nov 30, 2022
1 parent aee480b commit 5748c19
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 133 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ src="https://img.shields.io/github/downloads/giovannicoppola/alfred-almanac/tota
<!-- MarkdownTOC autolink="true" bracket="round" depth="3" autoanchor="true" -->

- [Setting up](#setting-up)
- [Basic Usage](#usage)
- [Basic Usage](#basic-usage)
- [Known Issues](#known-issues)
- [Acknowledgments](#acknowledgments)
- [Changelog](#changelog)
Expand All @@ -22,8 +22,8 @@ src="https://img.shields.io/github/downloads/giovannicoppola/alfred-almanac/tota
<!-- /MarkdownTOC -->


<a name="setting-up"></a>
# Setting up
<h1 id="setting-up">Setting up</h1>


### Needed

Expand All @@ -36,8 +36,8 @@ src="https://img.shields.io/github/downloads/giovannicoppola/alfred-almanac/tota
2. _Optional:_ Click `Configure Workflow` in `alfred-almanac` preferences to change settings
3. _Optional:_ Setup a hotkey to launch alfred-almanac

<a name="usage"></a>
# Basic Usage

<h1 id="basic-usage">Basic Usage</h1>
![](images/complice-almanac.png)

- Launch `alfred-almanac` to retrieve weather and other almanac information from default locations ...
Expand Down Expand Up @@ -65,26 +65,25 @@ src="https://img.shields.io/github/downloads/giovannicoppola/alfred-almanac/tota
- Option (⌥) will show the local date/time and timezone


<a name="known-issues"></a>
# Known issues
<h1 id="known-issues">Known issues</h1>
- Not tested extensively for international locations

<a name="acknowledgments"></a>
# Acknowledgments

<h1 id="acknowledgments">Acknowledgments </h1>
- [Igor Chubin](https://twitter.com/igor_chubin) for developing the amazing `wttr.in`
- [@vitorgalvao](https://github.com/vitorgalvao) for suggestions and great additions
- The [Alfred forum](https://www.alfredforum.com) community.

<a name="changelog"></a>
# Changelog
<h1 id="changelog">Changelog </h1>


- 11-30-2022: version 1.5 removed OneUpdater (for Alfred Gallery)
- 11-01-2022: version 1.4 added timezones
- 09-29-2022: version 1.3 added OneUpdater, quicklookurl preview, keyword configurable (thanks @vitorgalvao!)
- 08-07-2022: version 1.2 merging @vitorgalvao's changes to update Workflow Environment Variables to User Configuration
- 03-30-2022: version 1.1 (switched to `requests` package for web request handling)
- 03-22-2022: version 1.0

<a name="feedback"></a>
# Feedback

<h1 id="feedback">Feedback</h1>
Feedback welcome! If you notice a bug, or have ideas for new features, please feel free to get in touch either here, or on the [Alfred](https://www.alfredforum.com) forum.

Binary file added releases/alfred almanacv1.5.alfredworkflow
Binary file not shown.
120 changes: 1 addition & 119 deletions source/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>72A6C50C-1A20-4C3F-892E-C91FA5BB13BA</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>9FAAF43A-64B2-4222-9BC4-476F44DB774E</key>
<array>
Expand Down Expand Up @@ -284,103 +274,6 @@ python3 almanac.py $1 "${LOCATION}"</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>0</integer>
<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/giovannicoppola/alfred-almanac/main/source/info.plist'
readonly workflow_url='https://github.com/giovannicoppola/alfred-almanac'
readonly download_type='github_release'
readonly frequency_check='30'
# 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 {
local -r notificator="$(find . -type f -name 'notificator')"
if [[ -f "${notificator}" &amp;&amp; "$(/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 =&gt; 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</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>72A6C50C-1A20-4C3F-892E-C91FA5BB13BA</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string>- Launch `alfred-almanac` to retrieve weather and other almanac information from default locations ...
Expand Down Expand Up @@ -434,17 +327,6 @@ fi</string>
<key>ypos</key>
<real>305</real>
</dict>
<key>72A6C50C-1A20-4C3F-892E-C91FA5BB13BA</key>
<dict>
<key>colorindex</key>
<integer>12</integer>
<key>note</key>
<string>OneUpdater</string>
<key>xpos</key>
<real>305</real>
<key>ypos</key>
<real>615</real>
</dict>
<key>9FAAF43A-64B2-4222-9BC4-476F44DB774E</key>
<dict>
<key>xpos</key>
Expand Down Expand Up @@ -557,7 +439,7 @@ fi</string>
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>1.4</string>
<string>1.5</string>
<key>webaddress</key>
<string>https://github.com/giovannicoppola/alfred-almanac</string>
</dict>
Expand Down

0 comments on commit 5748c19

Please sign in to comment.