muzak 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77d8a106e1b6479194813a854372b1623f3bac7b
4
- data.tar.gz: 4eb72201a9378ba5ee92c43668009ab314c1e1ff
3
+ metadata.gz: 3338e70c6fa7dc2320227d38b13c944e7041f6a1
4
+ data.tar.gz: 38ba81685e38e29ad8bb4ce55897d2aa12d30d98
5
5
  SHA512:
6
- metadata.gz: e94f921353d774220411452b8ecd4a49003792d0f0a7a3a96d8cbda3d6d92518e6b50a2c46d1afaf8a7050136ffadc0a069c08857ee0e717bc589e9613262f5d
7
- data.tar.gz: 8bb4da0e3c69ad6e319b46db29a21031aec4d55ce6aef2b4ae33dca91dd4d44c7ec488f151b382485a29da7cdfa1e7be96fb1dca5135c5602c0412e3d6a397c9
6
+ metadata.gz: ccbf8b59dc56189f0805e8c382f54a91d6a2e646802d2e920402e7a1387622832446415419ca22f73547bca00fe43a3bf41cead6de8feb832df678114f3790b8
7
+ data.tar.gz: fb3b416d63a3ea9517b488881d5f94301d2ce9958ff8b00a1fb7dde8e2b5c93a6b1d19f4a6b4d6acad5cef2fc3463fb738395f8c64ab0367962052c6d30c92e8
data/CONFIGURATION.md CHANGED
@@ -120,6 +120,17 @@ initialize and control.
120
120
  The short names of supported players can be found in
121
121
  {Muzak::Player::PLAYER_MAP}.
122
122
 
123
+ ### `mpv-no-art`
124
+
125
+ *Optional.*
126
+
127
+ *Default:* `false`
128
+
129
+ If `mpv-no-art: true` is set in the configuration file *and* `player: mpv` is
130
+ set, then `mpv` will be instructed to disable all video output entirely.
131
+ This option is primarily useful in conjunction with plugins that provide
132
+ album art display, or for making Muzak entirely non-graphical.
133
+
123
134
  ### `jukebox-size`
124
135
 
125
136
  *Mandatory.*
@@ -139,7 +150,7 @@ by default with the `jukebox` size.
139
150
  album art, in "WxH" format. If not set, album art will be displayed at
140
151
  any size the player pleases.
141
152
 
142
- It's entirely up to the user's player to obey this value.
153
+ It's entirely up to the user's player and/or plugins to obey this value.
143
154
 
144
155
  ### `autoplay`
145
156
 
@@ -195,3 +206,14 @@ listen on.
195
206
  `dmenu-exec: <command args...>` can be used to alter `muzak-dmenu`'s
196
207
  invocation of `dmenu`. It can also be used to substitute a dmenu-compatible
197
208
  prompt like `rofi -dmenu`.
209
+
210
+ ### `dmenu-lines-exec`
211
+
212
+ *Optional.*
213
+
214
+ *No default.*
215
+
216
+ `dmenu-lines-exec: <command args>` can be used to alter `muzak-dmenu`'s
217
+ invocation of `dmenu` when showing selections on multiple lines (e.g.,
218
+ when offering albums after `enqueue-album` has been selected). It can be
219
+ used to substitute a dmenu-compatible prompt like `rofi -dmenu`.
data/bin/muzak-dmenu CHANGED
@@ -2,29 +2,62 @@
2
2
 
3
3
  require "muzak"
4
4
  require "socket"
5
+ require "json"
6
+ require "open3"
7
+
8
+ DMENU_EXEC = Muzak::Config.dmenu_exec || "dmenu"
9
+ DMENU_LINES_EXEC = Muzak::Config.dmenu_lines_exec || "dmenu -l 10"
5
10
 
6
11
  def fatal(msg)
7
12
  STDERR.puts "Fatal: #{msg}"
8
13
  exit 1
9
14
  end
10
15
 
11
- def dmenu(options)
12
- dmenu = Muzak::Config.dmenu_exec || "dmenu"
16
+ def dmenu(options, lines: false)
17
+ dmenu_cmd = lines ? DMENU_LINES_EXEC : DMENU_EXEC
13
18
  opts = options.join("\n")
14
- `printf "#{opts}" | #{dmenu}`
19
+ Open3.popen2(dmenu_cmd) do |stdin, stdout|
20
+ stdin.puts opts
21
+ stdin.close
22
+ stdout.gets
23
+ end
15
24
  end
16
25
 
17
- begin
18
- server_host = Muzak::Config.daemon_host
19
- server_port = Muzak::Config.daemon_port
20
- sock = TCPSocket.new server_host, server_port
21
- rescue
22
- fatal "Is muzakd running?"
26
+ def muzak_cmd(command)
27
+ begin
28
+ server_host = Muzak::Config.daemon_host
29
+ server_port = Muzak::Config.daemon_port
30
+ sock = TCPSocket.new server_host, server_port
31
+ rescue
32
+ fatal "Is muzakd running?"
33
+ end
34
+
35
+ sock.puts command unless command.empty?
36
+ response = sock.gets
37
+ sock.close
38
+
39
+ JSON.parse(response)
23
40
  end
24
41
 
25
42
  command = dmenu Muzak::Cmd.commands
26
43
 
27
- sock.puts command unless command.empty?
28
- puts sock.gets
44
+ exit if command.nil? || command.empty?
45
+
46
+ arguments = case command.chomp
47
+ when "enqueue-artist"
48
+ artists = muzak_cmd("list-artists")["response"]["data"]["artists"]
49
+ dmenu(artists, lines: true)
50
+ when "enqueue-album"
51
+ albums = muzak_cmd("list-albums")["response"]["data"]["albums"]
52
+ dmenu(albums, lines: true)
53
+ when "enqueue-playlist"
54
+ playlists = muzak_cmd("list-playlists")["response"]["data"]["playlists"]
55
+ dmenu(playlists, lines: true)
56
+ end
57
+
58
+ command = "#{command.chomp} #{arguments}" if arguments
59
+
60
+ puts command
61
+
62
+ muzak_cmd command
29
63
 
30
- sock.close
data/bin/muzak-index CHANGED
@@ -22,8 +22,8 @@ def help
22
22
  --version, -v Print version information
23
23
 
24
24
  Arguments:
25
- [tree] The filesystem tree to index (default: ~/music)
26
- [index] The saved index (default: ~/.config/muzak/index.dat)
25
+ [tree] The filesystem tree to index (default: #{Muzak::Config.music})
26
+ [index] The saved index (default: #{Muzak::Config::INDEX_FILE})
27
27
  EOS
28
28
 
29
29
  exit
data/lib/muzak.rb CHANGED
@@ -12,5 +12,5 @@ require_relative "muzak/instance"
12
12
  # The primary namespace for muzak.
13
13
  module Muzak
14
14
  # Muzak's current version
15
- VERSION = "0.3.7".freeze
15
+ VERSION = "0.3.8".freeze
16
16
  end
@@ -65,7 +65,11 @@ module Muzak
65
65
 
66
66
  plugins.each do |plugin|
67
67
  Thread.new do
68
- plugin.send(type, *args)
68
+ begin
69
+ plugin.send(type, *args)
70
+ rescue => e
71
+ error "something went wrong in #{plugin.class.plugin_name}: #{e}"
72
+ end
69
73
  end
70
74
  end
71
75
  end
@@ -25,11 +25,7 @@ module Muzak
25
25
 
26
26
  debug "activating #{self.class}"
27
27
 
28
- mpv_args = [
29
- # if i get around to separating album art from playback,
30
- # these two flags disable mpv's video output entirely
31
- # "--no-force-window",
32
- # "--no-video",
28
+ args = [
33
29
  # there's also this, which (might) also work
34
30
  # "--audio-display=no",
35
31
  "--no-osc",
@@ -39,14 +35,16 @@ module Muzak
39
35
  "--load-scripts=no", # autoload and other scripts with clobber our mpv management
40
36
  ]
41
37
 
42
- mpv_args << "--geometry=#{Config.art_geometry}" if Config.art_geometry
38
+ args.concat ["--no-force-window", "--no-video"] if Config.mpv_no_art
39
+
40
+ args << "--geometry=#{Config.art_geometry}" if Config.art_geometry
43
41
 
44
42
  # this is an experimental flag, but it could improve
45
43
  # muzak's load times substantially when used with a network
46
44
  # mounted music library
47
- mpv_args << "--prefetch-playlist" if ::MPV::Server.has_flag?("--prefetch-playlist")
45
+ args << "--prefetch-playlist" if ::MPV::Server.has_flag?("--prefetch-playlist")
48
46
 
49
- @mpv = ::MPV::Session.new(user_args: mpv_args)
47
+ @mpv = ::MPV::Session.new(user_args: args)
50
48
  @mpv.callbacks << ::MPV::Callback.new(self, :dispatch_event!)
51
49
 
52
50
  instance.event :player_activated
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muzak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-04 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: taglib-ruby