Skip to main content
Wachter Space πŸš€
  1. Posts/

Always Visible Deadlines

To not get surprised by an upcoming deadline the day before, I like having them in sight regularly. The solution for me is to have in the upper right corner of my computer screen at all time. I am using Gnome, but this approach works for macOS. It is possible to develop for the Gnome shell directly, but this requires interaction with some complex and poorly documented APIs. For simply counting down numbers in the top bar this seems overkill. Luckily argos got me covered, and simplifies this task enormously. For macOS there is xbar, which is compatible to argos. Argos itself is a Gnome shell extension, for developing simple text display and shortcut applications, that live in the top bar. All I have to do for displaying text, is to create any type of executable, that prints to stdout. I opted for a python script, but shell scripts, C programs, or anything else works just as well. The script should calculate the time to the next deadlines, easy right, right!

#!/usr/bin/env python3

import json
from datetime import timedelta
from datetime import date


with open('/home/myusername/.config/argos/days.json', 'r') as f:
    data = json.load(f)

deltas = map(lambda day: (day['Name'], (date.fromisoformat(day['Date'])-date.today()).days), data)
ordered = map(lambda e: f'{e[0]}:{e[1]}', sorted(deltas, key=lambda x: x[1]))

print(','.join(list(ordered)))

I just read all deadlines from a json file, calculate the difference to today, sort them, and print them comma separated. The json files, called days.json, looks like this:

[
    {"Name": "ApG", "Date": "2021-09-07"},
    {"Name": "BAf", "Date": "2021-09-08"},
    {"Name": "VG", "Date": "2021-09-22"},
    {"Name": "BAT", "Date": "2021-08-16"}
]

‘Name’ is just an abbreviation, to keep the output concise. days.json can be either manually edited, or keep updated by some other program, e.g. one using the API to my calendar. The script is placed into ~/.config/argos/days_left_json.1h+.py, where the 1h+ part of the filename stands for: Execute every hour and when I click on it. See the documentation for all options. Note that the location of the executable is not the location it is executed in, I therefor used the absolute path to days.json.

This is all, simple right?

Some people might object that they do not want to see all their deadlines at all time. I think it is better to have deadlines in sight, than trying to remember them, or irregularly scanning through the calendar. An easy change to the implementation would be to have the deadlines shown only during work hours, or having a hide for X amount of time button.