An imagemagick clock

The clock widget has a never-ending list of feature requests.

Then we have HTML Clock where you can have any layout you want, if you know some HTML:

Then I just realized that you can have an ultimate-customizable, pixel-perfect clock with ImageMagick. The clock widget just needs to call a small script like this every minute, and reload the generated picture:

#!/usr/bin/python3

import sys, time, subprocess

if len(sys.argv) <= 1:
    print("Usage: {} <output_file>".format(sys.argv[0]))
    sys.exit(1)
 
output_file = sys.argv[1]
t = time.localtime()
hour = t.tm_hour
minute = t.tm_min
day = t.tm_mday
month = t.tm_mon
year = t.tm_year

command = f'''magick -size 300x110 canvas:transparent -draw 'rectangle 0,0 300,110' -pointsize 128 -font '7-Segment' -fill '#FF2400' -draw 'text 0,104 "{hour:02d}"' -fill white -pointsize 84 -draw 'text 116,104 ":{minute:02d}"' -fill '#FF2400' -stroke '#FF2400' -strokewidth 5 -draw 'line 220,0 220,110' -strokewidth 0 -stroke none -fill white -pointsize 32 -draw 'text 230, 30 "{day:02d}"' -draw 'text 230, 64 "{time.strftime("%b", t).upper()}"' -draw 'text 230, 100 "{year}"' {output_file}'''
subprocess.run(command, shell=True)

Yeah, you need to know ImageMagick. Not a big issue if you are that into customization…

1 Like
1 Like