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 is a shell script for printing the battery percent of a bluetooth keyboard.


ioreg -l | grep -i batterypercent | awk '{ print substr( $0, length($0) - 1, length($0) ) }'

Output in terminal (for me): 78

If I look in System Preferences it says my battery is 78%. So there you go.

Interestingly enough when I put the command in geektool I get the following:

}}
78

I guess I will have to mess around with sed a little more. I have only tested this with one bluetooth device connected as I only have a bluetooth keyboard. The output will probably be wacky if there is more than one Apple BT device connected.

Its been a while, but if anyone is interested this is

mbatt=`ioreg -l | grep -i batterypercent | tail -1 | awk '{ print substr( $0, length($0)-1 , length($0) ) }'`
echo "Keyboard Battery: $mbatt%"
 
I was hoping that someone could help me out. I get a DailyZen update everyday. Sometimes it's long, sometimes short. I was wondering if there's a way to have the background fill in slightly to make the text easier to read. The challenge would be to have it stretch or shrink according to the amount of text in the box. As it is right now I simply have an over-sized static box to allows for any amount of text, but with a bg it would look like kaka being as big as it is. Is this possible?

Thanks for any help.

I'm still doing a lot of tweaking, but here's my DT for now.


Would you mind sharing your code for the weather and time? What fonts did you use? Also how are you creating those launchers? Also how did you get the widget for itunes? Thanks for any help. Your setup is extremely nice.
 
Yeah, I definitely don't have that button:

You definitely do... (it's hiding from you).

The font window by default is sized too small for the other options to fit, so they are completely hidden. Drag the lower right corner of the window to make it larger — the drop shadow option should then be visible. I ran into the same issue when I finally realized why those options weren't appearing.

;)
 

Attachments

  • font_options.png
    font_options.png
    17.5 KB · Views: 138
Need help

I wanted to get the Celsius temperature readout

I have the following script
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOUR_AREA_CODE&u=c" | grep -E '(Current Conditions:|C<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'

But I want just the Temperature not the conditions. Can anyone guide how to modify the script.
 
I wanted to get the Celsius temperature readout

I have the following script
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=YOUR_AREA_CODE&u=c" | grep -E '(Current Conditions:|C<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'

But I want just the Temperature not the conditions. Can anyone guide how to modify the script.

Use these geeklets, it should work perfect.
 
could someone tell me where i could find a script that displays the lyrics of the current iTunes track playing?
And (if it's possible) if there is one that displays part of the lyrics based on the track position (time).

Thanks !!
 
could someone tell me where i could find a script that displays the lyrics of the current iTunes track playing?
And (if it's possible) if there is one that displays part of the lyrics based on the track position (time).

Thanks !!

Here's a basic AppleScript to show the lyrics for the current song:

Code:
on run
	set info to ""
	set info2 to ""
	tell application "System Events"
		set num to count (every process whose name is "iTunes")
	end tell
	if num > 0 then
		tell application "iTunes"
			set myLyrics to lyrics of current track
			set info to myLyrics as string
		end tell
	end if
	return info
end run

I would use it myself, but I have found that I am unable to edit the (nonexistent) lyrics of several songs that have been purchased on the iTunes store.
 
I have a rather important question....

I have had my desktop "pimp'd" out with
Geektool scripts and images for the past
two years.

I feel the need to reformat my iMac. I think
there's some sort of virus or otherwise changing
my dock and removing my email setup. My
iMac has been acting weird for quite some time.

The only thing preventing me from doing a fresh
install is that I know I could never rebuild my
Geektool deskop. What I have built I could never
repeat again. It took a few months to perfect,
and all of it was done little-by-little using tricks and
methods in this thread.

Is there a way to backup Geektool? Is all the
information contained in one file?

I would love nothing more to do a fresh OS X
install and then transfer a single folder with all
my Geektool scripts and VOILA...my desktop is
restored.

Am I asking too much?
 
You could make a text file, or better yet a spreadsheet, and record what kind of geeklet there is, what command is put in it, etc. There really isn't an easy way to do it.
 
Shake'N'Bake,

Did a Google search and came up with
a possible idea...

Someone suggested disabling GeekTools
and copying the following....

/Users/YOUR_USERNAME_HERE/Library/Preferences/org.tynsoe.geektool.plist

Found 3 total such PLIST files.

I am going to try it out.

Question...

Where are the weather image files most likely
located on my drive?
 
Would you mind sharing your code for the weather and time? What fonts did you use? Also how are you creating those launchers? Also how did you get the widget for itunes? Thanks for any help. Your setup is extremely nice.

scutzi128,
Just saw your post today, sorry. Thanks for the compliment.

Without getting you completely frustrated with any directions I could possibly put together for the weather including the image, it may be easier for you to watch the following Youtube video. She also has the links to download the scripts under the video controls, it'll include directions for the weather. http://www.youtube.com/watch?v=uNFkW1lLxtU

As far as the Time, Month, Date, and AM/PM separately use the following in the Geektool Shell Command field. Remember to set your refresh times appropriately.

Time:
date '+%I:%M'

Month
date +%B

Date
date +%d

AM/PM
date +"%p"

For fonts I just used Helvetica Neue Light, Medium or Regular.

"The launchers" are Dragthing menus. I've tried others, but I like the customizing features the best. It's really easy to use and they have great support. Since my last posting I put my drives in a drop-down also to clean up my desktop even more. I called the tab "Drives" in the upper right corner, but you can name them anything. The left menu that you see open (for the screenshot only) are the currently open apps "Processes". You can make a menu for just about anything. They may have a demo for you to use, but I can't recall. http://www.dragthing.com/index.html

The "widget" for iTunes is simply a Bowtie skin. Quick and easy. http://bowtieapp.com/

Any other Q's please feel free.

 
Last edited:
The weather stuff can be tricky. I ended up writing a new Applescript for it, just to try to get a better understanding of it. You really shouldn't need Lynx to get the existing Yahoo Weather info to work though...

I re-wrote my scripts to gather info from the Yahoo Weather API. The advantages are a much simpler parsing routine and a well documented code table for weather conditions. This let me use the Flat Weather icon set to show my weather, rather than pull down the current weather PNG from Yahoo.

Here is the code:

Code:
--Date: 7/20/2010 Email:shomann@gmail.com
--Personal or non-commerical use only.
--Yahoo! Weather API used.

--Enter the location of the weather icon FOLDER on your harddrive as URL:
set iconfolder to "file://localhost/Volumes/media/_users/..."

--Enter the WOEID for your location here
--For more information on the WOEID system go here: http://developer.yahoo.com/geo/geoplanet/guide/concepts.html
--To find your WOEID, try here: http://sigizmund.info/woeidinfo/?woeid=texas

set theLoc to "2400767"

--Set unitlogic to true if you are using metric
set unitlogic to "false"

set shell1 to "curl \"http://weather.yahooapis.com/forecastrss?w="
if unitlogic = "false" then
	set shell2 to "\""
else
	set shell2 to "&u=c\""
end if

set web_content to do shell script (shell1 & theLoc & shell2) as string

set AppleScript's text item delimiters to "\""
--Location
set w_city to text item 14 of web_content
set w_state to text item 16 of web_content

--Units
set w_tempunits to text item 20 of web_content
set w_disunits to text item 22 of web_content
set w_prsunits to text item 24 of web_content
set w_speedunits to text item 26 of web_content

--Begin Current Conditions

--Wind
set w_cur_chill to text item 28 of web_content
set w_winddir to text item 30 of web_content
set w_windspd to text item 32 of web_content

--Atmosphere
set w_humid to text item 34 of web_content
set w_vis to text item 36 of web_content
set w_prs to text item 38 of web_content
set w_prslogic to text item 40 of web_content

--Astronomy
set w_sunrise to text item 42 of web_content
set w_sunset to text item 44 of web_content

-- Condition
set w_curcond_text to text item 46 of web_content
set w_curcond_code to text item 48 of web_content
set w_curcond_temp to text item 50 of web_content
set w_updated to text item 52 of web_content

--Forecast
set w_fore0day to text item 60 of web_content
set w_fore0low to text item 64 of web_content
set w_fore0high to text item 66 of web_content
set w_fore0text to text item 68 of web_content
set w_fore0code to text item 70 of web_content

set w_fore1day to text item 72 of web_content
set w_fore1low to text item 76 of web_content
set w_fore1high to text item 78 of web_content
set w_fore1text to text item 80 of web_content
set w_fore1code to text item 82 of web_content

--Prs logic
if w_prslogic is "1" then
	set w_prssymbol to "▲"
else
	set w_prssymbol to "▼"
end if

tell application "GeekTool"
	
	set command of shell geeklet "w_loc" to "echo '" & w_city & ", " & w_state & "'"
	set command of shell geeklet "w_foreday" to "echo '" & w_fore1day & "'"
	set command of shell geeklet "w_temps0" to "echo '" & w_curcond_temp & w_tempunits & "'"
	set command of shell geeklet "w_temps1" to "echo '" & w_fore0high & "-" & w_fore0low & w_tempunits & "'"
	set command of shell geeklet "w_temps2" to "echo '" & w_fore1high & w_tempunits & "\n" & w_fore1low & w_tempunits & "'"
	set image url of image geeklet "w_icon0" to iconfolder & w_curcond_code & ".png"
	set image url of image geeklet "w_icon1" to iconfolder & w_fore1code & ".png"
	
	set command of shell geeklet "w_updated" to "echo '" & w_updated & "'"
end tell


return "H: " & w_humid & "% | V: " & w_vis & w_disunits & " | W: " & w_winddir & "° at " & w_windspd & w_speedunits & " | P: " & w_prs & w_prsunits & w_prssymbol & "     ◉ " & w_sunrise & " - " & w_sunset

To break it down, I first have the script gather info from Yahoo Weather APIs. Then I assemble the output for the details of the current conditions, including humidity, visibility, wind, pressure, and sunrise/set. At the end of the script, I tell Applescript to reset the icons and temperature fields inside GeekTool.

I can break it down further, but if you want to use this as is, create two image geeklets named w_icon0 (for current conditions) and w_icon1 for tomorrow's conditions. Then create 3 shell geeklets named w_temps0 (current temp) and w_temps1(today's high low) and w_temps2 (tomorrow's temps).

You will need to modify the script to point to your weather icons folder. Search for Flat Weather icons on deviantArt for the icons I used...

Let me know what you think!


Like the setup.

though I'm getting the error:
error "GeekTool got an error: Can’t set shell geeklet \"w_loc\" to \"echo 'city, state'\"." number -10006 from shell geeklet "w_loc"
 
Last edited:
99% there

Any idea on how to append nd, rd or th to the end of the date in:

Code:
date '+%d of %b'
?


OK, I'm 99% of the way to your request. It works in Terminal.app with zsh and with bash, but when I paste it in GeekTool it doesn't work. I use zsh as my shell so for other flavors it's lots more work to figure out.

I suppose I need to find out what shell GeekTool needs.

Paste on one line:
Code:
ordinals=(st nd rd th th th th th th th)|
echo $(date +%d)${ordinals[$(($(date +%d)%10))]} of $(date +%b)
 
Last edited:
Well I thought I would share my setup. The desktop is from DeviantART (so credit goes to the person who made that).

And the very low amount of ram is becuase I am running Windows, and had just been running lots more.
 

Attachments

  • geektoolsdsktp.png
    geektoolsdsktp.png
    244.4 KB · Views: 286
OK, I'm 99% of the way to your request. It works in Terminal.app with zsh and with bash, but when I paste it in GeekTool it doesn't work. I use zsh as my shell so for other flavors it's lots more work to figure out.

I suppose I need to find out what shell GeekTool needs.

Paste on one line:
Code:
ordinals=(st nd rd th th th th th th th)|
echo $(date +%d)${ordinals[$(($(date +%d)%10))]} of $(date +%b)

Geektool is probably using system() which will ultimately be calling /bin/sh (which is vastly different from /bin/bash or /bin/zsh; in particular it doesn't know about the arrays you're using there) to run the code you pass to it.

You'll need to take your code and slap it in a separate file, chmod it 700, and have the geeklet exec that.

If you're using bash, take the above and put it in some file, say, /path/to/foo.bash. Don't forget the hash-bang line:
Code:
#!/bin/bash
ordinals=(st nd rd th th th th th th th)
echo $(date +%d)${ordinals[$(($(date +%d)%10))]} of $(date +%b)

Make the file executable with a chmod 700 /path/to/foo.bash

In your script geeklet, have it execute:
exec /path/to/foo.bash
 
date endings

Any idea on how to append nd, rd or th to the end of the date in:

Code:
date '+%d of %b'

?

I don't remember where I got this so I can't give the appropriate credit to it's author. I think this is what you're looking for.

date +"%B %e" | sed -E 's/([^1]1)$/\1st/'| sed -E 's/([^1]2)$/\1nd/' |sed -E 's/([^1]3)$/\1rd/' | sed -E 's/([0-9])$/\1th/'
 
I don't remember where I got this so I can't give the appropriate credit to it's author. I think this is what you're looking for.

date +"%B %e" | sed -E 's/([^1]1)$/\1st/'| sed -E 's/([^1]2)$/\1nd/' |sed -E 's/([^1]3)$/\1rd/' | sed -E 's/([0-9])$/\1th/'

To get it into the "2nd of March" format, I made some minor formatting modifications, including using ";" to chain all those sed commands into a single call:

date +"%d of %B" | sed -E 's/([^1]1)/\1st/ ; s/([^1]2)/\1nd/ ; s/([^1]3)/\1rd/ ; s/^0// ; s/([0-9]) of/\1th of/'

Darryl
 
Last edited:
I don't remember where I got this so I can't give the appropriate credit to it's author. I think this is what you're looking for.

date +"%B %e" | sed -E 's/([^1]1)$/\1st/'| sed -E 's/([^1]2)$/\1nd/' |sed -E 's/([^1]3)$/\1rd/' | sed -E 's/([0-9])$/\1th/'

Is there a way to have it output the lower date numbers 1-9 without the extra space in between the Month and Day?
 
This one gets the latest MLIA's on your desktop.
Code:
curl --silent -A Firefox "http://mylifeisaverage.com/" | sed -n '/<div class="sc">/,/<\/div>/p' | sed 's|<div class="sc">||g' | sed 's|</div>||'
Make sure to turn on force carriage return.


Edit: and its working again.
 
Last edited:
Is this possible? If so, how?

Is there a way to get the events or tasks to go across the screen instead of down? Basically, right now I have to extend the shell all the way down the desktop. I am wondering if there is a way to get the tasks and events to create a second column if I extend the shell across from left to right. Can anyone advise?

I am also wondering if there is a way to change "day after tomorrow at 11:00 AM" and "tomorrow at 1:00 PM" to something like "March 4th at 11:00 AM"

Please be very descriptive as I am VERY new to this application and KNOW NOTHING about script.

Here are the 2 shells and the commands I have now:

/usr/local/bin/icalBuddy -f -sc -sd eventsToday+3 | sed -e "s/*/--/" | sed -e "s/!/!!/"

/usr/local/bin/icalBuddy -f -sc -sd -sdta uncompletedTasks | sed -e "s/*/--/" | sed -e "s/!/!!/"

I have no idea what the second half of either of those codes is doing (| sed -e "s/*/--/" | sed -e "s/!/!!/"), I just copied it off this setup website (http://www.macosxtips.co.uk/index_files/display-ical-events-to-do-list-on-desktop.html)
 
Can you give some example output of those two commands? Just run them in terminal. Since I don't have any ical events or anything, I can't do it myself, and it didn't look like you gave the real output so I have nothing to work with.
 
Thank you for willing to help! When I copy/paste those above commands into terminal I get the following response: -bash: !/!!/": event not found

I am going to try and attach 2 screen shots. One for the Calender command and one for the To Do List command. (Please excuse the personal and somewhat embarrassing view into my world)

[Calendar Command] /usr/local/bin/icalBuddy -f -sc -sd eventsToday+3 | sed -e "s/*/--/" | sed -e "s/!/!!/"

[To Do List Command] /usr/local/bin/icalBuddy -f -sc -sd -sdta uncompletedTasks | sed -e "s/*/--/" | sed -e "s/!/!!/"
 

Attachments

  • Screen shot 2011-03-03 at 6.00.32 PM.png
    Screen shot 2011-03-03 at 6.00.32 PM.png
    271.3 KB · Views: 149
  • Screen shot 2011-03-03 at 6.00.40 PM.png
    Screen shot 2011-03-03 at 6.00.40 PM.png
    134.4 KB · Views: 139
Is there a way to get the events or tasks to go across the screen instead of down? Basically, right now I have to extend the shell all the way down the desktop. I am wondering if there is a way to get the tasks and events to create a second column if I extend the shell across from left to right. Can anyone advise?

I am also wondering if there is a way to change "day after tomorrow at 11:00 AM" and "tomorrow at 1:00 PM" to something like "March 4th at 11:00 AM"

Please be very descriptive as I am VERY new to this application and KNOW NOTHING about script.

Here are the 2 shells and the commands I have now:

/usr/local/bin/icalBuddy -f -sc -sd eventsToday+3 | sed -e "s/*/--/" | sed -e "s/!/!!/"

/usr/local/bin/icalBuddy -f -sc -sd -sdta uncompletedTasks | sed -e "s/*/--/" | sed -e "s/!/!!/"

I have no idea what the second half of either of those codes is doing (| sed -e "s/*/--/" | sed -e "s/!/!!/"), I just copied it off this setup website (http://www.macosxtips.co.uk/index_files/display-ical-events-to-do-list-on-desktop.html)

"-df, --dateFormat format" Format dates included in the output based on the format formatting string. See ""http://tinyurl.com/b9mgyp"" [apple.com] for documentation on the syntax to use. (note: in addition to the standard datetime element specifiers, you can also use the %RW specifier, which stands for ‘‘relative week’’ (e.g. ‘‘next week’’) and the %RD specifier which stands for ‘‘relative day’’ (e.g. ‘‘5 days from now’’).
from: http://hasseg.org/icalBuddy/man.html

so what you have to do is this:
Code:
/usr/local/bin/icalBuddy -df "%e of %B" -f -sc -sd eventsToday+3 | sed -e "s/*/--/" | sed -e "s/!/!!/"

didnt try it, but it should work.
 
I thought I would share my set-up.

Icons - Edited by me. (Original source "Helveticons")

Wallpaper - From Simple Wallpapers.

Date, time, and weather - Are simple and by me. I used Helvetica Neue for the type.

Screenshot2011-03-03at103923PM.png
 
Last edited by a moderator:
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.