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.
That looks like a complicated script for this. Here's my script for uptime.
Code:
echo "UP: \c"
uptime | cut -d ' ' -f 4-8 | sed -e s'/,//g;s/  / /g' | cut -d ' ' -f 1-3 | sed s'/,[ ]+users//'

I didn't write it, but it's a cool script in that it senses one day, hour, or minute and displays the singular form of the time, then if it's more than one day, hour, or minute, it adds an "s" to the word.

Looks great all except sensing one "day"....one minute or one hour display properly.
 
When I run the script and the uptime is one day, it returns an error about not being able to convert a value to Unicode. I can't generate the error today (machine has now been up two days).

I think the problem is it's trying to decide to display the text "day" vs. "days" and bombing, but I can't figure out why.

If I am reading this script correctly, not only does it have a day/days problem, it also has an hour/hours problem (ie, it will show "1 hours" at certain times) and also min/mins problem (certain times will come up as 1 mins) which will happen every now and then.

Honestly since there are many variations of how the time is outputted via uptime, without rewriting the script to check for these variations or changing it to manually check for what specific number each timeset is currently at (such as check if there is a 1 in the day spot then make it day as opposed to days), that script will not work at certain times and even run into a number of consistency problems. And those kind of problems drive me nuts, like when time shows up as 1 days, 1 hours, 1 minutes.

This is why I found it easier to make an uptime script output something with static abbreviations such as... 1d 4h 38m .. All the info is there but no need to deal with plurals. It keeps it cleaner and much simpler to write.
 
my uptime script shows day or days considering plurals and abbreviations for hours and minutes.
ie:
Code:
1 day 18h 47min
39 days 5h 04min

it's a not-so-simple shell script i found somewhere sometime and amended according to my preferences:
Code:
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 :\t" $3$4$5$6}'
try it an let me know!
 
If I am reading this script correctly, not only does it have a day/days problem, it also has an hour/hours problem (ie, it will show "1 hours" at certain times) and also min/mins problem (certain times will come up as 1 mins) which will happen every now and then.

Honestly since there are many variations of how the time is outputted via uptime, without rewriting the script to check for these variations or changing it to manually check for what specific number each timeset is currently at (such as check if there is a 1 in the day spot then make it day as opposed to days), that script will not work at certain times and even run into a number of consistency problems. And those kind of problems drive me nuts, like when time shows up as 1 days, 1 hours, 1 minutes.

This is why I found it easier to make an uptime script output something with static abbreviations such as... 1d 4h 38m .. All the info is there but no need to deal with plurals. It keeps it cleaner and much simpler to write.

Thanks for taking a look at it...I guess I haven't been looking at my Mac during those other inconsistent times so I haven't noticed them yet. It'd be slick to get a script that can check all those conditions and display the correct output, but as you say, a lot of work to get it right.
 
my uptime script shows day or days considering plurals and abbreviations for hours and minutes.
ie:
Code:
1 day 18h 47min
39 days 5h 04min

it's a not-so-simple shell script i found somewhere sometime and amended according to my preferences:
Code:
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 :\t" $3$4$5$6}'
try it an let me know!

I think that's the one I found as an alternative and am using it now...I'll verify when I get back to my machine.
 
Geek Tool Question

Hi,

New to this so please bear with me... I just downloaded geek tool, have put the month, date, time on my home screen using the shell, but the time is not changing...what am I doing wrong??? Any help would be appreciated!!!
Thanks!
Dan
 
Hi,

New to this so please bear with me... I just downloaded geek tool, have put the month, date, time on my home screen using the shell, but the time is not changing...what am I doing wrong??? Any help would be appreciated!!!
Thanks!
Dan

Make sure you set the refresh rate appropriately....default is 0 (no refresh)
 
Does anyone know how I can add my town like in this picture to my geek tool on my desktop?? I have everything else except not sure how to add a city name?

if you have everything else than you know how to change the location URL.
you have to do the same for the city name.
 
Geek Tool Question

Thanks for the help!!

Another question...I got my time, weather and stuff all set up with geek tool on my desktop, looked great....lost my power, imac went off, went I restarted it I lost all my shells except for 2 or 3.....what happened?? How come they got lost??? Now I have to re-create it all!!! Did I do something wrong when I first set it up???

Thanks!
Dan
 
Sunrise Sunset help!!!

Can someone tell me why when I paste the script for Sunrise and Sunset for my area both say PM and the same time?
Here's the script I used for geek tool:

Sunset:
curl --silent "http://weather.yahoo.com/united-states/california/folsom-2404810/" | grep "Sunset" | sed -e 's/.*\<dd\>/Sunset: /' -e 's/<.*//'

Sunrise:
curl --silent "http://weather.yahoo.com/united-states/california/folsom-2404810/" | grep "Sunrise" | sed -e 's/.*\<dd\>/Sunrise: /' -e 's/<.*//'

Then I replace the HTTP with my location:
http://weather.yahoo.com/united-states/massachusetts/haverhill-12758590/
 
Can someone tell me why when I paste the script for Sunrise and Sunset for my area both say PM and the same time?
Here's the script I used for geek tool:

Sunset:
curl --silent "http://weather.yahoo.com/united-states/california/folsom-2404810/" | grep "Sunset" | sed -e 's/.*\<dd\>/Sunset: /' -e 's/<.*//'

Sunrise:
curl --silent "http://weather.yahoo.com/united-states/california/folsom-2404810/" | grep "Sunrise" | sed -e 's/.*\<dd\>/Sunrise: /' -e 's/<.*//'

Then I replace the HTTP with my location:
http://weather.yahoo.com/united-states/massachusetts/haverhill-12758590/

Ok you are using the same script as someone I helped earlier in this thread. Yahoo seems to have changed their code slightly on their webpage, resulting in the sunrise script not working properly.

So here is an update to the sunrise script so that it will work for you.

Code:
curl --silent "http://weather.yahoo.com/united-states/massachusetts/haverhill-12758590/" | grep "Sunrise" | sed -e 's/.*\<dt\>Sunrise:\<\/dt\>\<dd\>/Sunrise: /' -e 's/<.*//'
 
Thanks for the help!!

Another question...I got my time, weather and stuff all set up with geek tool on my desktop, looked great....lost my power, imac went off, went I restarted it I lost all my shells except for 2 or 3.....what happened?? How come they got lost??? Now I have to re-create it all!!! Did I do something wrong when I first set it up???

Thanks!
Dan

The only thing I can think of is perhaps the .plist files that store your geeklet scripts got currupted when your power was lost? Not sure. This is a good reminder though for everyone to keep a backup of your scripts. I always have a text file saved in "Documents" that has all my geektool scripts saved in it. That way if anything happens to geektool, regardless of cause, I can always quickly recreate my setup.
 
Okay, so I put up the images and they all look great. Only problem is, it doesn't always work. Most of the time, it won't stay in the background. The other times, it stays, but after I exit System Preferences, the items stay highlighted and moveable. idk if I'm running too many scripts at once or what, because GeekTool is buggy every time I do this. :(

Okay, so I've been thinking about this for a while, and I think I have a solution, but I'm not sure…:confused:

I want to set up a file, Wallpaper.jpg, and use this as my wallpaper. Then, use a GeekTool script to change this file to the appropriate one (e.g. overwrite it with the correct background). Do you guys think this will work? And if so, what would I need to code to make it overwrite this?
 
Okay, so I've been thinking about this for a while, and I think I have a solution, but I'm not sure…:confused:

I want to set up a file, Wallpaper.jpg, and use this as my wallpaper. Then, use a GeekTool script to change this file to the appropriate one (e.g. overwrite it with the correct background). Do you guys think this will work? And if so, what would I need to code to make it overwrite this?

One way to do this could be to run an applescript via geektool to change the background.

Just set a different applescript app to run for when you activate each group.

Code:
tell application "Finder"
set desktop picture to {"Macintosh HD:Users:username:Pictures:wallpapername.jpeg"} as alias
end tell

You will have to change that above path to match up to the directory path of the picture you want as your wallpaper.
 
One way to do this could be to run an applescript via geektool to change the background.

Just set a different applescript app to run for when you activate each group.

Code:
tell application "Finder"
set desktop picture to {"Macintosh HD:Users:username:Pictures:wallpapername.jpeg"} as alias
end tell

You will have to change that above path to match up to the directory path of the picture you want as your wallpaper.

I don't know why but the code wasn't working in the Applescript Editor. When I deleted the "as alias" it started working (idk why). I set it up as a shell command and now, it works!!! Thank you so much! This stopped the bugs I was experiencing from occurring again. So now, I have three beautiful GeekTool integrated desktops that work! Thanks again.
 
Another question...I got my time, weather and stuff all set up with geek tool on my desktop, looked great....lost my power, imac went off, went I restarted it I lost all my shells except for 2 or 3.....what happened?? How come they got lost??? Now I have to re-create it all!!! Did I do something wrong when I first set it up???

GeekTools is buggy. put your scripts in NerdTool and you'll never have these problems.
 
hi everyone.
to make things short, I just bought a new MBP (the i7, I love it! :D) and I also took the magic mouse, which very useful...
I'm using geektool a lot, and I would like to have the % of battery left on my mouse on my desktop. I tried with Applescript, but I have a problem. Here's what I've done so far (not much I know... :p)
Code:
tell application "System Preferences"
	try
		set propert to properties of the pane "Bluetooth"
		set anchs to anchor of the pane "Bluetooth"
	end try
end tell
fisrt, I'm I suppose to take the properties or the anchors of the pane to find the %? then, where can I find the variables? it's not on the dictionary (well not where I checked...)

thanks!
 
Here's Mine

Here's my desktop. Using Geektool for the date, current weather, top labels, lines and in conjunction with icalBuddy for the calendar stuff. Bowtie is for itunes (Zukunft Condensed White theme) and WideScape weather for Yahoo Widgets for the forecast. Dateline for the date bar at the bottom.

Let me know what you think!
 

Attachments

  • screen-capture.png
    screen-capture.png
    732.7 KB · Views: 597
Here's my desktop. Using Geektool for the date, current weather, top labels, lines and in conjunction with icalBuddy for the calendar stuff. Bowtie is for itunes (Zukunft Condensed White theme) and WideScape weather for Yahoo Widgets for the forecast. Dateline for the date bar at the bottom.

Let me know what you think!

I think that's my favourite that I've ever seen.
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.