Skip to content

Instantly share code, notes, and snippets.

@alcides
Created March 3, 2015 16:23
Show Gist options
  • Save alcides/0b83740b6f5c567ee776 to your computer and use it in GitHub Desktop.
Save alcides/0b83740b6f5c567ee776 to your computer and use it in GitHub Desktop.
import os, random, datetime
from PIL import Image, ImageDraw, ImageFont
from AppKit import NSScreen
now = datetime.datetime.now()
then = datetime.datetime(2015,03,19)
days = abs((then - now).days)
fname = "countdown%d.png" % random.randint(0,2)
frame = NSScreen.mainScreen().frame().size
print frame.width, frame.height
txt = Image.new('RGBA', map(int, frame), (45,45,45,255))
fnt = ImageFont.truetype('quicksand.ttf', 100)
d = ImageDraw.Draw(txt)
d.text((frame.width/2 * 0.35,frame.height/2 * 0.55), "%d days remaining" % days, font=fnt, fill=(0,0,0,255))
txt.save(fname)
os.system("""
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "%s"'
""" % os.path.join(os.getcwd(), fname))
# Add this script to crontab -e
# 1 * * * * python /Users/alcides/Code/Support/countdown_background/background.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment