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.
Thank you very much for that.

I'm interested in Melbourne's weather, is it simply a matter of finding Melbourne's unique Yahoo code?

EDIT: scratch that, I've managed to work it out. Thanks heaps.



What is the melbourne code? I haven't been able to locate it.
 
Me Again

One more thing - can anyone change this code to output a horizontal calendar?
Code:
#!/bin/zsh

month=`date +%m`
year=`date +%Y`

nextMonth=$(($month+1))
lastMonth=$(($month-1))

if [[ $month -eq 1 ]]
then
        lastMonth=12
        cal $lastMonth $(($year-1)) | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
else
        cal $lastMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
fi

cal | awk -v cday=`date "+%d"` '{ fill=(int(cday)>9?"":" "); print " "$0; getline; print " "$0; while (getline != 0) {a=" "$0" "; sub(" "fill int(cday)" ",fill "(" int(cday)")", a); print a }}'

if [[ $month -eq 12 ]]
then
        nextMonth=1
        cal $nextMonth $(($year+1)) | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
else
        cal $nextMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
fi
I'm trying to make a modified version of this desktop and need the 3 month calendar to fit in the bottom section.
3208952107_2b635bd9cb.jpg
 
One more thing - can anyone change this code to output a horizontal calendar?
Code:
#!/bin/zsh

month=`date +%m`
year=`date +%Y`

nextMonth=$(($month+1))
lastMonth=$(($month-1))

if [[ $month -eq 1 ]]
then
        lastMonth=12
        cal $lastMonth $(($year-1)) | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
else
        cal $lastMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
fi

cal | awk -v cday=`date "+%d"` '{ fill=(int(cday)>9?"":" "); print " "$0; getline; print " "$0; while (getline != 0) {a=" "$0" "; sub(" "fill int(cday)" ",fill "(" int(cday)")", a); print a }}'

if [[ $month -eq 12 ]]
then
        nextMonth=1
        cal $nextMonth $(($year+1)) | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
else
        cal $nextMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
fi
I'm trying to make a modified version of this desktop and need the 3 month calendar to fit in the bottom section.
3208952107_2b635bd9cb.jpg

not exactly the same but i still love it!

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)

good luck with the past and next month! lol
dont know how to do it exactly...
 
One more thing - can anyone change this code to output a horizontal calendar?

Well if you wanted to use this exact script, one way to do it could be to split up that script into three scripts and have three geektool applets on your screen. Each applet displaying a month. That way you can arrange them how you like.

So for the previous month you could use this line of code..
Code:
#!/bin/zsh

month=`date +%m`
year=`date +%Y`

lastMonth=$(($month-1))

if [[ $month -eq 1 ]]
then
        lastMonth=12
        cal $lastMonth $(($year-1)) | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
else
        cal $lastMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
fi

for current month..
Code:
#!/bin/zsh

cal | awk -v cday=`date "+%d"` '{ fill=(int(cday)>9?"":" "); print " "$0; getline; print " "$0; while (getline != 0) {a=" "$0" "; sub(" "fill int(cday)" ",fill "(" int(cday)")", a); print a }}'

and for next month..
Code:
#!/bin/zsh

month=`date +%m`
year=`date +%Y`

nextMonth=$(($month+1))

if [[ $month -eq 12 ]]
then
        nextMonth=1
        cal $nextMonth $(($year+1)) | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
else
        cal $nextMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
fi
 
Anyone know why geektool causes Kernal Panics on my mac?

Do you have any comprehensive scripts running non stop that may be overlapping? If you say have a script running that takes a minute to run but are refreshing it every second, that could end up running you into problems, not sure. Your best bet would be to check your panic.log and system logs in Console and see what was happening at the time of the kernel panic.
 
Do you have any comprehensive scripts running non stop that may be overlapping? If you say have a script running that takes a minute to run but are refreshing it every second, that could end up running you into problems, not sure. Your best bet would be to check your panic.log and system logs in Console and see what was happening at the time of the kernel panic.

Never thought of that. I had all my scripts refreshing at the same time. :p
 
Never thought of that. I had all my scripts refreshing at the same time. :p

Yeah that can be a problem, I have some of my scripts such as weather and sunrise only run every hour or so. Current IP address only runs on system wake, logs and system info such as ram and battery info refreshes every 5 seconds. And even at 4 seconds, sometimes I've found via my system logs that the currently running process list overlaps at times throwing off an error in the logs.
 
Yeah that can be a problem, I have some of my scripts such as weather and sunrise only run every hour or so. Current IP address only runs on system wake, logs and system info such as ram and battery info refreshes every 5 seconds. And even at 4 seconds, sometimes I've found via my system logs that the currently running process list overlaps at times throwing off an error in the logs.

I had the date, month and time all set to refresh every 20,000 seconds just because i figured it didn't matter. This time around I changed them to different numbers so they didn't over lap. Thanks for the tip!
 
So I've been at it with GeekTool the past few days and I have my setup almost to my liking.

Here is my current setup desktop:

Screenshot2010-10-06at45242PM.jpg


Regarding the Memory/RAM, is it possible to make it a percent (no decimal places)?... Similar to my Hard Drive one. My MB has 4GB RAM btw.

This is my current RAM script:
Code:
top -l 1 | awk '/PhysMem/ {print "Memory: """ $8 "B"}' ;

Next question is about the Battery percentage. Any way to just round this off so there is no decimal places?

Here's the current script being used for the battery:
Code:
ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf ("%.2f%%", $10/$5 * 100)}'

Lastly, I'm looking for a CPU usage script that just displays the current percentage being used (not individual system, user, idle). Any ideas?

I know, it's a lot, but any help would be uber appreciated!!! 
 
Next question is about the Battery percentage. Any way to just round this off so there is no decimal places?

Here's the current script being used for the battery:
Code:
ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf ("%.2f%%", $10/$5 * 100)}'
the number before the f in the printf section is the number of decimals. erase the 2 and you'll have what you want.

and what is the code that you use for the HD?

edit: i dont know how to do it for the RAM, and i dont know if its possible... to see what you can put in the shell, go on terminal and type top
you'll see all you can put. (you can change whats between the two / and put for example CPU usage or an application. then, you change the number after the $ to change the parameter.
 
the number before the f in the printf section is the number of decimals. erase the 2 and you'll have what you want.

and what is the code that you use for the HD?

edit: i dont know how to do it for the RAM, and i dont know if its possible... to see what you can put in the shell, go on terminal and type top
you'll see all you can put. (you can change whats between the two / and put for example CPU usage or an application. then, you change the number after the $ to change the parameter.

Thanks for the tip on the battery. I'm not quite sure where I found the HDD script... somewhere on the internets. The script originally outputted the amount free, used, and a percent so I just took out the first two.
 
Geektool script and proxy server

Hi,

I successfully use the following weather-related scrip which I found on this thread:

curl --silent "http://xml.weather.yahoo.com/forecastrss?p=USUT0225&u=f" | grep -e "Current Conditions" -A 1 | tail -n 1 | sed -e 's/<BR \/>//' && echo && curl --silent "http://xml.weather.yahoo.com/forecastrss?p=USUT0225&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\:\ \(.*\)/\?H\: \1\ L\:\ \2/" | sed "s/\?\(.*\)/\\1/"

However, it doesn't work when I'm at work, where I have to specify a proxy server in my web browser: http://XXXX/proxya.pac

(I presume this is why it doesn't work there.)

Is there a way to solve this problem?

Thanks.

howardm
 
Guys, a really n00b question: how to make the am/pm letters appear in capitals?
The other one is how to make a text shadow? The "shadow" option is greyed out.

Cheers, Dan.
 
Guys, a really n00b question: how to make the am/pm letters appear in capitals?
The other one is how to make a text shadow? The "shadow" option is greyed out.

Cheers, Dan.

"click here to set font & color...", right on top of the background color. here you can change everything you want. the capitals letter would be in the typeface section of your font, and the shadow option is on top (where there's a T). this puts a shadow to all the letters. to put a shadow on a box, you need to put a background color at 100% opacity.
 
I'm wonderingif it is possible to have an iTunes seekbar geektool script? I already have Artist, Ablum and Trackname. I guess I really just want to get as close to the iTunes mini player as possible through a series of geektool scripts

Oh and btw here's my desktop.
 
Here is my current setup. I still think it needs a lot of work. My current problem is the calender... the current date is blank. I want it to show up and be black. I can not fugure out how to do this. I have tried to put a black cal with all the dates under the white one... but the prob is that the cal is transparent.

any ideas?
 

Attachments

  • Screen Shot  10.10.10.jpg
    Screen Shot 10.10.10.jpg
    705.6 KB · Views: 338
Here is my current setup. I still think it needs a lot of work. My current problem is the calender... the current date is blank. I want it to show up and be black. I can not fugure out how to do this. I have tried to put a black cal with all the dates under the white one... but the prob is that the cal is transparent.

any ideas?

You have to modify the current date's color manually inside the script itself.

I don't know which version of what calander code you are using, but here's an example that does what you want...

Code:
cal_head=`cal | head -1`; cal_tail=`cal | tail -7`; today=`date "+%e"`; echo "$cal_head"; echo "${cal_tail/${today}/\033[0;30m${today}\033[0m}";
 
Regarding the Memory/RAM, is it possible to make it a percent (no decimal places)?... Similar to my Hard Drive one. My MB has 4GB RAM btw.
In regards to the RAM percentage that you are interested in I wrote the following. It's a tad convoluted, but it is one way at least. This will show the percent of RAM used...

Code:
totalram=`top -l 1 | awk '/PhysMem/ {print $8 $10}' | sed "s/M/ /g" | awk '{sum+= $1 + $2 } END{print sum}' ` ;  usedram=`top -l 1 | awk '/PhysMem/ {print $8}' | sed "s/M/ /g"` ; rounded=`echo $totalram $usedram | awk '{ print $2 * 100 /$1}' | awk '{print int($1+0.5)}'` ; echo "Memory: ""$rounded""%"

To note the above code only compares total vs used ram and gives a percentage. It doesn't factor in inactive ram.
 
You have to modify the current date's color manually inside the script itself.

I don't know which version of what calander code you are using, but here's an example that does what you want...

Code:
cal_head=`cal | head -1`; cal_tail=`cal | tail -7`; today=`date "+%e"`; echo "$cal_head"; echo "${cal_tail/${today}/\033[0;30m${today}\033[0m}";

THANK YOU SO MUCH!
 
You have to modify the current date's color manually inside the script itself.

I don't know which version of what calander code you are using, but here's an example that does what you want...

Code:
cal_head=`cal | head -1`; cal_tail=`cal | tail -7`; today=`date "+%e"`; echo "$cal_head"; echo "${cal_tail/${today}/\033[0;30m${today}\033[0m}";

About 50 or 60 pages or so back, someone posted a script that creates a calendar with every date blank except for the current date. The purpose being that you use a different font color and then overlay it on top another month to "highlight" today's date.

Does anyone have that? I used to but I deleted it accidentally, and can't come up with good kewords to search for it.
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.