dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 6be98b3bc35ac2f2a7e4767f1635d47c05b31313
parent dc77feed3c7960fbafff61b460bb673848569561
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Sun, 26 Nov 2017 22:26:06 +0100

Added option for choosing currently playing song or selected song. Can also pass command-line arguments.

Diffstat:
Mitunes_style_getter | 34++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/itunes_style_getter b/itunes_style_getter @@ -1,8 +1,33 @@ #!/bin/bash -# Get info about currently selected track from iTunes (AppleScript) -artist=`osascript -e "tell application \"iTunes\" to return artist of selection"`; -album=`osascript -e "tell application \"iTunes\" to return album of selection"`; -name=`osascript -e "tell application \"iTunes\" to return name of selection"`; + +if [ $# -ne 0 ]; then + case $1 in + "-p") + artist=`osascript -e "tell application \"iTunes\" to return artist of current track"`; + album=`osascript -e "tell application \"iTunes\" to return album of current track"`; + name=`osascript -e "tell application \"iTunes\" to return name of current track"`; + ;; + "-s") + artist=`osascript -e "tell application \"iTunes\" to return artist of selection"`; + album=`osascript -e "tell application \"iTunes\" to return album of selection"`; + name=`osascript -e "tell application \"iTunes\" to return name of selection"`; + esac +else + echo "Which track?" + select sc in "Selected" "Playing"; do + case $sc in + Selected) + artist=`osascript -e "tell application \"iTunes\" to return artist of selection"`; + album=`osascript -e "tell application \"iTunes\" to return album of selection"`; + name=`osascript -e "tell application \"iTunes\" to return name of selection"`; + break;; + Playing) + artist=`osascript -e "tell application \"iTunes\" to return artist of current track"`; + album=`osascript -e "tell application \"iTunes\" to return album of current track"`; + name=`osascript -e "tell application \"iTunes\" to return name of current track"`; + esac + done +fi if [ -z "$album" ]; then # If there's no album, query without an album @@ -55,6 +80,7 @@ select yn in "Yes" "No"; do echo "Write your own then:" read finalg if [[ $finalg = "Hip Hop" ]]; then finalg="Hip-Hop"; fi + if [[ $finalg = "Post-Rock" ]]; then finalg="Post Rock"; fi break;; esac done