Class: Spty::Command::InfoCommand

Inherits:
BaseCommand show all
Defined in:
lib/spty/commands/info_command.rb

Constant Summary collapse

ASCRIPT_TRACK_INFO =
<<-EOL
  tell application "Spotify"
    set currentTrack to name of current track as string
    set currentArtist to artist of current track as string

    return currentTrack & " - " & currentArtist
  end tell
EOL

Constants inherited from BaseCommand

BaseCommand::ASCRIPT_PLAYER_DETECT

Class Method Summary collapse

Methods inherited from BaseCommand

running?

Class Method Details

.call(_, _command = 'info') ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/spty/commands/info_command.rb', line 11

def self.call(_, _command = 'info')
  return unless running?

  track_info = Spty::AppleScriptRunner.(ASCRIPT_TRACK_INFO)
  player_state_script = Spty::Command::StateCommand::ASCRIPT_PLAYER_STATE
  player_state = Spty::AppleScriptRunner.(player_state_script)

  puts "=> #{track_info.strip} [#{player_state.strip}]"
end