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.
here you go.
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[30m" #black
  #color = "\e[37m" #uncomment for white
  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)
just put this code into a shell geeklet. you can change some parameters like the color of "today" marker and the separator symbol.
have fun!


You are the man! Thank you so much! :D
 
I've been working on an adapted version of Fuzzy Clock, which displays the time in words, to display the "rough" time; five past one, twenty-five to seven etc.

How would I go about adding one to the hour, from x:33 an onwards so that it displays the correct time, as opposed to "twenty-five to one" at 13:35?

Thanks for your help guys and apologies for the horrifically long script

Code:
#!/bin/bash
# converts exact time To fuzzy format
export exact_time=$(date '+%I:%M')
export exact_hour=$(echo $exact_time | cut -c 1,2)
export exact_minute=$(echo $exact_time | cut -c 4,5)
case $exact_hour in
01) export fuzzy_hour='One';;
02) export fuzzy_hour='Two';;
03) export fuzzy_hour='Three';;
04) export fuzzy_hour='Four';;
05) export fuzzy_hour='Five';;
06) export fuzzy_hour='Six';;
07) export fuzzy_hour='Seven';;
08) export fuzzy_hour='Eight';;
09) export fuzzy_hour='Nine';;
10) export fuzzy_hour='Ten';;
11) export fuzzy_hour='Eleven';;
12) export fuzzy_hour='Twelve';;
esac
case $exact_minute in
00) export fuzzy_minute='';;
01) export fuzzy_minute='';;
02) export fuzzy_minute='';;
03) export fuzzy_minute='Five Past';;
04) export fuzzy_minute='Five Past';;
05) export fuzzy_minute='Five Past';;
06) export fuzzy_minute='Five Past';;
07) export fuzzy_minute='Five Past';;
08) export fuzzy_minute='Ten Past';;
09) export fuzzy_minute='Ten Past';;
10) export fuzzy_minute='Ten Past';;
11) export fuzzy_minute='Ten Past';;
12) export fuzzy_minute='Ten Past';;
13) export fuzzy_minute='Quarter Past';;
14) export fuzzy_minute='Quarter Past';;
15) export fuzzy_minute='Quarter Past';;
16) export fuzzy_minute='Quarter Past';;
17) export fuzzy_minute='Quarter Past';;
18) export fuzzy_minute='Twenty Past';;
19) export fuzzy_minute='Twenty Past';;
20) export fuzzy_minute='Twenty Past';;
21) export fuzzy_minute='Twenty Past';;
22) export fuzzy_minute='Twenty Past';;
23) export fuzzy_minute='Twenty-Five Past';;
24) export fuzzy_minute='Twenty-Five Past';;
25) export fuzzy_minute='Twenty-Five Past';;
26) export fuzzy_minute='Twenty-Five Past';;
27) export fuzzy_minute='Twenty-Five Past';;
28) export fuzzy_minute='Half Past';;
29) export fuzzy_minute='Half Past';;
30) export fuzzy_minute='Half Past';;
31) export fuzzy_minute='Half Past';;
32) export fuzzy_minute='Half Past';;
33) export fuzzy_minute='Twenty-Five To';;
34) export fuzzy_minute='Twenty-Five To';;
35) export fuzzy_minute='Twenty-Five To';;
36) export fuzzy_minute='Twenty-Five To';;
37) export fuzzy_minute='Twenty-Five To';;
38) export fuzzy_minute='Twenty To';;
39) export fuzzy_minute='Twenty To';;
40) export fuzzy_minute='Twenty To';;
41) export fuzzy_minute='Twenty To';;
42) export fuzzy_minute='Twenty To';;
43) export fuzzy_minute='Quarter To';;
44) export fuzzy_minute='Quarter To';;
45) export fuzzy_minute='Quarter To';;
46) export fuzzy_minute='Quarter To';; 
47) export fuzzy_minute='Quarter To';;
48) export fuzzy_minute='Ten To';;
49) export fuzzy_minute='Ten To';;
50) export fuzzy_minute='Ten To';;
51) export fuzzy_minute='Ten To';;
52) export fuzzy_minute='Ten To';;
53) export fuzzy_minute='Five To';;
54) export fuzzy_minute='Five To';;
55) export fuzzy_minute='Five To';;
56) export fuzzy_minute='Five To';;
57) export fuzzy_minute='Five To';;
58) export fuzzy_minute='';;
59) export fuzzy_minute='';;
esac
export fuzzy_time="About $fuzzy_minute $fuzzy_hour"
echo $fuzzy_time
exit 0
# Local variables:
# Coding: utf-8
# End:
 
Anyone have a countdown to Christmas Script? It would make my Christmas themed Desktop much better! Thank you!

I have a countdown on my desktop, where the script counts down the days and the I use a separate echo "days until _____" to list what I'm counting down to.

Code:
python -c 'from datetime import *; print (date(2011, 12, 25) - date.today()).days'

Not sure if it's the easiest/best, but was sent my way in the past. Just tweak the year, month, day to match your needs.
 
No IP based Geektools work suddenly?

Just realized none of my ip based weather geektools, like the excellent one that TacoCore made are working on my comp suddenly, and I can't figure out why...

Went home for thanksgiving, worked perfectly there, then got back, and I got incorrect location based on my IP, then the next day after a restart, none of the scripts seem to work, and its been like this for a couple days now... Anyone else experiencing something like this?
 
One thing i'd love to be able to have up in big bold numbers are the internal temperatures of my cpus, gpus, etc..

go to http://www.bresink.com/osx/0TemperatureMonitor/download.php5 and download that application. in that disk image there will be an application called temperature monitor, right click and show package contents. in package contents in MacOS, there will be a file called tempmonitor, to test it, drag it to terminal to get the directory, put a space and type: -c -l -a

if it works,copy and paste that command into the geektool command box, works with mine!
 
Last edited:
Just realized none of my ip based weather geektools, like the excellent one that TacoCore made are working on my comp suddenly, and I can't figure out why...

Went home for thanksgiving, worked perfectly there, then got back, and I got incorrect location based on my IP, then the next day after a restart, none of the scripts seem to work, and its been like this for a couple days now... Anyone else experiencing something like this?

That is interesting, mine still work. Have you tried running them in Terminal.app?

Can you also run
Code:
ls -la
in Terminal.app to see if .zip_woeid_map.txt is listed?
 
does anyone know how to get the 5 day forecast, i saw it in a picture of someone's geektool desktop...

i already have the 2 day forecast, but i want a bigger picture, i'll see if i can find the pic.

thanks!
 
Dynamic Earth time desktop

I stumbled upon this site here and started playing around. The end result is a desktop with a dynamic Earth background that changes as the time of day changes.

ScreenShot2011-12-05at93344PM.png


I played around some more to get the moon rendered and displayed using GeekTool. The moon shadow is accurate and changes once a day via script.

On my work computer I use a GOES satellite image of my state as the background. (I manage a gas station and schedule certain maintenance when its likely to rain. It's pictured a few pages back) So there I put this small globe also rendered accurately according to the time and the current moon phase in the background.
screenshotearthmoon.png


I modified the code abit from whats on the original site.
Here's my bgcreator.sh variant:
Code:
#!/bin/bash
cd ~/Pictures/xplanet_desktop
rm rectangularOLD.jpg
rm rectangular.jpg
cd ~/xplanet

xplanetcmd="/opt/local/bin/xplanet"
config="/Users/USER_NAME/xplanet/config"
outdir="/Users/USER_NAME/Pictures/xplanet_desktop"

# Check if the output dir exists
if [ ! -d "$outdir" ]; then
	mkdir -p "$outdir"
fi

# Create the basic output (change the resolution to whatever width
# your screen is and half that for the height assuming you have
# source images with an aspect ratio of 2:1 of course...
$xplanetcmd -config $config -long -50 -lat 0 --quality 100 -verbosity 0 --num_times 1 \
--output $outdir/rectangular.jpg --geometry 1920x1080 \
--projection rectangular &> /dev/null

# Add black borders to cover missing/distorted satellite data
/opt/local/bin/convert $outdir/rectangular.jpg -fill black \
-draw "rectangle 0,0,2160,135" $outdir/rectangular.jpg
/opt/local/bin/convert $outdir/rectangular.jpg -fill black \
-draw "rectangle 0,932,2160,1080" $outdir/rectangular.jpg
cd ~/Pictures/xplanet_desktop
cp rectangular.jpg rectangularOLD.jpg

exit 0

Config:
Code:
[earth]
map=day.jpg
night_map=night.jpg
cloud_map=cloud.jpg
bump_map=earthbump.jpg
bump_scale=5
specular_map=earthspec.jpg
cloud_threshold=0
cloud_gamma=1.25

In my script I have it delete the old pics and render 2 new ones. Then I set my desktop picture to rotate between the two images. It is the most reliable method I found of changing the desktop consistently. (I tried an automator script but that was unreliable. I can change the background via bash script using
Code:
defaults write com.apple.desktop Background '{default = {ImageFilePath = "/Users/USER_NAME/Pictures/xplanet/rectangularOLD.jpg"; };}'
but I couldn't get it to change unless I did a KillAll Dock and that's klunky to say the least. Anyway if the only 2 documents in the directory are the ones created via this script it works great.


Below I've pasted the code for the moon and earth png's. I tried running these in a single script but it kept failing for some reason. Rather then continue to torture myself trying to figure out if I just suck at scripting or if its a bug I just scheduled the two working scripts to run separately.
mooncreator.sh
Code:
#!/bin/bash

xplanetcmd="/opt/local/bin/xplanet"
config="/Users/USER_NAME/xplanet/moon_config"
outdir="/Users/USER_NAME/Pictures/xplanet"

# Check if the output dir exists
if [ ! -d "$outdir" ]; then
	mkdir -p "$outdir"
fi

# Create the basic output (change the resolution to whatever width
# your screen is and half that for the height assuming you have
# source images with an aspect ratio of 2:1 of course...
$xplanetcmd -config $config -body moon -origin earth --quality 100 -verbosity 0 --num_times 1 \
--transpng $outdir/moon.png --geometry 600x480 \
&> /dev/null

moon_config
Code:
[moon]
map=moon.jpg
shade=20
bump_map=moonbump.jpg
bump_scale=1

earth_png.sh
Code:
#!/bin/bash

cd ~/xplanet

xplanetcmd="/opt/local/bin/xplanet"
config="/Users/USER_NAME/xplanet/config"
outdir="/Users/USER_NAME/Pictures/xplanet"

# Check if the output dir exists
if [ ! -d "$outdir" ]; then
	mkdir -p "$outdir"
fi

#North America east coast -long -70 lat 20

# Create the basic output (change the resolution to whatever width
# your screen is and half that for the height assuming you have
# source images with an aspect ratio of 2:1 of course...
$xplanetcmd -config $config -long -70 -lat 20 --quality 100 -verbosity 0 --num_times 1 \
--transpng $outdir/earth.png --geometry 1080x1080 \
--projection orthographic &> /dev/null

exit 0
On the earth_png.sh I have it centered on N. America. You can play with -long and -lat to center it around your area or remove it entirely and the Earth will rotate.

Some links that may come in handy for textures:
Earth Day
Earth night
earth clouds
(clouds are updated daily so you can get semi accurate clouds if you want by scripting their retrieval.
earth bump
earth specular

moon
moon bump


Sorry for the wall of text. I figured someone would like to know how to do this and I spent two days reading allot about xplanet. I figure if I can save someone that time it'd be worth it. :apple:
 
Last edited by a moderator:
I stumbled upon this site here and started playing around. The end result is a desktop with a dynamic Earth background that changes as the time of day changes.

Nice work! Glad to see the CrossFit script is working well. I wish there was a way I could get the list of people who have submitted scores to the CrossFit website to not show up.

Is the Gas Station list the updated one I made for you or is it yours? Are there any issues with the scripts that I need to fix?
 
Nice work! Glad to see the CrossFit script is working well. I wish there was a way I could get the list of people who have submitted scores to the CrossFit website to not show up.

Is the Gas Station list the updated one I made for you or is it yours? Are there any issues with the scripts that I need to fix?

Thanks. Actually I don't mind the scores. It helps me kind of shoot for the stars when I work out. It's a nice gauge sometimes.

The gas buddy script is the one I made. I couldn't get the one you sent working right. I think I may be doing something wrong. I didn't want to bother you because my script is working fine and honestly I didn't put enough time to figure out if it was me.
Anyway I call it this way:
Code:
/Users/me/Documents/Scripts/Competetive_Fuel_Prices/gasbuddyv1.py -f Cumberland@http://m.gasbuddy.com/StationProfile.aspx?s=MVtn7QmOZDw%3d
and I get this:
computer:~ me$ /Users/me/Documents/Scripts/Competetive_Fuel_Prices/gasbuddyv1.py -f Cumberland@http://m.gasbuddy.com/StationProfile.aspx?s=MVtn7QmOZDw%3d&t=33020
[1] 20174
computer:~ me$ Traceback (most recent call last):
File "/Users/me/Documents/Scripts/Competetive_Fuel_Prices/gasbuddyv1.py", line 213, in <module>
gasbuddyMain(sys.argv[1:])
File "/Users/me/Documents/Scripts/Competetive_Fuel_Prices/gasbuddyv1.py", line 203, in gasbuddyMain
stationlist = parseFile(opts)
File "/Users/me/Documents/Scripts/Competetive_Fuel_Prices/gasbuddyv1.py", line 80, in parseFile
f = open(opts.file)
IOError: [Errno 2] No such file or directory: 'Cumberland@http://m.gasbuddy.com/StationProfile.aspx?s=MVtn7QmOZDw%3d'

Since my script works it's no big deal. But it might help out someone who want to use it and doesn't want to figure out how to modify the mess of code I posted.
 
I've been working on an adapted version of Fuzzy Clock, which displays the time in words, to display the "rough" time; five past one, twenty-five to seven etc.

How would I go about adding one to the hour, from x:33 an onwards so that it displays the correct time, as opposed to "twenty-five to one" at 13:35?

Thanks for your help guys and apologies for the horrifically long script

Code:
#!/bin/bash
# converts exact time To fuzzy format
export exact_time=$(date '+%I:%M')
export exact_hour=$(echo $exact_time | cut -c 1,2)
export exact_minute=$(echo $exact_time | cut -c 4,5)
case $exact_hour in
01) export fuzzy_hour='One';;
02) export fuzzy_hour='Two';;
03) export fuzzy_hour='Three';;
04) export fuzzy_hour='Four';;
05) export fuzzy_hour='Five';;
06) export fuzzy_hour='Six';;
07) export fuzzy_hour='Seven';;
08) export fuzzy_hour='Eight';;
09) export fuzzy_hour='Nine';;
10) export fuzzy_hour='Ten';;
11) export fuzzy_hour='Eleven';;
12) export fuzzy_hour='Twelve';;
esac
case $exact_minute in
00) export fuzzy_minute='';;
01) export fuzzy_minute='';;
02) export fuzzy_minute='';;
03) export fuzzy_minute='Five Past';;
04) export fuzzy_minute='Five Past';;
05) export fuzzy_minute='Five Past';;
06) export fuzzy_minute='Five Past';;
07) export fuzzy_minute='Five Past';;
08) export fuzzy_minute='Ten Past';;
09) export fuzzy_minute='Ten Past';;
10) export fuzzy_minute='Ten Past';;
11) export fuzzy_minute='Ten Past';;
12) export fuzzy_minute='Ten Past';;
13) export fuzzy_minute='Quarter Past';;
14) export fuzzy_minute='Quarter Past';;
15) export fuzzy_minute='Quarter Past';;
16) export fuzzy_minute='Quarter Past';;
17) export fuzzy_minute='Quarter Past';;
18) export fuzzy_minute='Twenty Past';;
19) export fuzzy_minute='Twenty Past';;
20) export fuzzy_minute='Twenty Past';;
21) export fuzzy_minute='Twenty Past';;
22) export fuzzy_minute='Twenty Past';;
23) export fuzzy_minute='Twenty-Five Past';;
24) export fuzzy_minute='Twenty-Five Past';;
25) export fuzzy_minute='Twenty-Five Past';;
26) export fuzzy_minute='Twenty-Five Past';;
27) export fuzzy_minute='Twenty-Five Past';;
28) export fuzzy_minute='Half Past';;
29) export fuzzy_minute='Half Past';;
30) export fuzzy_minute='Half Past';;
31) export fuzzy_minute='Half Past';;
32) export fuzzy_minute='Half Past';;
33) export fuzzy_minute='Twenty-Five To';;
34) export fuzzy_minute='Twenty-Five To';;
35) export fuzzy_minute='Twenty-Five To';;
36) export fuzzy_minute='Twenty-Five To';;
37) export fuzzy_minute='Twenty-Five To';;
38) export fuzzy_minute='Twenty To';;
39) export fuzzy_minute='Twenty To';;
40) export fuzzy_minute='Twenty To';;
41) export fuzzy_minute='Twenty To';;
42) export fuzzy_minute='Twenty To';;
43) export fuzzy_minute='Quarter To';;
44) export fuzzy_minute='Quarter To';;
45) export fuzzy_minute='Quarter To';;
46) export fuzzy_minute='Quarter To';; 
47) export fuzzy_minute='Quarter To';;
48) export fuzzy_minute='Ten To';;
49) export fuzzy_minute='Ten To';;
50) export fuzzy_minute='Ten To';;
51) export fuzzy_minute='Ten To';;
52) export fuzzy_minute='Ten To';;
53) export fuzzy_minute='Five To';;
54) export fuzzy_minute='Five To';;
55) export fuzzy_minute='Five To';;
56) export fuzzy_minute='Five To';;
57) export fuzzy_minute='Five To';;
58) export fuzzy_minute='';;
59) export fuzzy_minute='';;
esac
export fuzzy_time="About $fuzzy_minute $fuzzy_hour"
echo $fuzzy_time
exit 0
# Local variables:
# Coding: utf-8
# End:

I don't know about rough but I wrote my fuzzy clock to say "twenty to ten" instead of "nine fourty". (I'm English, its how we speak time lol). It's the same principle.

You can get my geeklet from This repository of Geeklets

Usually you output the words in hour:minute e.g 9:40. However when you say "twenty to ten" your output is actually minute:hour.

The key is that when the minute is greater than 30, you add one to the current hour and then output the time in minute:upcoming hour.

The problem you then get, is what happens when its 12:40 ? You don't want your fuzzy clock to say it's "Twenty to Thirteen" :)

And for anyone too lazy or disinterested to go and see all of the other goodies on that site, here is the UK Fuzzy Time code

Code:
# convert time to British spoken (fuzzy) format

time=$(date '+%I:%M')

# remove the leading zero so we can do maths with the hour
current_hour=$(echo $time | cut -c 1,2 | sed 's/^0//')

current_minute=$(echo $time | cut -c 4,5)

if [ ${current_minute} -gt 30 ]
then
        let current_hour=${current_hour}+1
else
        :
fi

case $current_hour in
        1) hour='one';;
        2) hour='two';;
        3) hour='three';;
        4) hour='four';;
        5) hour='five';;
        6) hour='six';;
        7) hour='seven';;
        8) hour='eight';;
        9) hour='nine';;
        10) hour='ten';;
        11) hour='eleven';;
        12) hour='twelve';;
        13) hour='one';;
esac

case $current_minute in
        00) minute="o'clock";;
        01) minute='one minute past';;
        02) minute='two minutes past';;
        03) minute='three minutes past';;
        04) minute='four minutes past';;
        05) minute='five past';;
        06) minute='six minutes past';;
        07) minute='seven minutes past';;
        08) minute='eight minutes past';;
        09) minute='nine minutes past';;
        10) minute='ten past';;
        11) minute='eleven minutes past';;
        12) minute='twelve minutes past';;
        13) minute='thirteen minutes past';;
        14) minute='fourteen minutes past';;
        15) minute='quarter past';;
        16) minute='sixteen minutes past';;
        17) minute='seventeen minutes past';;
        18) minute='eighteen minutes past';;
        19) minute='nineteen minutes past';;
        20) minute='twenty past';;
        21) minute='twenty-one minutes past';;
        22) minute='twenty-two minutes past';;
        23) minute='twenty-three minutes past';;
        24) minute='twenty-four minutes past';;
        25) minute='twenty-five past';;
        26) minute='twenty-six minutes past';;
        27) minute='twenty-seven minutes past';;
        28) minute='twenty-eight minutes past';;
        29) minute='twenty-nine minutes past';;
        30) minute='half past';;
        31) minute='twenty-nine minutes to';;
        32) minute='twenty-eight minutes to';;
        33) minute='twenty-seven minutes to';;
        34) minute='twenty-six minutes to';;
        35) minute='twenty-five to';;
        36) minute='twenty-four minutes to';;
        37) minute='twenty-three minutes to';;
        38) minute='twenty-two minutes to';;
        39) minute='twenty-one minutes to';;
        40) minute='twenty to';;
        41) minute='nineteen minutes to';;
        42) minute='eighteen minutes to';;
        43) minute='seventeen minutes to';;
        44) minute='sixteen minutes to';;
        45) minute='quarter to';;
        46) minute='fourteen minutes to';; 
        47) minute='thirteen minutes to';;
        48) minute='twelve minutes to';;
        49) minute='eleven minutes to';;
        50) minute='ten to';;
        51) minute='nine minutes to';;
        52) minute='eight minutes to';;
        53) minute='seven minutes to';;
        54) minute='six minutes to';;
        55) minute='five to';;
        56) minute='four minutes to';;
        57) minute='three minutes to';;
        58) minute='two minutes to';;
        59) minute='one minute to';;
esac

case $current_minute in
        00) echo "$hour $minute";;
        *) echo "$minute $hour";;
esac

hope this helps.
 
I don't know about rough but I wrote my fuzzy clock to say "twenty to ten" instead of "nine fourty". (I'm English, its how we speak time lol). It's the same principle.

You can get my geeklet from This repository of Geeklets

Usually you output the words in hour:minute e.g 9:40. However when you say "twenty to ten" your output is actually minute:hour.

The key is that when the minute is greater than 30, you add one to the current hour and then output the time in minute:upcoming hour.

The problem you then get, is what happens when its 12:40 ? You don't want your fuzzy clock to say it's "Twenty to Thirteen" :)

And for anyone too lazy or disinterested to go and see all of the other goodies on that site, here is the UK Fuzzy Time code

Code:
# convert time to British spoken (fuzzy) format

time=$(date '+%I:%M')

# remove the leading zero so we can do maths with the hour
current_hour=$(echo $time | cut -c 1,2 | sed 's/^0//')

current_minute=$(echo $time | cut -c 4,5)

if [ ${current_minute} -gt 30 ]
then
        let current_hour=${current_hour}+1
else
        :
fi

case $current_hour in
        1) hour='one';;
        2) hour='two';;
        3) hour='three';;
        4) hour='four';;
        5) hour='five';;
        6) hour='six';;
        7) hour='seven';;
        8) hour='eight';;
        9) hour='nine';;
        10) hour='ten';;
        11) hour='eleven';;
        12) hour='twelve';;
        13) hour='one';;
esac

case $current_minute in
        00) minute="o'clock";;
        01) minute='one minute past';;
        02) minute='two minutes past';;
        03) minute='three minutes past';;
        04) minute='four minutes past';;
        05) minute='five past';;
        06) minute='six minutes past';;
        07) minute='seven minutes past';;
        08) minute='eight minutes past';;
        09) minute='nine minutes past';;
        10) minute='ten past';;
        11) minute='eleven minutes past';;
        12) minute='twelve minutes past';;
        13) minute='thirteen minutes past';;
        14) minute='fourteen minutes past';;
        15) minute='quarter past';;
        16) minute='sixteen minutes past';;
        17) minute='seventeen minutes past';;
        18) minute='eighteen minutes past';;
        19) minute='nineteen minutes past';;
        20) minute='twenty past';;
        21) minute='twenty-one minutes past';;
        22) minute='twenty-two minutes past';;
        23) minute='twenty-three minutes past';;
        24) minute='twenty-four minutes past';;
        25) minute='twenty-five past';;
        26) minute='twenty-six minutes past';;
        27) minute='twenty-seven minutes past';;
        28) minute='twenty-eight minutes past';;
        29) minute='twenty-nine minutes past';;
        30) minute='half past';;
        31) minute='twenty-nine minutes to';;
        32) minute='twenty-eight minutes to';;
        33) minute='twenty-seven minutes to';;
        34) minute='twenty-six minutes to';;
        35) minute='twenty-five to';;
        36) minute='twenty-four minutes to';;
        37) minute='twenty-three minutes to';;
        38) minute='twenty-two minutes to';;
        39) minute='twenty-one minutes to';;
        40) minute='twenty to';;
        41) minute='nineteen minutes to';;
        42) minute='eighteen minutes to';;
        43) minute='seventeen minutes to';;
        44) minute='sixteen minutes to';;
        45) minute='quarter to';;
        46) minute='fourteen minutes to';; 
        47) minute='thirteen minutes to';;
        48) minute='twelve minutes to';;
        49) minute='eleven minutes to';;
        50) minute='ten to';;
        51) minute='nine minutes to';;
        52) minute='eight minutes to';;
        53) minute='seven minutes to';;
        54) minute='six minutes to';;
        55) minute='five to';;
        56) minute='four minutes to';;
        57) minute='three minutes to';;
        58) minute='two minutes to';;
        59) minute='one minute to';;
esac

case $current_minute in
        00) echo "$hour $minute";;
        *) echo "$minute $hour";;
esac

hope this helps.

Hell yes it does! Thank you. I will finish this version up (I'm in the UK too, and I wanted it to say the approximate time, so this is 100% killer) Thank you so much! :D
 
I love this MacRumors python script, but wonder if there's a way to pull the latest threads from a certain forum section? I would like a feed that shows the latest threads in the Mac Pro forum, for example. Is this possible?
Bringing back an old one for you SandboxGeneral...

Are you still looking for a MacRumors display? It's your lucky day if you are, here it is.

Code:
#!/usr/bin/env python

""" MACRUMORS_FEED_GRABBER
 ROBERT WOLTERMAN (xtacocorex) - 2010

 PULLS THE CURRENT FEED FROM MACRUMORS
 
"""

# MACRUMORS FEED - VERSION 1
# ROBERT WOLTERMAN - 2011
# PULLS THE CURRENT FEED FROM MACRUMORS

# CHANGELOG
# 12 SEPTEMBER 2011:
#  - INITIAL WRITE

# MODULE IMPORTS
import xml.dom.minidom
from optparse import OptionParser
import re
import urllib
import sys

# CONSTANTS
FEEDURL = "http://feeds.macrumors.com/MacRumors-All"

# CLASS TO HOLD THE DATA FOR A FEED ITEM
class NewsItem():
    def __init__(self):
        self.title = ""
        self.link = ""
        self.desc = ""
        self.pubdate = ""

# THE FOLLOWING TWO FUNCTIONS ARE FROM:
# http://love-python.blogspot.com/2008/07/strip-html-tags-using-python.html
# THEY WORK PERFECTLY
def remove_html_tags(data):
    p = re.compile(r'<.*?>')
    return p.sub('', data)    

def remove_extra_spaces(data):
    p = re.compile(r'\s+')
    return p.sub(' ', data)

# INLINE FUNCTIONS - DON'T FEEL LIKE CLASSING THIS UP
def getText(nodelist):
    rc = []
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc.append(node.data)
    return ''.join(rc)

def handleFeed(feed,FeedItems):
    items = feed.getElementsByTagName("item")
    handleNewsItem(items,FeedItems)

def handleNewsItem(items,FeedItems):
    for item in items:
        # CREATE TEMPORARY TODO
        tmpCls = NewsItem()
        # GET THE DATA FROM THE CURRENT ITEM
        title = item.getElementsByTagName("title")[0]
        link = item.getElementsByTagName("link")[0]
        pubdate = item.getElementsByTagName("pubDate")[0]
        # DESCRIPTION USES CDATA INSIDE TO CONTAIN HTML ELEMENTS
        desc = item.getElementsByTagName("description")[0].firstChild.wholeText
        # GET THE VALUES FROM THE TAGS
        tmpCls.title = getText(title.childNodes).strip()
        tmpCls.link = getText(link.childNodes).strip()
        tmpCls.pubdate = getText(pubdate.childNodes).strip()
        # DESCRIPTION IS DIFFERENT BECAUSE OF THE CDATA USE
        tmpCls.desc = remove_extra_spaces(remove_html_tags(desc))
        # APPEND TEMP DROPBOX NEWS CLASS TO DROP BOX NEWS LIST
        FeedItems.append(tmpCls)

def cmdLineOptionParser():
    """
        cmdLineOptionParser()
         - PARSES THE COMMAND LINE ARGUMENTS
         - INPUT:  NONE
         - OUPUTS: NONE
    """
    # CREATE OUR USAGE REPSONSE 
    usage = ("%prog [options]",__doc__)
    
    usage = "\n".join(usage)
    
    # CREATE OUR COMMAND LINE PARSER
    cmdparse = OptionParser(usage)
    
    # ADD COMMAND LINE OPTIONS
    cmdparse.add_option('-c', '--count', action='store', type='int',
        help="line count for output, default is 10",
        default=10
    )
    
    # NOT IMPLEMENTED
    #cmdparse.add_option('-s', '--sort', action="store", type='string',
    #    help="sort direction for the news items: forward/reverse",
    #    default='forward'
    #)
    
    # RETURN THE PARSER
    return cmdparse

if __name__ == "__main__":

    # SET UP THE COMMAND LINE OPTION HOLDER
    cmdparse = cmdLineOptionParser()
        
    # PARSE THE COMMAND LINE OPITONS
    opts, args = cmdparse.parse_args(sys.argv[1:])

    # GET THE FEED - UPDATE TO CMD LINE ARGUMENT
    dom = xml.dom.minidom.parse(urllib.urlopen(FEEDURL))

    # LIST TO HOLD ALL THE TASKS (toDo CLASS)
    FeedItems = []

    # HANDLE THE XML
    handleFeed(dom,FeedItems)

    # FIGURE OUT THE NUMBER OF ITEMS WE SHOULD PRINT
    if len(FeedItems) > opts.count:
        numprint = opts.count
    else:
        numprint = len(FeedItems)

    # PRINT OUT THE MACRUMORS NEWS
    # THIS IS CUSTOMIZABLE
    for i in range(numprint):
        # PRINT OUT THE DATA HOWEVER YOU WANT
        # DATA STORED IN EACH FeedItems SEGMENT
        # FeedItems[i].title   = TITLE OF THE NEWS ITEM
        # FeedItems[i].desc    = DESCRIPTION OF THE NEWS ITEM
        # FeedItems[i].link    = NEWS ITEM LINK
        # FeedItems[i].pubdate = DATE THE NEWS ITEM WAS PUBLISHED
        # CURRENTLY SET TO PRINT THE PUB DATE AND THE TITLE
        print FeedItems[i].pubdate + " " + FeedItems[i].title

Save the script as macrumorsnews.py. Output is customizable and is currently set to the publishing date and the title.

Options are similar to my Dropbox RSS feed script.
Code:
Options:
  -h, --help            show this help message and exit
  -c COUNT, --count=COUNT
                        line count for output, default is 10

For the geeklet (displays all items)
Code:
python /path/to/script/macrumorsnews.py


----------



They are images controlled by a Python script. I have an image for each month with the text vertical, they are .png files with transparent backgrounds.

I have a folder of the images in the location where I store all my geektool scripts, the script logic grabs this location and knows where the images are for the copy command at the end.

I have two geeklets, one to run the python script and another set to be an image pointed at /tmp/geektool/curmonthpic.png.

The python script is as follows:
Code:
#!/usr/bin/env python

import os, shutil, time

# Sets the current month to the /tmp/geektool/curmonthpic.png file

home = os.environ['HOME']
#print home
wdir = home+"/bin/geektool"
os.chdir(wdir)
cwd = os.getcwd()
#print cwd

ipath=cwd+"/monthimages/"
cfile="/tmp/geektool/curmonthpic.png"

# Set up day icon dictionary
monthmap = {
    'January'   : 'january.png',
    'February'  : 'february.png',
    'March'     : 'march.png',
    'April'     : 'april.png',
    'May'       : 'may.png',
    'June'      : 'june.png',
    'July'      : 'july.png',
    'August'    : 'august.png',
    'September' : 'september.png',
    'October'   : 'october.png',
    'November'  : 'november.png',
    'December'  : 'december.png'
	}

# GET THE CURRENT DATE
month = time.strftime("%B")

cicon = ipath + monthmap[month]

#print cicon

# Copy the current month image to /tmp/geektool/curmonthimg.png
shutil.copyfile(cicon,cfile)
 
Need help with Yahoo Weather Scripts.

I can get them to work sometimes, other times they don't What isn't working specifically right now is my weather image. Here are my codes:

Forecast:

echo && curl --silent "http://xml.weather.yahoo.com/forecastrss?p=UStx1060&u=f" | grep -e "Forecast:" -A 2 | tail -n 2 | sed -e 's/<br \/>//' -e 's/<BR \/>//' | sed "s/\(.*\)\.\ \(.*\)/\1\?\2/" | tr "?" "\n" | sed "s/High\:\ \(.*\)\ Low\:\ \(.*\)/\?High\: \1\ Low\:\ \2/" | sed "s/\?\(.*\)/\\1/"

Current Conditions:

curl --silent "http://xml.weather.yahoo.com/forecastrss?p=75093&u=f" | grep -E '(Current Conditions:|F<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'


Then here are the ones I don't think are working, its 11:33AM and its showing a moon.

curl --silent "http://weather.yahoo.com/united-states/texas/plano-12790372/?unit=f" | grep "forecast-icon" | sed "s/.*background\:url(\'\(.*\)\')\;\ _background.*/\1/" | xargs curl --silent -o /tmp/weather.png

and the image shell:

file:///tmp/weather.png



Any help would be greatly appreciated!
 
I love this MacRumors python script, but wonder if there's a way to pull the latest threads from a certain forum section? I would like a feed that shows the latest threads in the Mac Pro forum, for example. Is this possible?

Is there an actual RSS feed for the forum sections? I couldn't find one. If there isn't one available, it would probably have to parse the regular page and that could get dicey since you don't know what is new or not.
 
Angling GeekTool Scripts?

First of all, awesome thread! Secondly, on page 23, Flyne attempted to explain how you could move your GeekTool script at a slight angle. I tried to follow this guide (post 449), but unfortunately was not able to install the programs without a bunch of errors :(

Since his post was two years old, I was wondering if there is an easier way to angle your GeekTool scripts?
 
First of all, awesome thread! Secondly, on page 23, Flyne attempted to explain how you could move your GeekTool script at a slight angle. I tried to follow this guide (post 449), but unfortunately was not able to install the programs without a bunch of errors :(

Since his post was two years old, I was wondering if there is an easier way to angle your GeekTool scripts?

There is a way, but it's a pain in the ass. I found a script to help install ImageMagick because the binary that is provided on their website is for Lion and I'm running Snow Leopard on a Core Duo MacBook. This is how I installed ImageMagick, it is an older version, but for the stuff we need it to do, it won't matter what version it is. If you are running Lion, the binary provided on the ImageMagick website should work for you.

https://github.com/masterkain/ImageMagick-sl/blob/master/install_im.sh

You need the developer tools installed that comes with XCode because this will download a bunch of libraries and compile everything from the source code. If this sounds daunting already, then it probably isn't worth it to you.

Once ImageMagick is installed, you can learn how it works here: http://www.imagemagick.org/Usage/

Here is a simple script I just came up with to test out angled text, it gets the date, converts it to all uppercase, then rotates. It pulls up the specific font that I want from /Library/Fonts. The background is transparent, for nice use on the desktop. The script will save the file in the directory it is run from, so you'll need to specify the path if you want it saved to a special location.

Code:
#!/bin/bash

mytext=`date +%B`

echo $mytext | tr '[:lower:]' '[:upper:]' | convert -font /Library/Fonts/STHeiti\ Medium.ttc -background transparent -fill white -pointsize 72 label:@- -rotate -45 test.png

I'm attaching a screenshot showing the end result on my desktop. The vertical Month on my desktop is currently an image file that I pre-built and does not use the script above. The setup I am showing is just the image being displayed, I don't have a geeklet setup to run the script, so you would have to do that.
 

Attachments

  • Screen shot 2011-12-11 at 16.28.17 .jpg
    Screen shot 2011-12-11 at 16.28.17 .jpg
    358.3 KB · Views: 255
Last edited:
xtacocorex > Thank you so much for taking the time to write :) I have followed your instructions to the letter so far. I've downloaded and installed the developers tools from xCode and started installing ImageMagick through the install_im.sh you linked to (I am using Snow Leopard as well).

It downloaded everything perfectly, but when it was finished decompressing and started installing I received a whole bunch of "no's"... I'm not sure if that was supposed to happen, but just wanted to run it by you...

Code:
Starting...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Shorty/ImageMagick/libpng-1.4.8':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
./install_im.sh: line 78: make: command not found
Password:
sudo: make: command not found
checking build system type... i386-apple-darwin10.8.0
checking host system type... i386-apple-darwin10.8.0
checking target system type... i386-apple-darwin10.8.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking for style of include used by make... none
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Shorty/ImageMagick/jpeg-8c':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
./install_im.sh: line 88: make: command not found
sudo: make: command not found
./install_im.sh: line 95: make: command not found
checking build system type... i686-apple-darwin10.8.0
checking host system type... i686-apple-darwin10.8.0
checking target system type... i686-apple-darwin10.8.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking for style of include used by make... none
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Shorty/ImageMagick/lcms-2.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
./install_im.sh: line 97: make: command not found
sudo: make: command not found
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Shorty/ImageMagick/ghostscript-9.00':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
./install_im.sh: line 105: make: command not found
sudo: make: command not found
GNU make (>= 3.80) or makepp (>= 1.19) is required to build FreeType2.
Please try
  `GNUMAKE=<GNU make command name> ./configure'.
or >&2
  `GNUMAKE="makepp --norc-substitution" ./configure'.
./install_im.sh: line 118: make: command not found
sudo: make: command not found
./install_im.sh: line 125: make: command not found
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking build system type... i686-apple-darwin10.8.0
checking host system type... i686-apple-darwin10.8.0
checking for Win32... no
checking for gawk... (cached) awk
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
./install_im.sh: line 127: make: command not found
sudo: make: command not found
checking build system type... i386-apple-darwin10.8.0
checking host system type... i386-apple-darwin10.8.0
checking target system type... i386-apple-darwin10.8.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether build environment is sane... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Shorty/ImageMagick/tiff-3.9.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
./install_im.sh: line 135: make: command not found
sudo: make: command not found
configuring ImageMagick 6.7.1-10
checking build system type... i386-apple-darwin10.8.0
checking host system type... i386-apple-darwin10.8.0
checking target system type... i386-apple-darwin10.8.0
checking whether build environment is sane... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking for style of include used by make... none
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/Shorty/ImageMagick/ImageMagick-6.7.1-10':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
./install_im.sh: line 145: make: command not found
sudo: make: command not found
ImageMagick installed.
./install_im.sh: line 150: convert: command not found
Testing...
./install_im.sh: line 153: /usr/local/bin/convert: is a directory
./install_im.sh: line 154: /usr/local/bin/convert: is a directory
./install_im.sh: line 155: /usr/local/bin/convert: is a directory
./install_im.sh: line 156: /usr/local/bin/convert: is a directory
Tests done.
Jesper-Pedersens-iMac:ImageMagick Shorty$

Does that look aye okay to you?
 
Code:
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
./install_im.sh: line 127: make: command not found
sudo: make: command not found

Does that look aye okay to you?

Reading over that log you posted, that doesn't look right. Are you sure that you installed xcode? According to that snippet above, you have no C compiler (or it at least isn't linked in your $PATH, nor can it find make, which means there is no way that you can compile any applications. A compiler should have been installed when you installed xcode.

If you could, in terminal, type 'whereis gcc'. Do you then get back '/usr/bin/gcc' or something like that, or do you just get nothing when you type that? If you receive the location of gcc, then it is installed but not linked properly, if you don't get anything back from the command, then xcode wasn't installed, or it was incompletely installed.

Now when you type in terminal 'echo $PATH', you should get a string of directories, is '/usr/bin' included in there? If not, then your $PATH file needs to be fixed.
 
Does that look aye okay to you?

Not at all. :) XCode doesn't appear to be installed as Tag has mentioned above.

XCode is now a paid app in the app store, but if you have your install disk for OSX, it should be on there. I don't think you need the latest XCode for this to work, but I could be wrong.
 
I stumbled upon this site here and started playing around. The end result is a desktop with a dynamic Earth background that changes as the time of day changes.

...


Sorry for the wall of text. I figured someone would like to know how to do this and I spent two days reading allot about xplanet. I figure if I can save someone that time it'd be worth it. :apple:

WOW, awesome, thanks!!!! I have been using the other one you posted, but will be trying this out. Your detail IS very much appreciated!!!!
 
Reading over that log you posted, that doesn't look right. Are you sure that you installed xcode? According to that snippet above, you have no C compiler (or it at least isn't linked in your $PATH, nor can it find make, which means there is no way that you can compile any applications. A compiler should have been installed when you installed xcode.

If you could, in terminal, type 'whereis gcc'. Do you then get back '/usr/bin/gcc' or something like that, or do you just get nothing when you type that? If you receive the location of gcc, then it is installed but not linked properly, if you don't get anything back from the command, then xcode wasn't installed, or it was incompletely installed.

Now when you type in terminal 'echo $PATH', you should get a string of directories, is '/usr/bin' included in there? If not, then your $PATH file needs to be fixed.

When I typed "whereis gcc" I did not get any response :( However, when I typed echo $PATH I got the correct path, like you mentioned... The way I installed xCode was by registering myself as a programmer at Apple, which allowed me to download the following file: xcode313_2736_developerdvd

When I opened that .dmg-file, it gave me the option of installing "Developer Tools", which I did... Can't see what the problem is :S
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.