spotify-dbus 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/spotify-dbus +18 -8
  2. data/lib/spotify-dbus.rb +2 -2
  3. metadata +3 -3
data/bin/spotify-dbus CHANGED
@@ -1,13 +1,23 @@
1
1
  #!/usr/bin/env ruby
2
- #require 'spotify-dbus'
3
- require File.join(File.dirname(__FILE__), '../lib/spotify-dbus.rb')
2
+ require 'spotify-dbus'
4
3
 
4
+ def error msg
5
+ puts msg
6
+ exit false
7
+ end
5
8
 
6
- cmd = ARGV.pop
7
-
8
- begin
9
- Spotify.player.send(cmd) if Spotify.player.methods[cmd]
10
- rescue
11
- puts "Spotify is not running!"
9
+ if ARGV.size > 0
10
+ begin
11
+ cmd = ARGV.pop
12
+ if Spotify.player.methods[cmd]
13
+ Spotify.player.send(cmd)
14
+ else
15
+ error "Invalid command!"
16
+ end
17
+ rescue
18
+ error "Spotify is not running!"
19
+ end
20
+ else
21
+ error "No command given!"
12
22
  end
13
23
 
data/lib/spotify-dbus.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  require 'dbus'
2
2
 
3
3
  module Spotify
4
- def player
4
+ def self.player
5
5
  @player ||= player_object
6
6
  end
7
7
 
8
8
  protected
9
9
 
10
- def player_object
10
+ def self.player_object
11
11
  dbus = DBus::SessionBus.instance
12
12
  service = dbus.service('org.mpris.MediaPlayer2.spotify')
13
13
  object = service.object('/org/mpris/MediaPlayer2')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify-dbus
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby-dbus
17
- requirement: &19886080 !ruby/object:Gem::Requirement
17
+ requirement: &24723220 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: 0.6.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *19886080
25
+ version_requirements: *24723220
26
26
  description: Simple module and bin for Spotify DBus interfacing
27
27
  email: mikeycgto@gmail.com
28
28
  executables: