Class: Spty::Command::BaseCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/spty/commands/base_command.rb

Constant Summary collapse

ASCRIPT_PLAYER_DETECT =

Check if the application is running

<<-EOL
  if application "Spotify" is running then
    return "Running"
  else
    return "Not running"
  end if
EOL

Class Method Summary collapse

Class Method Details

.running?(show_mesg: true) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/spty/commands/base_command.rb', line 11

def self.running?(show_mesg: true)
  player_running = Spty::AppleScriptRunner.(ASCRIPT_PLAYER_DETECT)
  return true if player_running.strip == 'Running'

  if show_mesg
    output = "player not running\n"\
             "to launch Spotify player, use: spty launch"

    puts output
  end

  false
end