A macOS Alfred workflow that displays sunrise/sunset times for your current location on a specific date (default today).
-
Install the Workflow
Download the.alfredworkflowfile and double-click to install. -
No Manual Setup Required
This workflow includes its own Python virtual environment, pre-installed with all required packages (likegeocoder). -
Requirements
Type your Alfred keyword (default is "sun") followed by a date like:
t(today)t+2(two days from today)04-19or04/19(MM-DD)
If no argument is provided, it will display information for today.
Download the .alfredworkflow file and double-click it to install into Alfred.
- Obtain an API key from https://timezonedb.com/api (required)
- In "Configure Workflow" enter your API key
- If you prefer to enter dates in DD-MM format, check the box for that
- If you want to store a log file for debugging purposes, chdck the box for that
This workflow includes a self-contained Python virtual environment, so you don’t need to worry about dependencies.
You do not need to install these manually — the virtual environment bundled with this workflow already includes them.
If you ever want to recreate the environment:
```bash
python3 -m venv venv
source venv/bin/activate
pip install geocoder
If you encounter an error like:
ModuleNotFoundError: No module named 'geocoder'
it usually means the virtual environment wasn’t bundled correctly or is not being used. Try re-installing the workflow or rebuilding the virtual environment using the steps above.
Your location is based upon your IP address, so if you're using a VPN your sunrise information will be based on the location of your VPN server.
If you want to edit the script, right-click the workflow in Alfred → "Show in Finder" → Open SunriseSunset.py.
Download the latest .alfredworkflow file
Pull requests are welcome. For major changes, please open an issue first to discuss what you’d like to change.
MIT License.
I had a need for this functionality, so I used it as a learning exercise.
It utilizes a Python script, sunrisesunset.py. The script interprets and normalizes the argument, queries one server to find the user's location in latitude and longitude and then queries another server that provides sunrise and sunset information. The it parses the response and displays it.
Danny Sands
danny@drdannysands.com
github.com/drdannysands/sunrisesunset
All comments and suggestions welcome.
