|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Hello! I just discovered Geektool last night and have been going crazy with all the options. I found a really cool geeklet that displays the itunes song rating, but right now it only displays the number of stars in the rating. I figured out how to display 5 "white" stars when it has no rating, but my attempts to always display 5 stars is failing. Here is the script I came up with so far...
#!/usr/bin/osascript on run set info 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 how to rating of current track if how is 0 then return "☆☆☆☆☆" if how is 1 then return "★☆☆☆☆" if how is 2 then return "★★☆☆☆" if how is 3 then return "★★★☆☆" if how is 4 then return "★★★★☆" if how is 5 then return "★★★★★" set how to how / 20 as integer set star to {"★"} set infoitems to {} set starnum to 0 repeat set infoitems to infoitems & star set starnum to starnum + 1 if starnum = how then exit repeat end repeat set info to infoitems as string end tell end if return info end run I totally added all the "if how is" 1-5; if how is 0 works but all the other ones only display the number of stars in the rating. Any help would be much appreciated, thank you![COLOR="#808080"] ---------- All I had to do was move the "if how is" 1-5 until AFTER I set how. This is the new code, for anyone that wants to use this updated one... #!/usr/bin/osascript on run set info 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 how to rating of current track if how is 0 then return "☆☆☆☆☆" set how to how / 20 as integer if how is 1 then return "★☆☆☆☆" if how is 2 then return "★★☆☆☆" if how is 3 then return "★★★☆☆" if how is 4 then return "★★★★☆" if how is 5 then return "★★★★★" set star to {"★"} set infoitems to {} set starnum to 0 repeat set infoitems to infoitems & star set starnum to starnum + 1 if starnum = how then exit repeat end repeat set info to infoitems as string end tell end if return info end run GEEKTOOL IS AMAZING, I haven't done anything else in the past day!!!!! Will post my desktop once I get it perfect. HAHA! |
|
|
|
0
|
|
|
#2 |
|
Give this a try:
Code:
tell application "System Events" to set allAppList to name of application processes if allAppList contains "iTunes" then tell application "iTunes" set trackRating to rating of current track if trackRating is 0 then set returnStart to "☆☆☆☆☆" else if trackRating is 1 then set returnStart to "★☆☆☆☆" else if trackRating is 2 then set returnStart to "★★☆☆☆" else if trackRating is 3 then set returnStart to "★★★☆☆" else if trackRating is 4 then set returnStart to "★★★★☆" else if trackRating is 5 then set returnStart to "★★★★★" else set returnStart to "ERROR" end if end tell return returnStart end if
__________________
Last edited by Intell; Yesterday at 11:50 AM. |
|
|
|
0
|
|
|
#3 |
|
Intell, thanks for the quick reply!
I posted my own reply because I figured it out right after I posted it, or at least I got it to work...
---------- #!/usr/bin/osascript on run set info 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 how to rating of current track if how is 0 then return "☆☆☆☆☆" set how to how / 20 as integer if how is 1 then return "★☆☆☆☆" if how is 2 then return "★★☆☆☆" if how is 3 then return "★★★☆☆" if how is 4 then return "★★★★☆" if how is 5 then return "★★★★★" set star to {"★"} set infoitems to {} set starnum to 0 repeat set infoitems to infoitems & star set starnum to starnum + 1 if starnum = how then exit repeat end repeat set info to infoitems as string end tell end if return info end run It's definitely nowhere near as sophisticated, but it seems to work. Would it cause any problems or anything? I honestly know nothing about coding, I'm figuring out how to "tweak" scripts using common sense and guess and check! xP |
|
|
|
0
|
|
|
#4 |
|
Your script seems to have some unneeded counting and logic in it. They should both get the end result of having the stars printed. I don't see any problems with it at all.
__________________
Last edited by Intell; Yesterday at 11:50 AM. |
|
|
|
0
|
|
|
#5 |
|
Thanks! I was also wondering if you could help me out with a problem with my dateline calendar.
Here's the code: Code:
#!/usr/bin/env ruby
#
# Author: Robert Jorgenson
# Author email: rjorgenson@gmail.com
require 'Date'
ABBR_DAYNAMES = {0, 'Su', 1, 'Mo', 2, 'Tu', 3, 'We', 4, 'Th', 5, 'Fr', 6, 'Sa'}
def days_in_month(year, month)
return (Date.new(year, 12, 31) << (12 - month)).day
end
def day_in_month(year, month, day)
return Date.new(year, month, day).wday
end
def build_day_array(year, month)
day_array = Array.new
for d in (1..days_in_month(year, month))
day_array[d] = ABBR_DAYNAMES[day_in_month(year, month, d)]
end
day_array.shift
return day_array * " "
end
def build_separator(year, month)
red = "\e[31m" #uncomment for red
black = "\e[30m"
separator_string = "[]" # change this to change separator, best if 2 characters wide
close = "\e[30m" # don't change this
separator = Array.new
for d in (1..days_in_month(year, month))
if year == Time.now.year && month == Time.now.month && d == Time.now.day then
separator[d] = "#{red}#{separator_string}#{close}"
else
separator[d] = "#{black}#{separator_string}"
end
end
separator.shift
return separator * " "
end
def build_date_array(year, month)
date_array = Array.new
for d in (1..days_in_month(year, month))
date_array[d] = d
end
date_array.shift
date_array.each do |d|
if d < 10 then
date_array[(d-1)] = "0#{d}"
end
end
return date_array * " "
end
year = Time.now.year
month = Time.now.month
puts build_day_array(year, month)
puts build_separator(year, month)
puts build_date_array(year, month)
Also, my girlfriend pointed out (I hadn't noticed it before) that the calendar is enclosed in a dark grey box... is there any way to make that transparent? Thank you so much! |
|
|
|
0
|
|
|
#6 |
|
I'll be able to help you some time tomorrow. But for now, it's bed time.
__________________
Last edited by Intell; Yesterday at 11:50 AM. |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 07:57 AM.







Linear Mode
