Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
Not open for further replies.
The first line controls the date you're counting down to.
Code:
THEN=`date -v10y -v8d -v9m +%s`
SECS=$(($THEN-$(date +%s)))
echo "Days: "$(($SECS/3600/24))
Output looks like:
Code:
Days: 60
 
First off, I want to thank all of you for the work you have done. I know nothing about scripting and this thread has been a huge help to me. There is some amazing work displayed.

I have read through just about every page and have tried a lot of different weather scripts listed. I am having a problem getting them to display. My goal is to get current conditions and icon to display but when I try the different scripts listed, I do not get any results, just a blank window..

The last set of scripts I tried are THESE from RogersDA. I modify the url for my location, drag the shell geeklet to my desktop and paste the script in the command line but se nothing. Can someone tell me what I am doing wrong?

EDIT - Figured out what I was doing wrong. I forgot to add the image pointer.
 
That's just math. The SECS variable holds the number of seconds between the dates. You just have to do the right math on it to get each piece. See this page for help. I'll leave it to you to try to implement. It'll let you learn something in the process instead of just having the answer given to you ;)
 
uh, i got it "working". it shows accurate time for when I wrote the code in, but it's not refreshing?

heres what i have
Code:
THEN=`date -v10y -v9d -v9m +%s`
SECS=$(($THEN-$(date +%s)))
echo "Days: "$(($SECS/3600/24))
echo "Hours: "$(($SECS/3600))
echo "Minutes: "$(($SECS/60))
echo "Seconds: "$(($SECS))
 
Awesome, I knew you could figure it out. The refresh is a Geektool option. At least in version 3 there's a "Refresh every" field under the command field that you can put "1" in that will refresh every second.
 
Awesome, I knew you could figure it out. The refresh is a Geektool option. At least in version 3 there's a "Refresh every" field under the command field that you can put "1" in that will refresh every second.
i did that but it's still not reloading :S
 
Hi guys. I've just started messing around with GeekTool and I'm slowly starting to get the hang of it. UNIX code is still Chinese to me though :p

Anyway, I've been trying to add a birthday calendar to my desktop but I haven't found any way to do so... I've tried using this http://www.versiontracker.com/dyn/moreinfo/macosx/24591 but I've had no luck in getting it to work. I think there is an icalBuddy command that does what I want, but I'm not sure how to use that either...

Any ideas?

@Macdaddy1129 Really nice desktop. Can you tell me the script you used to make that circular progression bar for iTunes? :)

Thanks!
 
Oh right, forgot. The first line does a date adjustment, but currently doesn't adjust the time, so there's only ever a day difference calculated. Here's an updated first line that sets it to the given date at 12am (0:00:00)

Code:
THEN=`date -v10y -v9m -v9d -v0H -v0M -v0S +%s`
 
Attached is a 3-month calendar with the current month progress and day highlighted. Below is the code for it.

Code:
cal -m $(($[10#$(date +%m)]-1)) | sed -e s'/^/ /'
echo "\033[32m\c"
cal | sed "s/^/ /;s/$/ /;s/ $(date +%e | sed s'/ //') /$(date +%e | sed -e s'/ //' -e s'/\(.*\)/ \1 /g')/"
cal -m $(($[10#$(date +%m)]+1)) | sed -e s'/^/ /'
There are escaped characters on line 3. They are entered by doing a control+q esc (It's invisible when typed) and go right before the two [ chars toward the end of the line. When used inside a double quote area, you can use \033 instead, like on line 2. The coloring is done with ANSI color does. This page list the small list of codes.

Edit [20100801]: There was an octal parsing error so made the script parse to decimal explicitly.
 

Attachments

  • geektool-3month.png
    geektool-3month.png
    51 KB · Views: 136
Hello all,

I was hoping I could get some technical coding assistance?

Here's the code I'm using for my Calendar events and Todo's:

echo "\nEvents\n"; /usr/local/bin/icalBuddy -nc -nrd -sd eventsToday+14 | sed -e "s/*/•/" | sed -e "s/!/!!/"; echo "\nTasks\n"; /usr/local/bin/icalBuddy -nc uncompletedTasks | sed -e "s/*/•/" | sed -e "s/!/!!/"

I was wondering if there was a command within GeekTool that allowed for a specific line to be centered without affecting the alignment of the rest of the information? For example: In the case above, everything is either left, center, or right justified depending on the generalized setting on the GT inspector. What I would like to have is for "Events" and "Tasks" centered over the print out of events and todo's that are left justified. Is there such a command? I know that using \n adds a line break. Is there something along the lines of \n that centers the specific text of the echo argument?

Oh, in case you were wondering why I don't make a stand alone echo shell and have it above the rest of the info - it's because I want everything to automatically adjust for the change in the number of lines displayed.

Thank you to all who have submitted the various GT scripts and information :)
 
Attached is a 3-month calendar with the current month progress and day highlighted. Below is the code for it.

Code:
cal -m $(($(date +%m)-1)) | sed -e s'/^/ /'
echo "\033[32m\c"
cal | sed "s/^/ /;s/$/ /;s/ $(date +%e | sed s'/ //') /$(date +%e | sed -e s'/ //' -e s'/\(.*\)/ [42;30m\1[0m /g')/"
cal -m $(($(date +%m)+1)) | sed -e s'/^/ /'
There are escaped characters on line 3. They are entered by doing a control+q esc (It's invisible when typed) and go right before the two [ chars toward the end of the line. When used inside a double quote area, you can use \033 instead, like on line 2. The coloring is done with ANSI color does. This page list the small list of codes.


I could not succeed in doing this. I would be happy if I could get only the current month to highlight the current day (and no colors, I could not figure out how to put the invisible character control+q esc and quotes failed). So all I want is the code for the current month with the day "boxed" because I hate that ##, it looks ugly! But thank you for the post angelwatt.
 
I could not succeed in doing this. I would be happy if I could get only the current month to highlight the current day (and no colors, I could not figure out how to put the invisible character control+q esc and quotes failed). So all I want is the code for the current month with the day "boxed" because I hate that ##, it looks ugly! But thank you for the post angelwatt.

You should just need the third line.

Code:
cal | sed "s/^/ /;s/$/ /;s/ $(date +%e | sed s'/ //') /$(date +%e | sed -e s'/ //' -e s'/\(.*\)/ [42;30m\1[0m /g')/"

One the second line, where the [42 is, just before it hold control and hit q, then release and then hit esc. There's no visual feedback when you do this. Do the same before the [0m. If you move the text cursor across these characters you should notice it doesn't move one time for the invisible char. That should tell you it has been entered correctly. Also, the ANSI color codes only work in Geektool 3+ I believe.
 
Code:
cal | sed "s/^/ /;s/$/ /;s/ $(date +%e | sed s'/ //') /$(date +%e | sed -e s'/ //' -e s'/\(.*\)/ [42;30m\1[0m /g')/"

One the second line, where the [42 is, just before it hold control and hit q, then release and then hit esc. There's no visual feedback when you do this. Do the same before the [0m. If you move the text cursor across these characters you should notice it doesn't move one time for the invisible char. That should tell you it has been entered correctly. Also, the ANSI color codes only work in Geektool 3+ I believe.
got it to work... its really cool, even if I dont really understand why the character is invisible... can this be used on applescript? (put a part of the output a certain color)
 
Does anyone know how I would go about if I wanted to display an image in GeekTool so it would fill the window? The default behavior is to fit the image to the window when it's too big...
 
got it to work... its really cool, even if I dont really understand why the character is invisible... can this be used on applescript? (put a part of the output a certain color)

Potentially. One of the other posts recently someone was using them inside a Ruby script, but used \e for the escape character.
 
Potentially. One of the other posts recently someone was using them inside a Ruby script, but used \e for the escape character.

I saw the Ruby part... thats actually the first time I heard about the ANSI colors...:p But I really dont know how to put these in Applescript doh...
lets say (a part of) my script is this...
Code:
set displaymain to trackStatus & trackName & " | " & artistName & " | " & albumName & " | (" & tracktime & ") | " & trackrating & " | " & trackplaycount & "x" & " | " & trackplaylist
how would I put the artist in white for example? (ill figure out the rest... :D)
 
how would I put the artist in white for example?

I've never tried using any AppleScript with Geektool so no clue. I'd just try inputting the escape character in ways that have been demonstrated here, the control+q esc, \033, and the \e and see if any of those have an effect. It's just a matter of trial and error.
 
I took a look at your setup, and the calendar looks really great! Care to let us know how you did it, with so many colors and font styles?

Very nice! Thanks.

Darryl

probably with ruby, like this one! but I have no clue how to use ruby doh... so have fun! :D
Code:
#!/usr/bin/env ruby
#
# Author: Robert Jorgenson
# Author email: rjorgenson@gmail.com
require 'Date'
ABBR_DAYNAMES = {0, 'Su', 1, 'Mo', 2, 'Tu', 3, 'We', 4, 'Th', 5, 'Fr', 6, 'Sa'}

def days_in_month(year, month)
  return (Date.new(year, 12, 31) << (12 - month)).day
end

def day_in_month(year, month, day)
  return Date.new(year, month, day).wday
end

def build_day_array(year, month)
  day_array = Array.new
  for d in (1..days_in_month(year, month))
    day_array[d] = ABBR_DAYNAMES[day_in_month(year, month, d)]
  end
  day_array.shift
  return day_array * "   "
end

def build_separator(year, month)
  #color = "\e[32m" #green
  color = "\e[31m" #uncomment for red
  separator_string = "||" # change this to change separator, best if 2 characters wide
  close = "\e[0m" # don't change this
  separator = Array.new
  for d in (1..days_in_month(year, month))
    if year == Time.now.year && month == Time.now.month && d == Time.now.day then
      separator[d] = "#{color}#{separator_string}#{close}"
    else
      separator[d] = "#{separator_string}"
    end
  end
  separator.shift
  return separator * "   "
end

def build_date_array(year, month)
  date_array = Array.new
  for d in (1..days_in_month(year, month))
    date_array[d] = d
  end
  date_array.shift
  date_array.each do |d|
    if d < 10 then
      date_array[(d-1)] = "0#{d}"
    end
  end
  return date_array * "   "
end

year = Time.now.year
month = Time.now.month

puts build_day_array(year, month)
puts build_separator(year, month)
puts build_date_array(year, month)

and thanks angelwatt... ill try to make it work and ill come back with (hopefully) an answer! :)
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.