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.
Hi All,

I just found this thread looking for a working stock ticker script. Well I came across post 751 and it worked great. But I did some tweaks to make it easy to reproduce and choose your stock symbol quickly with out editing the script. So I made two scripts one that is for when the stock is up.. and one for when it is down and you can overlay them. The way the script works if its for up it only shows if the stock is up... and vise verse. So you can set two different colors for up and down.

if you want more than one stock info to show, look at this post.
it's also only one script. ;)
 
if you want more than one stock info to show, look at this post.
it's also only one script. ;)

Yeah I saw that one too.. but I did not like the color's I just wanted the txt to change colors not the back ground.... and I am not that good at scripting to edit that one :p
 
Hi All,



If there is any questions about the script I posted or anything you see on my desktop don't hesitate to ask.

Could I get the code you are using for your uptime display? It looks like you've got the minute/hour/day vs. minutes/hours/days (singular vs. plural) figured out....mine doesn't. Thanks in advance.
 
UpTime

Could I get the code you are using for your uptime display? It looks like you've got the minute/hour/day vs. minutes/hours/days (singular vs. plural) figured out....mine doesn't. Thanks in advance.

Sure here it is:

Code:
#!/bin/bash
then=$(sysctl kern.boottime | awk '{print $5}' | sed "s/,//")
now=$(date +%s)
diff=$(($now-$then))

days=$(($diff/86400));
diff=$(($diff-($days*86400)))
hours=$(($diff/3600))
diff=$(($diff-($hours*3600)))
minutes=$(($diff/60))
seconds=$(($diff-($minutes*60)))

function format {
	if [ $1 == 1 ]; then
		echo $1 ' ' $2
	else
		echo $1 ' ' $2's'
	fi
}
echo 'Uptime: '`format $days "day"` `format $hours "hour"` `format $minutes "minute"` `format $seconds "second"`
 
Yeah I saw that one too.. but I did not like the color's I just wanted the txt to change colors not the back ground.... and I am not that good at scripting to edit that one :p
change this section in the .py file (it's around the end)
Code:
        # COLORS
        elif OUTPTYPE == "-c":
            for i in xrange(len(symlist)):
                if   float(clist[i]) < 0.00:
                    print '\033[31m',symlist[i].ljust(6), plist[i].rjust(10), clist[i].rjust(9), cplist[i].rjust(9)
                elif float(clist[i]) > 0.00:
                    print '\033[32m',symlist[i].ljust(6), plist[i].rjust(10), clist[i].rjust(9), cplist[i].rjust(9)
                elif float(clist[i]) == 0.00:
 
change this section in the .py file (it's around the end)
Code:
        # COLORS
        elif OUTPTYPE == "-c":
            for i in xrange(len(symlist)):
                if   float(clist[i]) < 0.00:
                    print '\033[31m',symlist[i].ljust(6), plist[i].rjust(10), clist[i].rjust(9), cplist[i].rjust(9)
                elif float(clist[i]) > 0.00:
                    print '\033[32m',symlist[i].ljust(6), plist[i].rjust(10), clist[i].rjust(9), cplist[i].rjust(9)
                elif float(clist[i]) == 0.00:

kewl I see what needs to be changed... I might play with that tonight...
 
How can I change this to start the week on monday?

I worked out a calendar that uses the cal command, but also includes the last two weeks of the previous month, and the first two weeks of the next month and combines them together seamlessly under one month heading. This gives it a square layout. I also used some coloring to help tell the months apart and show the progress of the current month and highlight the current day. I haven't tested it with many other months, so may need some tweaking, but for now looks good.

Edit [20100905]: Fixed a few things in the code that miss-colored items this month.
Edit [20101201]: Improved code to fix issues losing January when it was the next month.
Code:
MONTH=$(date +'%B %Y')
OFFSET=$(((21-${#MONTH})/2))
WEEK="Su Mo Tu We Th Fr Sa"
PREV=$(cal -mj $(date -v -1m "+%m %Y") | grep .. | tail -n2)
CURR=$(cal | tail -n6)
NEXT=$(cal -mj $(date -v +1m "+%m %Y") | grep .. | tail -n6 | head -n2)
LINE=$((($(date +%e)/7)+2))

for ((i=0; i<$OFFSET; i++ ))
do
	echo " \c"
done
echo "[4m"$MONTH"[0m"
echo $WEEK $PREV$CURR$NEXT | sed -e s'/$/ /g' -e s'/ /  /g' -e s'/\([^0-9][0-9][^0-9]\)/ \1/g' -e s'/  / /g' -e s"/\(.\{21\}\)/\1#/g" | tr -s '#' '\n' | sed -e s'/^/ /g' -e s'/Sa/Sa[37m/' -e '3,5 s/ 1 /[32m 1 /' -e '7,9 s/ 1 / [37m1 /' -e "$LINE,$(($LINE+2)) s/ $(date +%e | sed s'/ //') /$(date +%e | sed -e s'/ //' -e s'/\(.*\)/[43;30m \1 [0m/')/"
For entering escaped characters before the [0m bits, you hit control+q [release] esc. It's invisible so you won't get any feedback.



Hi, as an european I would like this cool calendar to start the week with Monday, not Sunday. How must the code be changed?

Thanks,
newbie from Norway
 

Attachments

  • Screen shot 2011-06-08 at 12.07.06 AM.jpg
    Screen shot 2011-06-08 at 12.07.06 AM.jpg
    68.3 KB · Views: 114
Last edited:
Yeah I saw that one too.. but I did not like the color's I just wanted the txt to change colors not the back ground.... and I am not that good at scripting to edit that one :p

What colors are you thinking? Adding that feature in to my Ticker script isn't too hard to do.

I am planning on updating the code here soon to remove the need to dump the stock webpage data to a temporary file. I can roll that feature in.
 
Hi all,

here in the office we connect to the internet through a proxy server, causing Geektool not being able to connect to the internet. Does anybody know how to get Geektool to connect to the internet through a proxy server?

Many thanks!!
Pete
 
What colors are you thinking? Adding that feature in to my Ticker script isn't too hard to do.

I am planning on updating the code here soon to remove the need to dump the stock webpage data to a temporary file. I can roll that feature in.

Oh I just want it to change the txt colors not the background.... red/green is fine.... I just like the txt to change colors. But that's just me... If you put that in there that would be great... or if you can make it an option between the two.... :cool:
 
Sure here it is:

Code:
#!/bin/bash
then=$(sysctl kern.boottime | awk '{print $5}' | sed "s/,//")
now=$(date +%s)
diff=$(($now-$then))

days=$(($diff/86400));
diff=$(($diff-($days*86400)))
hours=$(($diff/3600))
diff=$(($diff-($hours*3600)))
minutes=$(($diff/60))
seconds=$(($diff-($minutes*60)))

function format {
	if [ $1 == 1 ]; then
		echo $1 ' ' $2
	else
		echo $1 ' ' $2's'
	fi
}
echo 'Uptime: '`format $days "day"` `format $hours "hour"` `format $minutes "minute"` `format $seconds "second"`

Thanks....seems to be working like a charm
 
Oh I just want it to change the txt colors not the background.... red/green is fine.... I just like the txt to change colors. But that's just me... If you put that in there that would be great... or if you can make it an option between the two.... :cool:

That option will be added, and I think I'm going to add the capability to pick the colors you want.
 
Here's a look @ mine...

I'm currently running 11 separate scripts and only consumes 25.7MB. Let me know what you think!

~ :apple:
 

Attachments

  • ioioi_100611.jpg
    ioioi_100611.jpg
    250.9 KB · Views: 451
Introducing the New and Improved 5 Day Yahoo Weather Forecast! - Now with Automatic Location Grabber!

Spurred on by dotcommer, I implemented location grabbing into the 5 Day Weather forecast Yahoo script I wrote for the thread. After some beta testing by dotcommer and brenm666, I think it's good enough to throw out here to the rest of the geektool users here. It may not be perfect and some issues may arise, but for the three of us, it works well.

Program options:
Code:
Options:
  -h, --help            show this help message and exit
  -d, --detailed        Displays the detailed forecast
  -l, --highlow         Displays the Highs and Lows only forecast
  -u, --underline       Underlines the day headers
  -w WEBADDRESS, --webaddress=WEBADDRESS
                        Used for pre-specifying the Yahoo Weather URL instead
                        of automatically grabbing based on external IP

If you don't want the code to automatically grab your location, you can specify a url for the script to use. This feature is handy if the location the IP service gives is completely wrong, the page I'm using for the this script says they are usually correct most of the time (in the upper 90th percentile).

Here are some sample commands:
This command uses the url provided to output the detailed forecast for Las Vegas, Nevada:
Code:
python fivedayforecastv3.py -d -w http://weather.yahoo.com/united-states/nevada/las-vegas-2436704/
This command will print the detailed forecast for your location with the days underlined:
Code:
python fivedayforecastv3.py -d -u
This will print just the Highs/Lows for the week:
Code:
python fivedayforecastv3.py -l

The script can be found here: http://xtacocorex-geektool-scripts.googlecode.com/files/fivedayforecastv3.py

I've created a google code page to house my scripts in one central location, seemed easier than pasting code in here all the time.

I do have improvements for this planned, but I want to see what you all think about this before I move forward with the changes.
 
My desktop including AppleScript

Here's my desktop.
I used different scripts found in this thread and elsewhere on the net and compiled them into one AppleScript. In addition to the visual information, I get a spoken warning if my hard disk space falls below 10% on either disk.
Please excuse my amateurish way of parsing results from the curl command. I don't know how to do it any other way, but hey - it works.
I've not included the scripts for the date and weather since that info is already explained waaay too many times.
Please note that I use the app "Temperature Monitor" to get system temperatures.

The AppleScript is called using the osascript command.

Code:
--get IP addresses
set grepText to do shell script "system_profiler SPNetworkDataType|grep 'IPv4 Addresses'"
set text item delimiters to ":"
set grepText2 to text item 2 of grepText
set text item delimiters to " "
set intIP to text item 2 of grepText2
set extIP to do shell script "curl ifconfig.me"

--get disk space
set macDisk to do shell script "df | grep 0s2"
set macCap to ((100 - ((word 6 of macDisk) as integer)) as string) & "% available"
try
	set extDisk to do shell script "df | grep Ekstern"
	set extCap to ((100 - ((word 6 of extDisk) as integer)) as string) & "% available"
on error
	set extCap to "N/A"
end try

--get system temperatures
set allTemps to do shell script "/Applications/TemperatureMonitor.app/Contents/MacOS/tempmonitor -a -l"
set coreOne to word 4 of paragraph 1 of allTemps & "°C"
try
	set coreTwo to word 4 of paragraph 2 of allTemps & "°C"
on error
	set coreTwo to "Please wait"
end try
set GPUtemp to word 5 of paragraph 10 of allTemps & "°C"
set pwrTemp to word 6 of paragraph 18 of allTemps & "°C"

--get time since quit smoking
set startDate to date "onsdag den 20. oktober 2010 21.00.00"
set totalDays to round (getTimeSince(startDate, "d"))
set amountSaved to totalDays * 150

--get world population
set curlText to do shell script "curl http://www.census.gov/main/www/popclock.html|grep wclocknum"
set text item delimiters to ">"
get every text item of curlText
set curlText2 to text item 4 of curlText
set text item delimiters to "<"
set worldPop to text item 1 of curlText2

--get reddit karma
set theDump to do shell script "curl http://www.reddit.com/user/TinyLebowski/"
set text item delimiters to "karma"
set link1 to text item 2 of theDump
set comment1 to text item 4 of theDump
set text item delimiters to "<"
set link2 to text item 1 of link1
set comment2 to text item 1 of comment1
set text item delimiters to ">"
set linkKarma to text item 2 of link2
set commentKarma to text item 2 of comment2

--get my age
set ageList to getTimeSince(date "6/2/1974 12:00", "a")
set myAge to ((item 1 of ageList) as string) & " y, " & (item 2 of ageList as string) & " m, " & ((item 4 of ageList as string) & " d, " & (item 5 of ageList as string) & " h, " & (item 6 of ageList as string) & " m, " & (item 7 of ageList as string) & " s.")

--say warning if hard disk space falls below 10%
if macCap ≤ 10 then say "warning. running low on disk space"
if extCap ≤ 10 then say "warning. running low on disk space"

--format output
set output to "IP addresses:" & return & "External IP: " & tab & extIP & return & "Internal IP: " & tab & intIP & return & return & "Hard disk space:" & return & "Mac HD: " & tab & tab & macCap & return & "Ekstern HD: " & tab & extCap & return & return & "Computer temperatures" & return & "Core 1:" & tab & tab & coreOne & return & "Core 2:" & tab & tab & coreTwo & return & "GPU:" & tab & tab & tab & GPUtemp & return & "PWR supply:" & tab & pwrTemp & return & return & "Reddit karma:" & return & "Link:" & tab & tab & tab & linkKarma & return & "Comment:" & tab & tab & commentKarma & return & return & "Other information:" & return & "World pop.:" & tab & worldPop & return & "No smoking:" & tab & totalDays & " days, " & amountSaved & " Dkr saved." & return & "My age:" & tab & tab & myAge
return output

--getTimeSince Handler
on getTimeSince(theDate, theUnit) -- "y"=years, "m"=months, "w"=weeks, "d"=days, "h"=hours, "min"=minutes, "s"=seconds, "a"=all
	set timeSpan to (current date) - theDate
	if theUnit is "y" then
		set theOutput to timeSpan / 31536000
	else if theUnit is "m" then
		set theOutput to timeSpan / (31536000 / 12)
	else if theUnit is "w" then
		set theOutput to timeSpan / weeks
	else if theUnit is "d" then
		set theOutput to timeSpan / days
	else if theUnit is "h" then
		set theOutput to timeSpan / 3600
	else if theUnit is "min" then
		set theOutput to timeSpan / 60
	else if theUnit is "s" then
		set theOutput to timeSpan / 1
	else if theUnit is "a" then
		set yearSpan to timeSpan div 31536000
		set leftOver to timeSpan mod 31536000
		set monthSpan to leftOver div (31536000 / 12)
		set leftOver to leftOver mod (31536000 / 12)
		set weekSpan to leftOver div weeks
		set leftOver to leftOver mod weeks
		set daySpan to leftOver div days
		set leftOver to leftOver mod days
		set hourSpan to leftOver div 3600
		set leftOver to leftOver mod 3600
		set minuteSpan to leftOver div 60
		set leftOver to leftOver mod 60
		set secondSpan to leftOver div 1
		set theOutput to {yearSpan, monthSpan, weekSpan, daySpan, hourSpan, minuteSpan, secondSpan}
	end if
	return theOutput
end getTimeSince
 

Attachments

  • geektooldesktop.jpg
    geektooldesktop.jpg
    244.7 KB · Views: 419
I must admit you have the most eclectic list of Geektool scripts I've ever seen :)

Congratulations Monostratos! You win three Internets.
You, sir, are a gentleman and a scholar. ;)
I'm just geeking out - it's not like it's all important information. I learn something new from every site I scrape.
 
Please if anyone can help me I'm in dire search of the code for this graph in the top left:

http://i166.photobucket.com/albums/u100/lp_obsession2005/Picture1-3.png

It was give by user lpobsession on page 95, but he never posted the code for the CPU graph usage.

Anyone know how I can do this with Geektool?! Thanks!

ALSO EDIT --

Does anyone have the code to display temperatures in geek tool WITHOUT a third party application?

I wish this forum had a search function for individual threads :(
 
Last edited:
is there a script that will display internet usage? i have a monthly limit :( and it would be nice to have a quick glance at how close i am to it.
 
I'm trying change the "unread" mail script for the default Mail.app to Microsoft Outlook 2011 which is the program I use for my emails. My script for the Mail.app is below...

EditScript-1.png


Also, I have a script for my wireless keyboard and trackpad batt %. But I can't get to work. The script is below.

ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{print ("System Battery: ",$10/$5 * 100,"%")}';
osascript -e 'set a to do shell script "ioreg -w0 -l | grep Capacity"' -e "set h to word 5 of a" -e "set z to word 33 of a" -e "set b to word 38 of a" -e "set c to 1000 * b / z" -e "set d to round c" -e "set f to d / 10" -e "set q to 1000 * h / b" -e "set w to round q" -e "set j to w / 10" -e '"Battery Health: " & j &"%"' | iconv -f utf-8 -t ucs-2-internal;
ioreg -w0 -l | grep "Cycle Count" | awk 'BEGIN { FS = "=" } ; {print $8}' | awk 'BEGIN { FS = "}" } ; {print $1, "Cycles"}';

kbatt=`ioreg -c AppleBluetoothHIDKeyboard | grep BatteryPercent | tail -1|awk '{print $10}'`;

tbatt=`ioreg -c BNBTrackpadDevice | grep BatteryPercent | tail -1|awk '{print $10}'`;

mbatt=`ioreg -c BNBMouseDevice | grep Percent | tail -1| awk '{print $9}'`;

if [ ${#mbatt} -lt 1 ]; then
echo "Magic Mouse: disconnected"
else
echo "Magic Mouse Battery: $mbatt%"
fi
if [ ${#tbatt} -lt 1 ]; then
echo "Magic Trackpad: disconnected"
else
echo "Magic Trackpad Battery: $tbatt%"
fi
if [ ${#kbatt} -lt 1 ]; then
echo "Wireless Keyboard: disconnected"
else
echo "Wireless Keyboard Battery: $kbatt%"
fi



Any help would be much appreciated thanks.
 
Last edited:
I'm trying change the "unread" mail script for the default Mail.app to Microsoft Outlook 2011 which is the program I use for my emails. My script for the Mail.app is below...

Image

Also, I have a script for my wireless keyboard and trackpad batt %. But I can't get to work. The script is below.

ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{print ("System Battery: ",$10/$5 * 100,"%")}';
osascript -e 'set a to do shell script "ioreg -w0 -l | grep Capacity"' -e "set h to word 5 of a" -e "set z to word 33 of a" -e "set b to word 38 of a" -e "set c to 1000 * b / z" -e "set d to round c" -e "set f to d / 10" -e "set q to 1000 * h / b" -e "set w to round q" -e "set j to w / 10" -e '"Battery Health: " & j &"%"' | iconv -f utf-8 -t ucs-2-internal;
ioreg -w0 -l | grep "Cycle Count" | awk 'BEGIN { FS = "=" } ; {print $8}' | awk 'BEGIN { FS = "}" } ; {print $1, "Cycles"}';

kbatt=`ioreg -c AppleBluetoothHIDKeyboard | grep BatteryPercent | tail -1|awk '{print $10}'`;

tbatt=`ioreg -c BNBTrackpadDevice | grep BatteryPercent | tail -1|awk '{print $10}'`;

mbatt=`ioreg -c BNBMouseDevice | grep Percent | tail -1| awk '{print $9}'`;

if [ ${#mbatt} -lt 1 ]; then
echo "Magic Mouse: disconnected"
else
echo "Magic Mouse Battery: $mbatt%"
fi
if [ ${#tbatt} -lt 1 ]; then
echo "Magic Trackpad: disconnected"
else
echo "Magic Trackpad Battery: $tbatt%"
fi
if [ ${#kbatt} -lt 1 ]; then
echo "Wireless Keyboard: disconnected"
else
echo "Wireless Keyboard Battery: $kbatt%"
fi



Any help would be much appreciated thanks.

I don't think Outlook supports Applescript, so therefore mail script won't work.

I don't have any wireless mice or keyboard, so I can't troubleshoot those scripts for you.

As for your original post about the RSS feed, the feed isn't XML, it's HTML so it needs to be parsed differently.
 
What, a new Stock Ticker!? - now in Technicolor!

I've been wanting to re-vamp my Stock Ticker script for a while, mainly to reduce the dependency on a temporary directory to store the web pages for the stock symbols. The old code was sorta fast and dumb, but the new code is slower and better. Yeah, that seems backwards, but for this, speed isn't key as the geeklet shouldn't be set to refresh faster than 30 minutes (but that is still up to you, I use an hour timer for mine).

Aside from the bulk re-write, I added more color changing options due to MoonDog ripping on my script (that was a joke). :) Just know that certain color combinations won't display properly. I have no idea why, but trying to get blue text with a green background just won't work.

Program Options:
Code:
Arguments:
    TICKER_FILE: the file that contains the stock symbols and markets to display

Options:
  -h, --help            show this help message and exit
  -c, --colorize        colorizes the output
  -p UPCOLOR, --upcolor=UPCOLOR
                        defines the color for positive changing stocks - will
                        either color the text or the background depending on
                        the -f or -b option
  -n DOWNCOLOR, --downcolor=DOWNCOLOR
                        defines the color for negative changing stocks - will
                        either color the text or the background depending on
                        the -f or -b option
  -u UPTEXTCOLOR, --uptextcolor=UPTEXTCOLOR
                        defines the color for positive changing stocks - will
                        either color the text or the background depending on
                        the -f or -b option
  -d DOWNTEXTCOLOR, --downtextcolor=DOWNTEXTCOLOR
                        defines the color for negative changing stocks - will
                        either color the text or the background depending on
                        the -f or -b option
  -f, --foreground      colorize the text
  -b, --background      colorize the background

List of Approved Colors:
Code:
   BLACK       DGRAY
   RED         LRED
   GREEN       LGREEN
   BROWN       YELLOW
   BLUE        LBLUE
   MAGENTA     LMAGENTA
   CYAN        LCYAN
   GRAY        WHITE

Sample Tickerlist File:
Code:
m INDEXNASDAQ:.IXIC NASDAQ
m INDEXDJX:.DJI DOW
s NYSE UA
s NYSE EK
s NASDAQ NDSN
s NYSE MCD
s NYSE S
s NYSE BA
s NYSE PEP

Here are some sample commands:
This is the basic stock ticker with no colored output
Code:
python tickerv4.py tickerlist.txt

Here is a sample for coloring the foreground text
Code:
python tickerv4.py -c -f --upfgcolor=green --downfgcolor=red tickerlist.txt

Here is a sample for coloring the background
Code:
python tickerv4.py -c -b --upbgcolor=cyan --downbgcolor=magenta tickerlist.txt

Code can be downloaded here: http://xtacocorex-geektool-scripts.googlecode.com/files/tickerv4.py
 
Last edited:
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.