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.
just got a little idea... here's the AppleScript!

Code:
tell application "System Events" to set iCalIsRunning to (name of processes) contains "Mail"
set finalText to ""
if iCalIsRunning then
	tell application id "com.apple.mail"
		set unreadCount to (get unread count of inbox)
		if unreadCount > 0 then
			set finalText to "█"
		end if
	end tell
end if
finalText

since my dock is auto-hiding, i cant see when i have a new mail. so with geektool, i can put the shell (always on top), in the top corner, and i dont have to move my mouse to know if i have a new mail!
im lazy, i know... :D
 
I'm having trouble getting anything entered in the "command" box to show up in the translucid shell window. Even typing in something as simple as "cal" does nothing. Any hints?

10.6.4
Geektool 3.0
 
script for currency exchange rates

Don't blame me on my programming skills but I haven't found a script for online currency exchange rates so I developed this small script which shows me the US rate for the Euro:

curl --silent "http://www.ecb.int/rss/fxref-usd.html" | grep -E '(ECB Reference rate)' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' -e 's/1 EUR//' | awk '{print $1,$4}'

Output looks like
1.3896 2010-10-18
1.4089 2010-10-15
1.4101 2010-10-14
1.3958 2010-10-13
1.3833 2010-10-12

Two questions: How can I convert the date from yyyy-mm-dd to dd.mm.yy
and
what needs to be programmed, that I only will receive the first two lines? I don't need all the history.
Thanks in advance for any help
 
check unread mails

Have a nice script for unread email checking.

Code:
if [ "$(ps -Ac | grep Mail)" != "" ]; then
	echo 'tell application "Mail" to return unread count of inbox as string' | osascript | grep -v '00';
fi
echo $mailStat;

The advantage it checks only if mail App is running and does not start mail as other scripts do. Another script changes the text accordingly

Code:
if [ "$(ps -Ac | grep Mail)" != "" ]; then
	echo "unread mails";
else
	mailStat="mail is down";
fi
echo $mailStat;
 
since my dock is auto-hiding, i cant see when i have a new mail. so with geektool, i can put the shell (always on top), in the top corner, and i dont have to move my mouse to know if i have a new mail!
im lazy, i know... :D

I have the same type of thing except I use a red background and white font to show the number of unread items, then place it next to the Spotlight icon like you suggest. I did it for the same reason as you, I have my Dock hidden.

I also posted a script for showing the inbox on your desktop and highlights the unread ones.
Code:
osascript <<eos
tell application "Mail"
    set x to 0
    -- Grab all of the unread messages first
    repeat with _msg in (messages in inbox)
        if read status of _msg is false then
            set x to x + 1
        end if
    end repeat
    if x > 0 then
        " "& x &" "
    else
        --"   "
    end if
end tell
eos
 
I have the same type of thing except I use a red background and white font to show the number of unread items, then place it next to the Spotlight icon like you suggest. I did it for the same reason as you, I have my Dock hidden.

I also posted a script for showing the inbox on your desktop and highlights the unread ones.

*bookmarks*

that is wonderful! thanks so much! i am investigating possibilities for my geektools on my imac :)
 
Don't blame me on my programming skills but I haven't found a script for online currency exchange rates so I developed this small script which shows me the US rate for the Euro:

curl --silent "http://www.ecb.int/rss/fxref-usd.html" | grep -E '(ECB Reference rate)' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' -e 's/1 EUR//' | awk '{print $1,$4}'

Output looks like
1.3896 2010-10-18
1.4089 2010-10-15
1.4101 2010-10-14
1.3958 2010-10-13
1.3833 2010-10-12

Two questions: How can I convert the date from yyyy-mm-dd to dd.mm.yy
and
what needs to be programmed, that I only will receive the first two lines? I don't need all the history.
Thanks in advance for any help

How about adding the following to the end of your commands:
Code:
 | head -2 | sed 's/-/ /g' | awk '{print $1,"@"$4,$3,$2}' | sed 's/ /./g;s/.@/  /g;s/..\(..$\)/\1/'

MAJ
 
I have the same type of thing except I use a red background and white font to show the number of unread items, then place it next to the Spotlight icon like you suggest. I did it for the same reason as you, I have my Dock hidden.

I also posted a script for showing the inbox on your desktop and highlights the unread ones.
Code:
osascript <<eos
tell application "Mail"
    set x to 0
    -- Grab all of the unread messages first
    repeat with _msg in (messages in inbox)
        if read status of _msg is false then
            set x to x + 1
        end if
    end repeat
    if x > 0 then
        " "& x &" "
    else
        --"   "
    end if
end tell
eos

im sure id would look great, if i could actually use it! but when i put it in the shell command bar it doesnt work... same thing for your other mail script... i've also tried to put the Applescript part in the editor, but i couldn't even run it... what i'm i doing wrong? i've checked the escape characters and they're here...
 
im sure id would look great, if i could actually use it! but when i put it in the shell command bar it doesnt work... same thing for your other mail script... i've also tried to put the Applescript part in the editor, but i couldn't even run it... what i'm i doing wrong? i've checked the escape characters and they're here...

You'll likely need to retype the color codes as they involve escape characters, which don't post well to the forum. See this post for entering color codes. When you moved it to AppleScript editor, did it give any errors? Do you currently have new messages? If not, it won't display anything. Also, what OS version do you have? It could make a difference in what works. I'm on 10.6. Also, AppleScript Editor likely won't give feedback. It may show something in the output panel, but can't remember.
 
You'll likely need to retype the color codes as they involve escape characters, which don't post well to the forum. See this post for entering color codes. When you moved it to AppleScript editor, did it give any errors? Do you currently have new messages? If not, it won't display anything. Also, what OS version do you have? It could make a difference in what works. I'm on 10.6. Also, AppleScript Editor likely won't give feedback. It may show something in the output panel, but can't remember.

ill try retyping the color codes tonight... thanks! :)
theres no "error", it just runs and doesnt stop... and i have 10.6 too...

edit: just a minute... your script to show the inbox, does it have to check all the messages in the inbox? if yes, well this might be why it doesnt work... i have more than 10000 messages in my inbox... :p
thats the reply it keeps on sending (in the editor)
Code:
get read status of item 20 of every message of inbox
where the item changes about every second...
thanks again!
 
edit: just a minute... your script to show the inbox, does it have to check all the messages in the inbox? if yes, well this might be why it doesnt work... i have more than 10000 messages in my inbox... :p

Yea, that could definitely be an issue. The script sorts all the messages by date, then goes through them all to do counting and whatnot. The one variable does set a limit on the output of messages (default I think is 18), but that doesn't cut down on some of the first loops. If you only have one account setup in Mail the script could probably be tweaked to run more efficiently, but it would take me some time to work that out. Mainly it would involve taking "theList" variable from the inbox and just getting the first x messages rather than the whole shebang. If I get a chance, I'll look into it.
 
Haven't visited this thread in a while and I really like what I am seeing here. Some great layouts. I've had this same one for some time now and looks like it will stay until the end of the year. Going to need to cook up something new eventually!

And yes, I need to clean my desktop.

without iTunes playing
Screenshot2010-10-19at94203pm.png


with iTunes playing
Screenshot2010-10-19at94325pm.png
 
Check out page 63 of this thread, and post 1553 in particular. You should be able to adapt that post for your needs.

How would you change that code for a countdown to a specific date?? I tried a couple things not knowing anything about writing code but nothing worked??

Thanks
 
pretty sure thats all you have to change :
Code:
mktime(0, 0, 0, 7, 1, 2000)
(this would give the 1st of July 2000)


Ok, i dont know if it is my code or the whole .php thing thats is giving me trouble.

I put this code together off a couple different sites then saved as .php and tried to "call" (or whatever u call it ) it in geektool and i get nothing..... anyone help me out??

im not sure if I am doing the .php thing correctly, i cant find any info about how to do it...

PHP:
<?php
$target = mktime(0, 0, 0, 5, 7, 2010) ;
$today = time () ;
$difference =($target-$today) ;
$weeks = (int) ($difference/604800) ;
$days =(int) ($difference/86400) ; 
$hours =(int) ($difference/3600) ;
$minutes =(int) ($difference/60) ;
print "$weeks, $days, $hours, $minutes Until Hell!!";
	?>
 
im not sure if I am doing the .php thing correctly, i cant find any info about how to do it...

What do you have in the command line of Geektool? Make sure you precede the PHP file with the php command. Example:
Code:
php folder/file.php
 
What do you have in the command line of Geektool? Make sure you precede the PHP file with the php command. Example:
Code:
php folder/file.php

yea as far as i know thats what i have been doing...

have tried...

going with just php folder/file.php

and have tried as far back as php macintosh hd/users........./file.php

cant seem to get anything to work? but i dont know if its the code or my php illiteracy???
 
cant seem to get anything to work? but i dont know if its the code or my php illiteracy???

Yeah stop messing with how to run the code in geektool, it seems it is a code error. You won't get error messages via geektool so when in doubt always try running it through terminal to see what pops out. In this case the following error comes out.

Code:
rob@MacBookPro:~/bin:$> php test.php

Warning: mktime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /Users/rob/bin/test.php on line 2
-23, -167, -4021, -241276 Until Hell!!
 
my brand new desktop!
finished it 5 min ago! :cool:
 

Attachments

  • Screen shot 2010-10-21 at 1.37.29 PM.jpg
    Screen shot 2010-10-21 at 1.37.29 PM.jpg
    752.8 KB · Views: 516
im not sure if I am doing the .php thing correctly, i cant find any info about how to do it...

I read over the other countdown code and something like this should work if this is what you are looking for. This is a countdown to Halloween which displays days, hours, and minutes left and can be modified to any date easily.

PHP:
<?php
// remember to set your own timezone
date_default_timezone_set('America/New_York');
// (year, month, day, hour, min)
countdown(2010,10,31,0,0);
function countdown($year, $month, $day, $hour, $minute)
{
  $the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1);
  $today = time();
  $difference = $the_countdown_date - $today;
  if ($difference < 0) $difference = 0;
  $days_left = floor($difference/60/60/24);
  $hours_left = floor(($difference - $days_left*60*60*24)/60/60);
  $minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);
echo "$days_left days $hours_left hours $minutes_left minutes left until Halloween";
}
?>

As for how to use php in geektool, save the php code in a file say "countdown.php", and say it is stored in your Documents folder, you would execute this in geektool by the command..

Code:
php ~/Documents/countdown.php
 
I read over the other countdown code and something like this should work if this is what you are looking for. This is a countdown to Halloween which displays days, hours, and minutes left and can be modified to any date easily.

@Tag,Thank you very much!! I didnt know you can take the code and put it into terminal and have it "check" it.

I used that to edit my code and try and get it myself and it worked!! I am at school and will post it when i get home, but it is basically the same as your code.

thanks again for the help!!
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.