Anyone know how to make GeekTool Python scripts work with Python3. Changing the path in the current script doesnt work. Bash scripts work fine but python no go. Im using GeekTool on Monterey.
Thank you!
Here is the vertical calendar script...
#!/usr/bin/python
# VertiCal: A slim monthly calendar (that's perfect for GeekTool)
# by Rob Dumas
# Copyright (c) 2012 GNU Public License version 3.
# See
http://www.gnu.org/licenses/licenses.html for details on this license.
import sys
import datetime
import calendar
# Get the current date and create our vertiCal.
today = datetime.date.today()
vertiCal = []
# Create a calendar object, whose weeks start on monday.
cal = calendar.Calendar(0)
# Set a variable for the day.
for i in cal.itermonthdays2( today.year,today.month ):
if i[1] == 0:
theday = "M"
elif i[1] == 1:
theday = "T"
elif i[1] == 2:
theday = "W"
elif i[1] == 3:
theday = "T"
elif i[1] == 4:
theday = "F"
elif i[1] == 5:
theday = "S"
elif i[1] == 6:
theday = "S"
else:
print "Error: Day of week is not between 0 and 6."
# Make sure the date is nonzero before appending to our list.
if i[0] != 0:
# ANSI codes:
# 'black': '0;30', 'bright gray': '0;37',
# 'blue': '0;34', 'white': '1;37',
# 'green': '0;32', 'bright blue': '1;34',
# 'cyan': '0;36', 'bright green': '1;32',
# 'red': '0;31', 'bright cyan': '1;36',
# 'purple': '0;35', 'bright red': '1;31',
# 'yellow': '0;33', 'bright purple': '1;35',
# 'dark gray': '1;30', 'bright yellow': '1;33',
# 'normal': '0'
startofline = "" # empty by default
default = '''\033[1;37m''' # white by default
highlighted = '''\033[1;32m''' # yellow
endofline = ''' \033[0m''' # return to normal at EOL
separator = ""
monthlen = len( today.strftime( "%b" ) )
if monthlen < 6: monthlen = 6
for d in range( monthlen ):
separator += "."
if i[0] == today.day:
startofline = highlighted
spacer = " >> "
else:
startofline = default
spacer = " "
thestring = startofline + theday + spacer
# At this point, thestring should look something like:
# \033[1;37mMo (normal)
# \033[0;33mTu (highlighted)
# Add an extra space to the line if the date is a single digit.
if 1 <= i[0] <= 9: thestring += " "
# Add the date to thestring.
thestring += str(i[0]) + endofline
# At this point, thestring should look something like:
# \033[1;37mMon 9\033[0m (normal)
# \033[0;33mTue 10\033[0m (highlighted)
vertiCal.append(thestring)
# Print it all out.
print highlighted + today.strftime( "%B %Y" ) + endofline
print default + separator + endofline
for item in vertiCal: print item