A note about the GeekTool It turned out to be quite popular. So I decided to develop the theme a bit and talk about other ways to work with the program. If there are any questions - feel free to ask.
Working with iTunes
reader mixazen interestedHow to display on the desktop name of the song being played. This problem is actually two sub - must somehow get from the iTunes song title, and then use GeekTool display it on your desktop.
The forums Macrumors I found the following script:
property go1: false. - check to see if iTunes is running. tell application "System Events" set the process_flag to (exists process "iTunes") end tell. if the process_flag then - check to see if iTunes is playing tell application "iTunes" if player state contains playing then set go1 to true end tell if go1 then - do what you need to do tell application "iTunes" set foo1 to name of current track set foo2 to artist of current track set foo3 to album of current track set foo4 to foo1 & "/" & foo2 & "/" & foo3 end tell end if. end if.
Save it by giving any name and said expanded scpt (file Applescript). Then run GeekTool, create a new Giklet (how to do it, I mentioned in the previous article). In the Command, enter the following command:
osascript /put/do/skripta/itunes.scpt
osascript - it team perform AppleScript script. It remains to choose the update interval (time will be sufficient to 5 seconds) and experiment with design. The script works fine with the latest version of iTunes and correctly displays the name of Russian songs. You can go even further and, for example, displayed on the desktop a progress bar playing song. But this is too much, in my opinion.
We derive the album art of the playing song to your desktop
GeekTool - amazingly powerful stuff. Opportunities offered by the program, except that users are limited imagination. Studying examples, I encountered the article Dr Drenga (Dr. Drang), which via GeekTool displays for desktop album cover. After half an hour the proceedings my desktop looks like this (note that I have installed GeekTool 3.0 RC5 and iTunes 9.0.2):
And now about how to get to the desktop cover composition that is played at the moment in iTunes. For this we need to write AppleScript and make a couple gikletov.
AppleScript code is as follows:
- Paths and stuff. set ArtworkFromiTunes to ((path to home folder) as text) & ¬ "Pictures: iTunes Artwork: From iTunes: albumArt.pict" as alias. set iTunesArtwork to ((path to home folder) as text) & ¬ "Pictures: iTunes Artwork: From iTunes: albumArt.pict" set DefaultArtwork to ((path to home folder) as text) & ¬ "Pictures: iTunes Artwork: Default: albumArt.pict" set displayArtwork to ((path to home folder) as text) & ¬ "Pictures: iTunes Artwork: albumArt.pict" - Unix versions of the above path strings. set unixITunesArtwork to the quoted form of POSIX path of iTunesArtwork. set unixDefaultArtwork to the quoted form of POSIX path of DefaultArtwork. set unixDisplayArtwork to the quoted form of POSIX path of displayArtwork set whichArt to "blank" tell application "System Events" if exists process "iTunes" then - iTunes is running tell application "iTunes" if player state is playing then - iTunes is playing set aLibrary to name of current playlist - Name of Current Playlist set aTrack to current track set aTrackArtwork to null if (count of artwork of aTrack) ≥ 1 then - there's an album cover "Running and playing and art" set aTrackArtwork to data of artwork 1 of aTrack set fileRef to ¬ (open for access ArtworkFromiTunes with write permission) try set eof fileRef to 512 write aTrackArtwork to fileRef starting at 513 close access fileRef on error errorMsg try close access fileRef end try error errorMsg end try tell application "Finder" to ¬ set creator type of ArtworkFromiTunes to "???" set whichArt to "iTunes" end if end if end tell end if. end tell if whichArt is "iTunes" then do shell script "ditto -rsrc" & unixITunesArtwork & space & unixDisplayArtwork. else do shell script "ditto -rsrc" & unixDefaultArtwork & space & unixDisplayArtwork. end if.
Save the file as iTunesArtwork.scpt. You can also download it from the website "Makradara". better file placed in the folder ~ / Library / Scripts, although this is not essential.
Now create the first giklet. Shell click on the icon, drag it to the desktop, as well as a command, specify this:
osascript ~ / Library / Scripts / iTunesArtwork.scpt
Giklet causes and more AppleScript does nothing. Therefore, take the time to format it is not necessary. Specify a range call - 5-10 seconds is enough.
Then, in a folder ~ / Pictures
iTunes Artwork, create a subfolder with the following structure:
This structure is necessary to reproduce exactly. Create From iTunes and Default folder. They put albumArt.pict file created in any graphics program. File albumArt.pict used in cases where iTunes does not play anything, or the album art is missing. Therefore albumArt.pict make 1x1 pixels and paint color that matches the color of wallpaper (not ozdavalos impressions "broken pixel").
Now you have to create another giklet. Click the Picture icon, drag it to the desktop. In the file, specify:
file: ///Users/put_k_faylu/Pictures/iTunes%20Artwork/albumArt.pict
Specify the update interval (5-10 seconds) and image size (I chose 200x200 pixels).
If you want to display on the desktop album cover, keep in mind: we GeekTool immediately increased the appetite for storage. Instead of the usual 30-40 MB of RAM, it starts to require 300 MB. For modern computers equipped with 4 or more gigabytes of RAM is almost palpable, for the old makbukov with limits 2GB - is an occasion to think about it, is it really necessary these "whistles". In any case, in the corner of the desktop can be a separate gikletom display information about the amount of RAM used GeekTool. The team is as follows:
ps axo "rss, ucomm" | awk '/ Geek / {printf "% .2f", $ 1/1024}'
***
In these two examples, we were taken to the desktop as text data and images. Once again I podverknu: GeekTool - fantastic app. I continue to experiment with it on a daily basis. Already I tried to display on your desktop statistics Li.ru one of the sites, tweets and weather. :-)
If you have any questions or clarifications, I will be glad to see them in the comments. Share the results of their experiments, interesting to learn about your experiences.
Updated. Useful link from Sergei Tugarinova - scripts collection for GeekTool
***
Useful links:
- Conclusion album art to your desktop
- How to keep track of how much memory to use Geek Tool
- How to display events from iCal calendar directly on the desktop?