spty 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/lib/spty/commands/help_command.rb +5 -1
- data/lib/spty/commands/mute_command.rb +15 -0
- data/lib/spty/commands/pause_command.rb +25 -0
- data/lib/spty/commands/play_command.rb +25 -0
- data/lib/spty/commands/unmute_command.rb +15 -0
- data/lib/spty/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9cb0010b9cd30d4267b0ece9f6ab6b5c66610ea
|
4
|
+
data.tar.gz: 0a6d2bef6da0f091d8051d0a2a9f701bc4e0492f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 742a3e5843d973759b473a5e8a0397930e5e121bd77b914b727860315a2bc3aad0d000db34bd76954aa9ae58f76ba0bb8a39bf4452dbe7f15fc57c7e041c29c2
|
7
|
+
data.tar.gz: 3a9167bf075476fe7851598c32367cecb5ca32945f00c39b27c79ec07c39d543860bc34751343247389580086ebbece40c04d1d5790c0f2e22262a7cce7bd7e1
|
data/README.md
CHANGED
@@ -25,6 +25,16 @@ Show current player state
|
|
25
25
|
$ spty state
|
26
26
|
```
|
27
27
|
|
28
|
+
Play the current track
|
29
|
+
```
|
30
|
+
$ spty play
|
31
|
+
```
|
32
|
+
|
33
|
+
Pause the current track
|
34
|
+
```
|
35
|
+
$ spty pause
|
36
|
+
```
|
37
|
+
|
28
38
|
Toggle player play / pause
|
29
39
|
```
|
30
40
|
$ spty toggle
|
@@ -65,6 +75,16 @@ Set the volume level with given number
|
|
65
75
|
$ spty volume [number]
|
66
76
|
```
|
67
77
|
|
78
|
+
Set the volume level to 0
|
79
|
+
```
|
80
|
+
$ spty mute
|
81
|
+
```
|
82
|
+
|
83
|
+
Set the volume level to 60
|
84
|
+
```
|
85
|
+
$ spty unmute
|
86
|
+
```
|
87
|
+
|
68
88
|
## Contributing
|
69
89
|
|
70
90
|
Bug reports and pull requests are welcome on GitHub at
|
@@ -4,7 +4,9 @@ module Spty::Command
|
|
4
4
|
"usage: spty <command> [<args>]\n"\
|
5
5
|
"\n"\
|
6
6
|
"Player specific command\n"\
|
7
|
-
" state Display
|
7
|
+
" state Display the current player state\n"\
|
8
|
+
" play Play the current track\n"\
|
9
|
+
" pause Pause the current track\n"\
|
8
10
|
" toggle Toggle player play or pause\n"\
|
9
11
|
" skip Skip the current track and play the next track\n"\
|
10
12
|
" replay Replay the current track\n"\
|
@@ -12,6 +14,8 @@ module Spty::Command
|
|
12
14
|
" volume up Increase the volume level by 10\n"\
|
13
15
|
" volume down Decrease the volume level by 11\n"\
|
14
16
|
" volume [number] Set the volume level to number\n"\
|
17
|
+
" mute Set the volume level to 0\n"\
|
18
|
+
" unmute Set the volume level to 60\n"\
|
15
19
|
"\n"\
|
16
20
|
"Track specific command\n"\
|
17
21
|
" info Show information for the current track\n"\
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class MuteCommand < BaseCommand
|
3
|
+
ASCRIPT_PLAYER_MUTE = <<-EOL
|
4
|
+
tell application "Spotify"
|
5
|
+
set sound volume to 0
|
6
|
+
end tell
|
7
|
+
EOL
|
8
|
+
def self.call(options, _)
|
9
|
+
return unless running?
|
10
|
+
|
11
|
+
Spty::AppleScriptRunner.call(ASCRIPT_PLAYER_MUTE)
|
12
|
+
puts "Player muted"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class PauseCommand < BaseCommand
|
3
|
+
ASCRIPT_PLAYER_PAUSE = <<-EOL
|
4
|
+
tell application "Spotify"
|
5
|
+
pause
|
6
|
+
end tell
|
7
|
+
EOL
|
8
|
+
def self.call(options, _)
|
9
|
+
return unless running?
|
10
|
+
|
11
|
+
# Get the player state
|
12
|
+
player_state_script = Spty::Command::StateCommand::ASCRIPT_PLAYER_STATE
|
13
|
+
player_state = Spty::AppleScriptRunner.(player_state_script)
|
14
|
+
|
15
|
+
if player_state.strip == 'playing'
|
16
|
+
Spty::AppleScriptRunner.call(ASCRIPT_PLAYER_PAUSE)
|
17
|
+
end
|
18
|
+
|
19
|
+
track_info_script = Spty::Command::InfoCommand::ASCRIPT_TRACK_INFO
|
20
|
+
track_info = Spty::AppleScriptRunner.(track_info_script)
|
21
|
+
|
22
|
+
puts "=> #{track_info.strip} [paused]"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class PlayCommand < BaseCommand
|
3
|
+
ASCRIPT_PLAYER_PLAY = <<-EOL
|
4
|
+
tell application "Spotify"
|
5
|
+
play
|
6
|
+
end tell
|
7
|
+
EOL
|
8
|
+
def self.call(options, _)
|
9
|
+
return unless running?
|
10
|
+
|
11
|
+
# Get the player state
|
12
|
+
player_state_script = Spty::Command::StateCommand::ASCRIPT_PLAYER_STATE
|
13
|
+
player_state = Spty::AppleScriptRunner.(player_state_script)
|
14
|
+
|
15
|
+
if player_state.strip == 'paused'
|
16
|
+
Spty::AppleScriptRunner.call(ASCRIPT_PLAYER_PLAY)
|
17
|
+
end
|
18
|
+
|
19
|
+
track_info_script = Spty::Command::InfoCommand::ASCRIPT_TRACK_INFO
|
20
|
+
track_info = Spty::AppleScriptRunner.(track_info_script)
|
21
|
+
|
22
|
+
puts "=> #{track_info.strip} [playing]"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Spty::Command
|
2
|
+
class UnmuteCommand < BaseCommand
|
3
|
+
ASCRIPT_PLAYER_UNMUTE = <<-EOL
|
4
|
+
tell application "Spotify"
|
5
|
+
set sound volume to 60
|
6
|
+
end tell
|
7
|
+
EOL
|
8
|
+
def self.call(options, _)
|
9
|
+
return unless running?
|
10
|
+
|
11
|
+
Spty::AppleScriptRunner.call(ASCRIPT_PLAYER_UNMUTE)
|
12
|
+
puts "Player unmute"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/spty/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J Shamsul
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,10 +107,14 @@ files:
|
|
107
107
|
- lib/spty/commands/help_command.rb
|
108
108
|
- lib/spty/commands/info_command.rb
|
109
109
|
- lib/spty/commands/launch_command.rb
|
110
|
+
- lib/spty/commands/mute_command.rb
|
111
|
+
- lib/spty/commands/pause_command.rb
|
112
|
+
- lib/spty/commands/play_command.rb
|
110
113
|
- lib/spty/commands/replay_command.rb
|
111
114
|
- lib/spty/commands/skip_command.rb
|
112
115
|
- lib/spty/commands/state_command.rb
|
113
116
|
- lib/spty/commands/toggle_command.rb
|
117
|
+
- lib/spty/commands/unmute_command.rb
|
114
118
|
- lib/spty/commands/version_command.rb
|
115
119
|
- lib/spty/commands/volume_command.rb
|
116
120
|
- lib/spty/version.rb
|