Difficulty: Easy
This Geeklet contains 2 Scripts, an Applescript that grabs the Data from the Reminders App and passes them to the Ruby Script to proceed Output and Color Highlighting, and thats how it may look for you:
First of all here comes the Image if you want it to have:
Save the Image on your Mac and link it with an Image Geeklet first, oncee done, drag another Script Geeklet and in the Command Field write:
echo "Reminders"
this writes the Word Reminders on the Desktop,
than the first Part, the AppleScript:
my GetRemis() on GetRemis() set cD to (current date) tell application "Reminders" --set output to name of reminders if (count of (reminders whose completed is false)) > 0 then set output to "" set todoList to id of reminders whose completed is false set array to my theSplit(todoList, ",") repeat with itemNum from 1 to ((count of (reminders whose completed is false))) try set idf to item itemNum of array set Remi to name of (reminders where id is idf) set remiT to due date of (reminders where id is idf) as date set tim to time string of remiT set dD to date string of remiT if remiT ≤ cD then log "OK" set tmpDate to short date string of (remiT) set val to (tim & " - " & Remi & " $$" & tmpDate & "/ENDE") set output to (output & val & return) else log "ERROR" end if on error errMsg number errNr log errNr log errMsg end try end repeat else set output to "No reminders available" end if end tell return output end GetRemis on theSplit(theString, theDelimiter) -- save delimiters to restore old settings set oldDelimiters to AppleScript's text item delimiters -- set delimiters to delimiter to be used set AppleScript's text item delimiters to theDelimiter -- create the array set theArray to every text item of theString -- restore the old setting set AppleScript's text item delimiters to oldDelimiters -- return the result return theArray end theSplitSave this Applescript as reminders.scpt and remenber the Path!
Now head over to the Ruby Script:
require "date" require 'time' class String # colorization def colorize(color_code) "\e[#{color_code}m#{self}\e[0m" end def red colorize(31) end def green colorize(32) end def yellow colorize(33) end def pink colorize(35) end end def remi res = `osascript /Users/atoxx/Desktop/Coding/reminders.scpt` return res end def tom res = `osascript /Users/atoxx/Desktop/Coding/reminders_Tomorrow.scpt` return res end def dd res = `osascript -e "current date"` return res end tmp = remi tmp2 = tmp.split("/ENDE") eve = Array.new tim = Array.new for i in 0..tmp2.length-1 tmp3 = tmp2[i].split("$$") eve.push tmp3[0] tim.push tmp3[1] end out = "" puts "Today and Overdue" for i in 0..eve.length-1 # begin tmp = eve[i].split(" ") timeS = tmp[0] nowT = Time.now.strftime("%I:%M:%S %z") now2 = nowT.split(" ") if tim[i] != nil if Date.parse(tim[i]) < Date.today tmp = eve[i].split("-") res = ["25B6".hex].pack("U") + " " + tmp[0].strip! + " - " + "\033[1m" + "\e[4m" + tmp[1].strip!.red + "\033[0m" #res = "\033[1m" + out.red + "\033[0m" puts res else res = ["25B6".hex].pack("U") + " " + eve[i].strip! #res = tmp[0].strip! + " - " + tmp[1].strip! puts res end end # rescue # end end #Tomorrow------------------------- tomo = tom tomo2 = tomo.split("/ENDE") eveT = Array.new for i in 0..tomo2.length-1 tmp3 = tomo2[i].split("$$") eveT.push tmp3[0] end if eveT[0].length > 1 out = "" puts "\nTomorrow" for i in 0..eveT.length-1 begin tmpT = eveT[i].split(" ") tmp2T = eveT[i].split("-") res = ["25B6".hex].pack("U") + " " + tmp2T[0].strip! + " - " + "\033[1m" + "\e[4m" + tmp2T[1].strip! + "\033[0m" #res = "\033[1m" + out.red + "\033[0m" puts res rescue end end endSave this Script e.g. as "remi.rb"
Once you have your both Scripts, plz remeber to edit the Rub Script where it calls the Applescript to the correct File Path:
Check Code Line 31 for this issue!
The Right Now Reminders are white in this case, you can change the Color in the Font Settings , overdue Reminders are always in RED Color
After you did all the Stuff above, drag the last Script Geeklet onto Desktop and in the Command Line enter the Following:
ruby "Path/to/file/remi.rb"
Set the refresh time to whatever you need, i use an every 30 minutes refresh, so 60*30 is the Math
Plz note that every time this Script will trigger, the Reminders App will be launched by the Applescript, so best Practise is to have your Reminders App running all the time in the Dock
No comments:
Post a Comment