|
|
Combine bash w/ applescript
I'm glad I found this hint (I'm a former XMMS2 junkie on FreeBSD). You can actually open up the command structure of iTunes directly to the command line. This approach (below) uses a couple short mapping functions, and a mega hint function.
I store this in a file called ~/shell/itunes.sh, and then source it (dot it) from ~/.bashrc, e.g. . ~/shell/itunes.sh
itunes() {
if [ -z "$1" -o "$1" = '-h' -o "$1" = '--help' ]; then
itunes-hints
else
osascript -e 'tell app "iTunes" to '"$*"
fi
}
vol() {
local vol=$(itunes get sound volume)
if [[ -z "$1" ]]; then
echo $vol
elif [[ "$1" = up ]]; then
itunes set sound volume to $((vol+10))
elif [[ "$1" = down ]]; then
itunes set sound volume to $((vol-10))
elif [[ "$1" =~ ^[0-9]{1,3}$ ]]; then
itunes set sound volume to "$1"
else
echo vol '[up | down | <number>]'
fi
}
itunes-hints() {
cat - <<EOS
Usage:
itunes play
itunes stop
itunes playpause
itunes set mute to 1
itunes set mute to 0
itunes quit
itunes next track
itunes previous track
itunes play playlist \"name\"
itunes play track 3 of current playlist
itunes get player state
itunes get player position
itunes get artist of current track
itunes get name of current track
itunes get current stream title
itunes get current stream URL
itunes get name of every playlist
itunes get name of every track in current playlist
itunes get name of track 3 of current playlist
itunes set position of window \"iTunes\" to '{0,22}'
itunes set bounds of window \"iTunes\" to '{0,22,800,600}'
itunes set visible of window \"iTunes\" to 1
: ... anything you can tell iTunes via OSA
: See /Applications/AppleScript/Script Editor
vol up - Increase volume by 10%
vol down - Decrease volume by 10%
vol <0-100> - Set volume from 0 to 100%
EOS
}
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.20 seconds |
|