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.
Thought I'd post my uptime code. It parses the day/time and outputs in full spelling: Uptime: 1 day, 15 hours, 32 minutes

Code:
DAY=""; HRS=""; MIN=""
VAR=`uptime | sed 's/^.*up *//;s/, [0-9]* user.*$//'`
if [[ "$VAR" =~ "days" ]];then
DAY=`echo "$VAR" | awk '{print $1,$2}'`
VAR=`echo "$VAR" | sed 's/^.*day[s], //'`
fi
if [[ "$VAR" =~ ":" ]];then
HRS=`echo "$VAR" | sed 's/\([0-9]*\):.*/\1/'`
MIN=`echo "$VAR" | sed 's/^.*://;s/^0//'`
[[ $MIN = 1 ]] && MIN="$MIN minute" || MIN="$MIN minutes"
[[ $HRS = 1 ]] && HRS="$HRS hour, " || HRS="$HRS hours, "
VAR="$HRS$MIN"
else
VAR=`echo "$VAR" | sed 's/hr/hour/;s/hrs/hours/;s/min/minute/;s/mins/minutes/;s/secs/seconds/'`
fi
echo "Uptime: $DAY$VAR"

BTW, I use NerdTool now, as it uses far less memory and resources.

MAJ

Thanks....I've switched out my old uptime script for yours
 
Desktop

Had to get in on this, loving the GeekTools!!
 

Attachments

  • Screen shot 2011-05-09 at 11.53.00.jpg
    Screen shot 2011-05-09 at 11.53.00.jpg
    750.1 KB · Views: 779
Enhanced trash size script

The trash size command typically adds the contents of the .DS_Store file (keeps track of Finder window attributes) that can appear when you open the Trash window. This is generally about 16K in size. So, a 4K file in the Trash can make the Trash appear to be 20K in total.

Using du's -I option allows one to specify a Ignore mask:
Code:
du -I .DS_Store -sh ~/.Trash | awk '{print "Trash: " $1}'


Additionally, if you have multiple partitions/volumes, you probably realize that the typical trash size script is limited, as it only keeps track of files trashed from your boot volume. The following is a script I have created that adds the trash from any volume on your system.

Code:
TTL=0; UNT="K"
while read LINE; do
TSH=`sudo du -I .DS_Store -sk "/Volumes/$LINE/.Trashes" | awk '{print $1}'`
TTL=$((TTL + TSH ))
done<<<"`mount | grep hfs, | grep -v "on / " | sed 's/^.*\/Volumes\///;s/(hfs,.*$//'`"
TSH=`du -I .DS_Store -sk ~/.Trash | awk '{print $1}'`
TTL=$((TTL + TSH ))
if [[ $TTL -gt 999999 ]];then
VAR=$((TTL / 100000 )); UNT="G"
TTL="${VAR%[0-9]}.${VAR: -1}"
elif [[ $TTL -gt 999 ]];then
VAR=$((TTL / 100 )); UNT="M"
TTL="${VAR%[0-9]}.${VAR: -1}"
fi
echo "Trash: $TTL$UNT"

FYI:
I've elected to divide by powers of 10, rather than powers of 2 to provide a result that closer to reality.

kind regards,
MAJ

Another FYI:
Using the du command (disk usage) is not entirely accurate, as it records how much space the file/directory is taking up on the drive, not the actual file/directory size. But, this is much simpler than using the alternatives, like stat. Plus, the precise size of your Trash is of little significance to most of us, so this is good-enough-for-most-of-us(TM). :p
 
Hello everyone. I am a relatively new Mac user and I just started using GeekTool a few days ago. I am getting the hang of it but I have a few questions/topics that I am hoping can be answered/addressed here. I am running the latest version of Snow Leopard and am using GeekTool 3.

Is it normal for scripts such as RAM usage or CPU scripts to lag GeekTool?

I notice that when I restart or shut down and start up that some of my scripts may either slightly relocate themselves or they will all completely disappear until refreshing in GeekTool. Is this a regular occurrence?

Some codes (one, mainly) seem to lose or change its display when restarting or logging, such as "1 user" changing to simply "1" in a RAM/Uptime script? Would this be normal or simply a bad script?

I use a weather image from Yahoo and during the off chance that my scripts do appear when logging in, the image is the other thing missing. Would this be because it is an image script, or?

The scripts that I am currently using minus echo commands are System Info, Battery Level/Time Remaining, Date, Time and AM/PM, Calendar (regular), RAM/Uptime, and Processes. I like them all except for my RAM/Uptime and Processes scripts, does anyone have any good scripts to display things like - RAM, Uptime, Processes (percentages or otherwise), CPU, and Users? I would really appreciate that.

I am basically wondering if I am just using bad scripts (I will provide them to the best of my ability if necessary) or if GeekTool 3 has issues with Snow Leopard or what? It's kind of frustrating to try to be precise and have things like this happening.

If anyone could address some of these points or provide anything, it would be much appreciated. Thanks.

It should not be relocating, disappearing, etc. I believe all of the problems you are having can be easily resolved by checking the box next to the folder that entails your scripts. This way geektool will open upon turning on your computer. Hope this helps.
 
I have been looking over this thread for some time as well as links given on this thread by MacRumors users and I just wanted to say Thank You to all of you as it has helped me a lot to learn GeekTool. : )
 
Last edited:
only found geektool tonight, here is my first attempt, very simple but i like it.

keen to get into this and find some interesting geeklets

ps calendar isn't actually cut off, is about 8mm down from menu bar, not sure why it got cut
 

Attachments

  • Screen shot 2011-05-16 at 10.42.jpg
    Screen shot 2011-05-16 at 10.42.jpg
    114.3 KB · Views: 270
Does anyone know the geektool script that i need to acquire a dock similar to this image? http://img.photobucket.com/albums/v412/wilk0076/030610.png
I've looked for a while and can't find it anywhere :/

You can put a blank file geeklet exactly where you want the "dock" to appear, and set its color and transparency as you like. Then turn off the dock's actual background, and voilá!

I've shamelessly used that trick to make my mounted volumes visible when I've got a busy desktop picture.
 
I have a small problem with the time script. No matter what time script I use, the AM/PM never shows as capitalized even thought the scripts I copied and pasted from all showed that they're supposed to be. Does anyone know how I can change this? The font I'm using is Helvetica Neue, if that makes a difference.

Here's a picture of it.
2z82b1g.png
 
Okay so I've been thinking, I want to move on to a horizontal calendar. That set me back to my old problem, which was "how the hell am I supposed to know what day it'll fall on just by looking at the line?"

Then it hit me ( and I'd love to see more practical suggestions ) that I could just pick days like monday and friday and assign them, say, colors. That way, every monday of the month would show as a yellow number on the horizontal calendar.

I have just one problem. I'm an utter, walking and babbling scripting failure. Can anyone lend me a hand o/?
 
I have a small problem with the time script. No matter what time script I use, the AM/PM never shows as capitalized even thought the scripts I copied and pasted from all showed that they're supposed to be. Does anyone know how I can change this? The font I'm using is Helvetica Neue, if that makes a difference.

Here's a picture of it.
Image

whats the script youre using?
if you see the letter a, try using an "A" instead of the "a". should work.

Okay so I've been thinking, I want to move on to a horizontal calendar. That set me back to my old problem, which was "how the hell am I supposed to know what day it'll fall on just by looking at the line?"

Then it hit me ( and I'd love to see more practical suggestions ) that I could just pick days like monday and friday and assign them, say, colors. That way, every monday of the month would show as a yellow number on the horizontal calendar.

I have just one problem. I'm an utter, walking and babbling scripting failure. Can anyone lend me a hand o/?

no idea how to do what youre talking about. (and maybe a bit too colorful for me... :D)
but this is what im using and it works quite well.

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)
 
whats the script youre using?
if you see the letter a, try using an "A" instead of the "a". should work.

I'm using date "+%l:%M %p"

Haven't seen a script with "a", or was that just an example? I tried using "P" instead of "p" but that just screwed up the am/pm part.
 
Weather problems.

Hello all. I pulled this piece of code from a geeklets site, but the coder has not been responsive with questions. Can anyone help me figure out this bash script? It fetches a 5 day forecast with descriptions from Yahoo and displays it one line/day.

Code:
curl --silent -o /tmp/weather.html http://weather.yahoo.com/united-states/oregon/portland-23424682/; curl --silent -o /tmp/weather.png $(grep "div\ class=\"forecast-icon\"\ style=\"background:url" /tmp/weather.html| awk -F"'" '{ printf $2 }');for NUM in $(grep -n "<li><strong>.*\n" /tmp/weather.html|cut -d":" -f1); do TARGET=$((NUM+1)) ; sed -n "$NUM"p /tmp/weather.html|sed 's|<li><strong>||g'|sed 's|</strong>||g'| sed 's/^[\t]*//'; sed -n "$TARGET"p /tmp/weather.html ; done

The code was then later updated by another user who also put in decent formatting:

Code:
curl --silent -o /tmp/weather.html http://weather.yahoo.com/united-states/nevada/las-vegas-2436704/; 
curl --silent -o /tmp/weather.png $(grep "div class="forecast-icon" style="background:url" /tmp/weather.html| awk -F"'" '{ printf $2 }');
LINE=$(grep -n ".*n" /tmp/weather.html|cut -d":" -f1);
FIRST=1
for NUM in $LINE; 
do TARGET=$((NUM+1)) ;
	if [ $FIRST -eq 1 ]; then
		sed -n "$NUM"p /tmp/weather.html | sed 's|Detailed Local ForecastHow to Read This||g' | sed 's|||g' | sed 's/^[tnn]*//';	
		FIRST=$((FIRST+1));
	else
		sed -n "$NUM"p /tmp/weather.html | sed 's|||g' | sed 's|||g' | sed 's/^[t]*//';
	fi
	sed -n "$TARGET"p /tmp/weather.html ;
done

So here's the problem. The first script I posted, works, but has a bunch of html tags that come with the output. The second, well, just flat out doesn't work, but was supposed to be an update that removes said html tags.

Can ANYone out there help me fix this script up? So far as I can tell, this is the only script i've come across that provides more than a 2-day forecast plus details of each day. I'd really like to get this working so there is at least one version out there on the net for people. Bonus would be to incorporate an earlier script from this thread that looked up your IP and fetched the appropriate zip from yahoo based on the IP.


So. Anyone out there willing to shed some light on this?

I appreciate any effort anyone puts towards this.
 
I have a problem. I have a .glet file but everytime i double click it it asks for a program to open with. Does anyone know how to get it to work?

Thanks
 
whats the script youre using?

no idea how to do what youre talking about. (and maybe a bit too colorful for me... :D)
but this is what im using and it works quite well.


Ohhh, sweet! Yea it would definetly be too colorful for me too, I'm more of a white on dark desktop kind of guy, but I hadn't considered the angle you're using there! At a later point, the day nr distances itself to the right from the day itself, but I can definetly live with that!

I just wonder 2 things.

1) What's the purpose of that black separator? When I pasted your ( blessed ) script, the black square just stayed all the way >.

2) Is there anything I could add to that script to make the current day/date have a bold font?



In any case this is sweet, thanks Bren!

Edit: From what I read in your script, it was supposed to keep the right separator within range of the current date, right? Somehow that's just not happening here. Furthermore, it doesn't display what month it is, hm. Is it just me?
 
Last edited:
I'm using date "+%l:%M %p"

Haven't seen a script with "a", or was that just an example? I tried using "P" instead of "p" but that just screwed up the am/pm part.

this one pissed me off a little but i finally got it!
just check off the "set locale environment" option in the bottom.
voila! :cool:

I have a problem. I have a .glet file but everytime i double click it it asks for a program to open with. Does anyone know how to get it to work?

Thanks

when I do it, it opens it with geektool by default. try reinstalling geektool?

Ohhh, sweet! Yea it would definetly be too colorful for me too, I'm more of a white on dark desktop kind of guy, but I hadn't considered the angle you're using there! At a later point, the day nr distances itself to the right from the day itself, but I can definetly live with that!

I just wonder 2 things.

1) What's the purpose of that black separator? When I pasted your ( blessed ) script, the black square just stayed all the way >.

2) Is there anything I could add to that script to make the current day/date have a bold font?



In any case this is sweet, thanks Bren!

Edit: From what I read in your script, it was supposed to keep the right separator within range of the current date, right? Somehow that's just not happening here. Furthermore, it doesn't display what month it is, hm. Is it just me?

use a monospaced font. should help you see things clearly... ;)
its gonna look like that:
 

Attachments

  • Screen shot 2011-05-18 at 12.57.07 PM.png
    Screen shot 2011-05-18 at 12.57.07 PM.png
    42.5 KB · Views: 202
use a monospaced font. should help you see things clearly... ;)
its gonna look like that:


You are divine

ps: Is the minimum refresh rate 1s on GT? I'm trying to make a small animated icon next to my wi fi script, I can't seem to make gifs work on geektools so I'm thinking I'll just set a 0.2 refresh rate in a folder with slightly different pictures of the icon so that it looks animated. Or maybe I'm just stupid and there's a simple way to make animated icons I don't know about? :p
 
Last edited:
this one pissed me off a little but i finally got it!
just check off the "set locale environment" option in the bottom.
voila! :cool:

Omg thank you! I thought I'd never resolve this.
 

Attachments

  • Screen shot 2011-05-18 at 1.34.37 PM.png
    Screen shot 2011-05-18 at 1.34.37 PM.png
    160.6 KB · Views: 156
Still looking for a solution to this. Really, all I need is the first code mentioned to strip out the html tags it includes. Its so close to working perfectly... Would really like someone to take a look and see whats wrong.



Hello all. I pulled this piece of code from a geeklets site, but the coder has not been responsive with questions. Can anyone help me figure out this bash script? It fetches a 5 day forecast with descriptions from Yahoo and displays it one line/day.

Code:
curl --silent -o /tmp/weather.html http://weather.yahoo.com/united-states/oregon/portland-23424682/; curl --silent -o /tmp/weather.png $(grep "div\ class=\"forecast-icon\"\ style=\"background:url" /tmp/weather.html| awk -F"'" '{ printf $2 }');for NUM in $(grep -n "<li><strong>.*\n" /tmp/weather.html|cut -d":" -f1); do TARGET=$((NUM+1)) ; sed -n "$NUM"p /tmp/weather.html|sed 's|<li><strong>||g'|sed 's|</strong>||g'| sed 's/^[\t]*//'; sed -n "$TARGET"p /tmp/weather.html ; done

The code was then later updated by another user who also put in decent formatting:

Code:
curl --silent -o /tmp/weather.html http://weather.yahoo.com/united-states/nevada/las-vegas-2436704/; 
curl --silent -o /tmp/weather.png $(grep "div class="forecast-icon" style="background:url" /tmp/weather.html| awk -F"'" '{ printf $2 }');
LINE=$(grep -n ".*n" /tmp/weather.html|cut -d":" -f1);
FIRST=1
for NUM in $LINE; 
do TARGET=$((NUM+1)) ;
	if [ $FIRST -eq 1 ]; then
		sed -n "$NUM"p /tmp/weather.html | sed 's|Detailed Local ForecastHow to Read This||g' | sed 's|||g' | sed 's/^[tnn]*//';	
		FIRST=$((FIRST+1));
	else
		sed -n "$NUM"p /tmp/weather.html | sed 's|||g' | sed 's|||g' | sed 's/^[t]*//';
	fi
	sed -n "$TARGET"p /tmp/weather.html ;
done

So here's the problem. The first script I posted, works, but has a bunch of html tags that come with the output. The second, well, just flat out doesn't work, but was supposed to be an update that removes said html tags.

Can ANYone out there help me fix this script up? So far as I can tell, this is the only script i've come across that provides more than a 2-day forecast plus details of each day. I'd really like to get this working so there is at least one version out there on the net for people. Bonus would be to incorporate an earlier script from this thread that looked up your IP and fetched the appropriate zip from yahoo based on the IP.


So. Anyone out there willing to shed some light on this?

I appreciate any effort anyone puts towards this.
 
Still looking for a solution to this. Really, all I need is the first code mentioned to strip out the html tags it includes. Its so close to working perfectly... Would really like someone to take a look and see whats wrong.

Haha, I'm looking for the exact same fix... Does anybody else know of any scripts that can produce multi-day forecasts neatly?

That's really all I'm lookin for.
 
Hey everybody. This is my first post, but I have been tinkering with geektool for some time. Below is my latest desktop. It tries to combine every cool shell command and script I have found scouring the nets.
Among the notables:
-iTunes song progress meter (my favorite)
-yweather as featured on lifehacker (finally got it to work!)
-cpu temp and fan speed
-new mail
-rss feed
-next 5 iTunes songs in itunes DJ (I modified somebody's applescript to make this work for the current version of itunes)
-volume meter
-icalbuddy for calendar events and todos
-wallpaper from kitsunenoir.com

I'm still playing around with the layout, and might even eliminate some of the scripts, as it can get a little busy when you have limited screen real estate as I do. Please feel free to ask me anything.

Thom

PS: Has anybody gotten twitterbuddy to work? I have no trouble installing it, but for some reason I am unable to sign in....(maybe something having to do with twitter?)

Flickr link: http://www.flickr.com/photos/16971666@N08/3592055147/in/pool-lifehacker-desktop-showandtell

Where can I get the rss feed and mail scripts?
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.