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.
PHP:
uptime | awk '{sub(/[0-9]|user\,|users\,|load/, "", $6); sub(/mins,|min,/, "min", $6); sub(/user\,|users\,/, "", $5); sub(",", "min", $5); sub(":", "h ", $5); sub(/[0-9]/, "", $4); sub(/day,/, " day ", $4); sub(/days,/, " days ", $4); sub(/mins,|min,/, "min", $4); sub("hrs,", "h", $4); sub(":", "h ", $3); sub(",", "min", $3); print "Uptime: " $3$4$5$6}';
top -l 1 | awk '/PhysMem/ {print "RAM - Used: " $8 ", Free: " $10}'
ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("Battery: %.2f%%", $10/$5 * 100)}';

PHP:
df -h | grep disk0s2 | awk '{print "HD: ", $3, "of", $2, "-", $4, "available"}' | sed 's/Gi/Gb/g'
PHP:
#! /bin/bash
myvar1=`system_profiler SPAirPortDataType | grep -e "Current Wireless Network:" | awk '{print $4}'`
myvar2=`system_profiler SPAirPortDataType | grep -e "Wireless Channel:" | awk '{print $3}'`

echo "External:" `curl -s http://checkip.dyndns.org/ | awk '{print $6}' | cut -f 1 -d "<"`
myen0=`ifconfig en0 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`

if [ "$myen0" != "" ]
then
echo "Ethernet: $myen0"
else
echo "Ethernet: INACTIVE"
fi

myen1=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`

if [ "myen1" != "" ]
then
 echo "AirPort: $myen1"
else
 echo "Airport: Inactive"
fi

Can someone please help me add colours to my script and combine the last two scripts to the first first. Thank you so much

Uptime - Orange
Ram - Red
Battery - Green
Hard Drive - purple
Network - white
 
Quick question, loving playing around with Geektool, but wondering if there is a way to keep everything on 'one' desktop, I switch my laptop out at home and at work with two separate monitors and leave my laptop lid open but the monitors are on separate sides, I can of course put the monitors in different places, but everytime if I move the monitor that's not where geek tool is loaded on, it just stays where I put them. (which is a good thing I guess) except when I would like it to stay with the main laptop screen all the time.

These two threads seem to make this sound possible:
https://forums.macrumors.com/posts/11458874/
https://forums.macrumors.com/posts/11459158/

I don't have a dual monitor setup, so I'm essentially worthless in helping. I also think you need Geektool 3 and I have no idea if this will work on 10.7.
 
Can someone please help me add colours to my script and combine the last two scripts to the first first. Thank you so much

Uptime - Orange
Ram - Red
Battery - Green
Hard Drive - purple
Network - white

Here is a combined script, you'll have to save it and have geektool run the file. Since it's a shell script, you have to make it executable. Open up the terminal app (Terminal.app) and browse to the directory where you saved the file. If you don't know simple Unix commands, now is the time to read up, a simple Bash tutorial will have you changing directories in now time.

Code:
#!/bin/bash

# COLORED UPTIME SCRIPT

# SET OUR COLOR ESCAPE AND RESET
RESET="\033[0m"
ORANGE="\033[33m"
PURPLE="\033[34m"
GREEN="\033[32m"
RED="\033[31m"

# ==================================
# DATA SECTION

# GET OUR UPTIME
MYUPTIME=`uptime | awk '{sub(/[0-9]|user\,|users\,|load/, "", $6); sub(/mins,|min,/, "min", $6); sub(/user\,|users\,/, "", $5); sub(",", "min", $5); sub(":", "h ", $5); sub(/[0-9]/, "", $4); sub(/day,/, " day ", $4); sub(/days,/, " days ", $4); sub(/mins,|min,/, "min", $4); sub("hrs,", "h", $4); sub(":", "h ", $3); sub(",", "min", $3); print "Uptime: " $3$4$5$6}';`

# GET OUR DISK USAGE
MYDISK=`df -h | grep disk0s2 | awk '{print "HD: ", $3, "of", $2, "-", $4, "available"}' | sed 's/Gi/Gb/g'`

# GET OUR BATTERY
MYBATT=`ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("Battery: %.2f%%", $10/$5 * 100)}'`

# GET OUR RAM USAGE
MYRAM=`top -l 1 | awk '/PhysMem/ {print "RAM - Used: " $8 ", Free: " $10}'`

# ==================================
# DATA PRINT SECTION

# PRINT OUT THE COLORED UPTIME TEXT
echo -e $ORANGE$MYUPTIME$RESET

# PRINT OUT THE COLORED RAM TEXT
echo -e $RED$MYRAM$RESET

# PRINT OUT THE COLORED BATTERY TEXT
echo -e $GREEN$MYBATT$RESET

# PRINT OUT THE COLORED RAM TEXT
echo -e $PURPLE$MYDISK$RESET

# IP/ETHERNET SECTION

# IP ADDRESS/ETHERNET CONNECTION
myvar1=`system_profiler SPAirPortDataType | grep -e "Current Wireless Network:" | awk '{print $4}'`
myvar2=`system_profiler SPAirPortDataType | grep -e "Wireless Channel:" | awk '{print $3}'`

echo "External:" `curl -s http://checkip.dyndns.org/ | awk '{print $6}' | cut -f 1 -d "<"`
myen0=`ifconfig en0 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`

if [ "$myen0" != "" ]; then
    echo "Ethernet: $myen0"
else
    echo "Ethernet: INACTIVE"
fi

myen1=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`

if [ "myen1" != "" ]; then
    echo "AirPort: $myen1"
else
    echo "Airport: Inactive"
fi

To make the file executable, run the command (filename is whatever you named the script). Make sure you're in the directory with the file when you do this.
Code:
chmod +x filename.sh

The battery code didn't work for me, so I'm not sure if you'll have issues on your end. When I ran the script in the terminal, I was getting a divide by zero error.

Make sure the geeklet is set to use color escapes otherwise the color won't display.
 
Thanks so much Taco! I finally got it :)

Edit: Must have done something wrong because it freezes every now and then. What I did was copy the script in the file and paste them on the command shell on geektool. Is that what it freezes? What do I have to do?

Edit 2: I also tried command in geektool but doesn't work. "sh /Users/name/geektool/file.sh"
 
Last edited:
@xtacocorex
Thanks for the reply.

I modified a battery script.
original script
My script

But the charging time calculator doesn't work good. I try repair this, but no good.
Orig: mins=`echo "(${status[0]}-${status[3]})*60/${status[4]}"|bc`
My: mins=`echo "(${status[0]}-${status[3]})*120/${status[4]}"|bc`

Any idea?

My script use the battery icons. If the battery level changes, then the battery icon will change.

Screen_Shot_2011-09-11_at_11.46.50.png

Screen_Shot_2011-09-11_at_13.04.45.png


My English knowledge isn't the best. I hope you understand me.

Edit: The original charger script is correct. The apple battery calculator and the script show same time. But the iSata menus show a different time.
 
Last edited:
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.

Wow, cool... I forgot about that one. Ok I tried to do it with AppleScript Editor and it won't let me save the file as .py, and gives me the option for .scpt or .py.scpt. Regardless of which option I choose I get this error:

applescripterror.png


So then I thought I would paste the code into TextEdit, save it and then change the file extension to .py and then add the line for the Geeklet shell. I did that and nothing shows up at all.

Odd that I found this post, because I totally missed it the other day and I was just now searching this thread for "python," and your website too, to try and figure out what it was because I was trying to do a Stock Ticker script to show a couple of symbols (MSI, AAPL) to start.

Thank you for all your help and I apologize for being such a scripting dummy as I need it laid out Barney style for me! :D
 
Wow, cool... I forgot about that one. Ok I tried to do it with AppleScript Editor and it won't let me save the file as .py, and gives me the option for .scpt or .py.scpt. Regardless of which option I choose I get this error:

So then I thought I would paste the code into TextEdit, save it and then change the file extension to .py and then add the line for the Geeklet shell. I did that and nothing shows up at all.

Odd that I found this post, because I totally missed it the other day and I was just now searching this thread for "python," and your website too, to try and figure out what it was because I was trying to do a Stock Ticker script to show a couple of symbols (MSI, AAPL) to start.

Thank you for all your help and I apologize for being such a scripting dummy as I need it laid out Barney style for me! :D

Python won't work in Applescript. :)

Did you setup the geeklet to be:
Code:
python /path/to/script/whateveryounamedthescript.py

The stock ticker is a nice script, but it is a little involved in the initial setup. Here is the link to the post about it, if you didn't find it: https://forums.macrumors.com/posts/12796750/
 
How do I run a shell script on geektool? I had tried a couple of methods but to no avail.
 
Python won't work in Applescript. :)

OK... so then what? :confused:

Did you setup the geeklet to be:
Code:
python /path/to/script/whateveryounamedthescript.py

Yes I did. In the properties for the shell under command:

Code:
python /Users/sandboxgeneral/Documents/macrumorsnews.py

I have the macrumorsnews.py (made in TextEdit) in the Documents folder.
 
Last edited:
iCalBuddy help?

Can anyone help me customise this script?

Code:
icalBuddy eventsToday -nrd -df "%a" -tf "%H:%M" -nc -eed -ps "| - |" -iep "datetime,title" eventsToday+2

I want to put a space between the two days events. so:

wed:
wed:

----------

Thurs:
Thurs:

Thanks, lewis.
 
Last edited:
How to set up this script?

I try this:
Code:
$ python fivedayforecastv3.py 
Traceback (most recent call last):
  File "fivedayforecastv3.py", line 427, in <module>
    forecastMain(sys.argv[1:])
  File "fivedayforecastv3.py", line 416, in forecastMain
    mywoeid = getWOEID(locdict['zipcode'])
  File "fivedayforecastv3.py", line 186, in getWOEID
    resp    = ast.literal_eval(reqresp.read())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 80, in literal_eval
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 63, in _convert
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 62, in <genexpr>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 63, in _convert
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 62, in <genexpr>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 79, in _convert
ValueError: malformed string
 
Anyone able to help with this? https://forums.macrumors.com/posts/13324138/

I've been trying to get the right reg expressions for the past 3 days but no luck yet :(

Here, I wrote this code which will give you the full URL of the image you are looking for.

Code:
curl --silent "http://weather.yahoo.com.au/local-conditions/nsw/sydney" | grep -m 1 '/styles/icons/yahoo7/large/' | cut -d\" -f6 | sed s#^#http://weather.yahoo.com.au#

If just the URL isn't what you were looking for let me know.
 
How to set up this script?

I try this:
Code:
$ python fivedayforecastv3.py 
Traceback (most recent call last):
  File "fivedayforecastv3.py", line 427, in <module>
    forecastMain(sys.argv[1:])
  File "fivedayforecastv3.py", line 416, in forecastMain
    mywoeid = getWOEID(locdict['zipcode'])
  File "fivedayforecastv3.py", line 186, in getWOEID
    resp    = ast.literal_eval(reqresp.read())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 80, in literal_eval
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 63, in _convert
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 62, in <genexpr>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 63, in _convert
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 62, in <genexpr>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 79, in _convert
ValueError: malformed string

You're missing a command line argument to tell the program what to display. The options are as follows:
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

Let me know what happens next, I just tried running my script and it threw out regular expression errors, so Yahoo might have changed the page format on me.

----------

OK... so then what? :confused:



Yes I did. In the properties for the shell under command:

Code:
python /Users/sandboxgeneral/Documents/macrumorsnews.py

I have the macrumorsnews.py (made in TextEdit) in the Documents folder.

Delete the file you copied the script from and download the one that I'm linking here. http://xtacocorex-geektool-scripts.googlecode.com/files/macrumorsnews.py

Try running the script in Terminal.app and see what the output is please.

In Terminal.app:
Code:
$ cd Documents
$ python ./macrumorsnews.py


----------

How do I run a shell script on geektool? I had tried a couple of methods but to no avail.

Scripts have to be made executable if you don't prefix the command with the interpreter.

You need to go into Terminal.app and change directories to the one with the script. You then need to run the chmod command on the file you want made executable.

Simple tutorial, the $ is the shell prompt in Terminal.app:
Code:
$ cd /path/to/scripts
$ chmod + x script.ext

/path/to/scripts is the path to where the scripts are, in your case (from helping you previously) it'll be /Users/<yourusernameisremovedtoprotectyouridentity/geektool

script.ext is the script name with ext being the appropriate file extension for the script you want to make executable.
 
Delete the file you copied the script from and download the one that I'm linking here. http://xtacocorex-geektool-scripts.googlecode.com/files/macrumorsnews.py

Try running the script in Terminal.app and see what the output is please.

In Terminal.app:
Code:
$ cd Documents
$ python ./macrumorsnews.py

After I deleted my file and as soon as I moved the file you provided to the Documents folder, the Geeklet (still running from yesterday) automatically showed the output. I didn't have to run it in Terminal.

Any idea what I did wrong or what the problem was?

Thank you! :)

EDIT: Here is my new current desktop after using and receiving assistance with GeekTool, Nocturne and CandyBar.
 

Attachments

  • Screen Shot 2011-09-14 at 10.08.28 PM.png
    Screen Shot 2011-09-14 at 10.08.28 PM.png
    298.1 KB · Views: 138
  • Screen capture 1.jpg
    Screen capture 1.jpg
    947.7 KB · Views: 234
Last edited:
After I deleted my file and as soon as I moved the file you provided to the Documents folder, the Geeklet (still running from yesterday) automatically showed the output. I didn't have to run it in Terminal.

Any idea what I did wrong or what the problem was?

Thank you! :)

EDIT: Here is my new current desktop after using and receiving assistance with GeekTool, Nocturne and CandyBar.

I think the problem was in how you copied the text. It sounded like you pasted the code into the Applescript editor and then copied what was in the Applescript editor into TextEdit. There must have been some other underlying change in that process.

At least it's working now. :) Desktop looks great too!
 
I think the problem was in how you copied the text. It sounded like you pasted the code into the Applescript editor and then copied what was in the Applescript editor into TextEdit. There must have been some other underlying change in that process.

At least it's working now. :) Desktop looks great too!

Yeah, that might have been what I did (copy from AppleScript Editor to TextEdit).

Now if I can get that ticker script working. I messed with it this morning before work and it wasn't showing anything. Does it only work (display) while the market is open? I'm not normally home when it's open.

I still need to find a good, and working iCal icon for CandyBar and I need to figure out how to unlock the Twitter icon so it can be changed.
 
Yeah, that might have been what I did (copy from AppleScript Editor to TextEdit).

Now if I can get that ticker script working. I messed with it this morning before work and it wasn't showing anything. Does it only work (display) while the market is open? I'm not normally home when it's open.

I still need to find a good, and working iCal icon for CandyBar and I need to figure out how to unlock the Twitter icon so it can be changed.

The ticker script will display all the time, the market data will only update while the markets are open though, so over the weekend, you'll be stuck seeing Fridays data at the market close.

I might not have been clear in the description of setting up that script. Throw up your tickerlist file, that might be one of the issues.

This is how I have my geeklet setup:
Code:
python ~/bin/geektool/tickerv4.py ~/bin/geektool/tickerlist.txt -c -f --upfgcolor=green --downfgcolor=red

To explain out my options:
Code:
-c -> colored output
-f -> color the foreground
-upfgcolor     -> specifies the color for the foreground (text) when the market value increases
-downfgcolor -> specifies the color for the foreground (text) when the market value decreases

Note that ~ is another way to specify /Users/username in the shell. I usually set the scripts up for people to have them put /Users/username because it's easier to not have to explain the ~.

This is one you might have to run in Terminal.app to get the error the script is giving.

To summarize the possible issues:
1. tickerlist.txt is not formatted properly
2. geeklet isn't set to display colored text (if using the colored option, not specifying the colored text option will output nothing in the geeklet)
3. paths are incorrect
4. corner case in the code that I haven't found on my end yet

-
For the twitter icon, can't you just right click on the app and select "Show Contents"? You should then be able to browse around the directory structure to the resource folder and there should be an icon in there that can be changed.
 
Ok. Thanks, it works. But I can't set up Celsius and kph (wind speed).

Code:
python fivedayforecastv3.py -w http://weather.yahoo.com/hungary/kecskem%C3%A9t/kecskem%C3%A9t-809168/ -d
Today:
 Scattered showers this morning, becoming mostly sunny during the afternoon hours. Warm. High 81F. Winds NNW at 5 to 10 mph. Chance of rain 30%.

Tonight:
 Mainly clear. Low 56F. Winds NNW at 5 to 10 mph.

Tomorrow:
 A mainly sunny sky. Warm. High around 80F. Winds light and variable.

Tomorrow Night:
 Clear. Low 59F. Winds light and variable.

Saturday:
 Plenty of sun. Highs in the mid 80s and lows in the low 50s.

Sunday:
 Plenty of sun. Highs in the low 90s and lows in the upper 50s.

Monday:
 Light rain. Highs in the mid 70s and lows in the low 50s.

I'd like five or six days forecast with only Hi Lo temps and mini icons. Like this
Screen_Shot_2011-09-15_at_5.19.16.png


Or this on website.
You know that?
I know the yahoo widgets but that no good.
 
The ticker script will display all the time, the market data will only update while the markets are open though, so over the weekend, you'll be stuck seeing Fridays data at the market close.

I might not have been clear in the description of setting up that script. Throw up your tickerlist file, that might be one of the issues.

I firgured it out after reading your explanation here. I neglected to add the full path on the second file in the Geeklet. What I had was:

Code:
python ~/bin/geektool/tickerv4.py tickerlist.txt

Leaving out: ~/bin/geektool/ part in the second half. When I put that part in, it all started working.

I left in the Indexes and took out the other symbols and added Motorola Solutions and Apple, for now anyway.

Again, thank you. :)

-
For the twitter icon, can't you just right click on the app and select "Show Contents"? You should then be able to browse around the directory structure to the resource folder and there should be an icon in there that can be changed.

I did try that a little. I was 3 hours into messing with CandyBar, searching tons of websites for icons I liked and so forth before I tried working on the Twitter icon. I was getting tired from all the searching around after getting home from work.

I browsed to the Twitter application and did the "Show Package Contents" and made sure I had permissions to edit it all. But when I look at the Twitter icon in CandyBar (attached image) it has a lock on it and when I drag a new icon overtop it doesn't take. I closed the app and tried it, logged out and tried it, but nothing.
 

Attachments

  • Twitter.png
    Twitter.png
    13.1 KB · Views: 2,770
  • Screen capture 1.jpg
    Screen capture 1.jpg
    1 MB · Views: 375
Ok. Thanks, it works. But I can't set up Celsius and kph (wind speed).

Code:
python fivedayforecastv3.py -w http://weather.yahoo.com/hungary/kecskem%C3%A9t/kecskem%C3%A9t-809168/ -d
Today:
 Scattered showers this morning, becoming mostly sunny during the afternoon hours. Warm. High 81F. Winds NNW at 5 to 10 mph. Chance of rain 30%.

Tonight:
 Mainly clear. Low 56F. Winds NNW at 5 to 10 mph.

Tomorrow:
 A mainly sunny sky. Warm. High around 80F. Winds light and variable.

Tomorrow Night:
 Clear. Low 59F. Winds light and variable.

Saturday:
 Plenty of sun. Highs in the mid 80s and lows in the low 50s.

Sunday:
 Plenty of sun. Highs in the low 90s and lows in the upper 50s.

Monday:
 Light rain. Highs in the mid 70s and lows in the low 50s.

I'd like five or six days forecast with only Hi Lo temps and mini icons. Like this
Image

Or this on website.
You know that?
I know the yahoo widgets but that no good.

Here is the url set for metric units: http://weather.yahoo.com/hungary/kecskemét/kecskemét-809168/?unit=c
That should work with the -w option.

As for getting the images, I haven't worked on that yet.
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.