gtk2mp3 1.5.0 → 2.5.191217

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4f79f5bc2924956a93650f0a670b8bc7b488d7cc569ee791f2917ba31e18bc1
4
- data.tar.gz: 66280432b988ad1434b31d6f05c5b7ea170b337c1e2ba65a981ee7e3d39a612a
3
+ metadata.gz: 44f275e94c4638c8571bc8f08aff3b3530fb880fdc618ff5db7d3127d74be392
4
+ data.tar.gz: ecb239912c273b285001c0ad0794543647703d4d5d7760ecd66dda86eb694f83
5
5
  SHA512:
6
- metadata.gz: 01d6edc0a0be541ca19846b33073e4c9e5691435888c2c898315ab8686e55eadcca7193d4a01a25de0d5ac1029182bbecdb2e6737362e7d700ef2eb38f50d95c
7
- data.tar.gz: 409c5d5283188ca8c2e5229b0fdf585290c88564245b3b070277777fb5eed4c955e5aa63b58e82fc72fe692a5a0f321e655068e271ca11b761c31fc34efb0ecc
6
+ metadata.gz: f8396b6d71a498084af8a5fd1025974a3cccbb100ff87e4a64de8332b6b5bc33cf84a7039de2dbf356e6c67576a9d1d9209b04df609205e6ec775539d3a05377
7
+ data.tar.gz: 1c01f0c6edca39f25258b261b983fc340ae41434c65369273b87872eecefb93dbb536c8fd4ef1cae051e0de29a048c0c6deb6b6bad3e9a9c5c85e8c65e4fa823
data/README.md CHANGED
@@ -24,8 +24,11 @@ A "Next!" button gui for MPD/MPC.
24
24
  -h --help
25
25
  -v --version
26
26
  --noinit Don't reset the playlist
27
+ -V --verbose
27
28
  # Notes #
28
29
  # Signal USR1 will trigger Next! song.
30
+ # Signal USR2 will trigger Stop song.
31
+ # Signal TERM will quit.
29
32
  # Requires MPD/MPC.
30
33
  # See https://www.musicpd.org/clients/mpc/.
31
34
 
@@ -1,41 +1,43 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'help_parser'
3
- require 'gtk2mp3'
4
3
 
5
- OPTIONS = HelpParser[Gtk2Mp3::VERSION, <<HELP]
4
+ OPTIONS = HelpParser['2.5.191217', <<HELP]
6
5
  Usage:
7
6
  gtk2mp3 [:options+]
8
7
  Options:
9
8
  -h --help
10
9
  -v --version
11
10
  --noinit \tDon't reset the playlist
11
+ -V --verbose
12
12
  # Notes #
13
13
  # Signal USR1 will trigger Next! song.
14
+ # Signal USR2 will trigger Stop song.
15
+ # Signal TERM will quit.
14
16
  # Requires MPD/MPC.
15
17
  # See https://www.musicpd.org/clients/mpc/.
16
18
  HELP
17
19
 
20
+ TO_DEV_NULL = OPTIONS.verbose? ? '' : '> /dev/null'
18
21
  unless OPTIONS.noinit?
19
- unless system 'ps -C mpd'
20
- unless system 'mpd'
22
+ # check if mpd is already running
23
+ unless system "ps -C mpd #{TO_DEV_NULL}"
24
+ unless system "mpd #{TO_DEV_NULL}"
21
25
  $stderr.puts 'Could not start the mpd daemon.'
22
26
  exit 69 # EX_UNAVAILABLE
23
27
  end
24
28
  end
25
- unless system "mpc --wait update" and
26
- system "mpc clear" and
27
- system "mpc ls | mpc add" and
28
- system "mpc consume off" and
29
- system "mpc repeat off" and
30
- system "mpc random on" and
31
- system "mpc single on"
29
+ unless system "mpc --wait update #{TO_DEV_NULL}" and
30
+ system "mpc clear #{TO_DEV_NULL}" and
31
+ system "mpc ls | mpc add" and
32
+ system "mpc consume off #{TO_DEV_NULL}" and
33
+ system "mpc repeat off #{TO_DEV_NULL}" and
34
+ system "mpc random on #{TO_DEV_NULL}" and
35
+ system "mpc single on #{TO_DEV_NULL}"
32
36
  $stderr.puts 'Could not initialize mpd\'s playlist'
33
37
  exit 76 # EX_PROTOCOL
34
38
  end
35
39
  end
36
40
 
37
- Gtk2Mp3.requires
38
- Signal.trap :USR1 do
39
- Gtk2Mp3.next!(true)
40
- end
41
+ require 'gtk2mp3'
42
+ [:USR1,:USR2,:TERM].each{|_|Signal.trap(_){Gtk2Mp3.signal!(_)}}
41
43
  Gtk3App.main(Gtk2Mp3)
@@ -1 +1 @@
1
- 1.5.0
1
+ 2.5.191217
@@ -1,18 +1,32 @@
1
- module Gtk2Mp3
2
- VERSION = '1.5.0'
1
+ require 'json'
2
+ require 'shellwords'
3
3
 
4
- def self.requires
5
- # This is a Gtk3App.
6
- require 'gtk3app'
4
+ # This is a Gtk3App.
5
+ require 'gtk3app'
6
+ module Gtk3App
7
+ # Monkey patching a missing feature
8
+ def Gtk3App.quit!
9
+ @program.quit!
10
+ end
11
+ end
7
12
 
8
- # Standard Libraries
9
- require 'json'
10
- require 'shellwords'
13
+ module Gtk2Mp3
14
+ VERSION = '2.5.191217'
11
15
 
12
- # This Gem.
13
- require_relative 'gtk2mp3/config.rb'
14
- require_relative 'gtk2mp3/gui.rb'
16
+ @signal = nil
17
+ def Gtk2Mp3.signal!(q=nil)
18
+ if q
19
+ @signal = q
20
+ elsif @signal
21
+ signal,@signal = @signal,nil
22
+ return signal
23
+ end
24
+ return nil
15
25
  end
26
+
27
+ # This Gem.
28
+ require_relative 'gtk2mp3/config.rb'
29
+ require_relative 'gtk2mp3/gui.rb'
16
30
  end
17
31
 
18
32
  # Requires:
@@ -20,6 +20,7 @@ module Gtk2Mp3
20
20
  STOP: [label: 'Stop'],
21
21
  stop_button!: [:STOP, 'clicked'],
22
22
  stop_item!: [:STOP, 'activate'],
23
+ id_label!: [set_selectable: true],
23
24
  VBOX: [:vertical],
24
25
  HBOX: [:horizontal],
25
26
  about_dialog: {
@@ -3,17 +3,6 @@ module Gtk2Mp3
3
3
  GUI.new(program)
4
4
  end
5
5
 
6
- @next = false
7
- def Gtk2Mp3.next!(q=false)
8
- if q
9
- @next = true
10
- elsif @next
11
- @next = false
12
- return true
13
- end
14
- return false
15
- end
16
-
17
6
  class GUI
18
7
  MUTEX = Mutex.new
19
8
  ID = lambda{|_|File.basename(_.strip.split(/\n/).first.strip,'.*')}
@@ -31,9 +20,12 @@ module Gtk2Mp3
31
20
  end
32
21
 
33
22
  def next_song
34
- @label.text = @playing = ID[`mpc -f '%file%' searchplay filename #{random_song.shellescape}`]
23
+ id = random_song
24
+ @label.text = @playing = ID[`mpc -f '%file%' searchplay filename #{id.shellescape}`]
35
25
  end
36
26
 
27
+ # decrementing count makes the id
28
+ # more likely to be played
37
29
  def down(id)
38
30
  if count=@db[id]
39
31
  count -= 1
@@ -45,6 +37,8 @@ module Gtk2Mp3
45
37
  end
46
38
  end
47
39
 
40
+ # incrementing count makes the id
41
+ # less likely to be played
48
42
  def up(id)
49
43
  @db[id] = @db[id].to_i+1
50
44
  end
@@ -62,7 +56,7 @@ module Gtk2Mp3
62
56
 
63
57
  def mpc_idle_player
64
58
  loop do
65
- system 'mpc idle player'
59
+ system "mpc idle player #{TO_DEV_NULL}"
66
60
  MUTEX.synchronize{db_update}
67
61
  end
68
62
  end
@@ -77,7 +71,7 @@ module Gtk2Mp3
77
71
  def stop_song!
78
72
  MUTEX.synchronize do
79
73
  @skipped = @playing = @played = nil
80
- system 'mpc stop'
74
+ system "mpc stop #{TO_DEV_NULL}"
81
75
  end
82
76
  end
83
77
 
@@ -88,7 +82,7 @@ module Gtk2Mp3
88
82
  hbox = Such::Box.new(vbox, :HBOX)
89
83
  Such::Button.new(hbox, :next_button!){next_song!} if CONFIG[:BUTTONS].include?(:next_button!)
90
84
  Such::Button.new(hbox, :stop_button!){stop_song!} if CONFIG[:BUTTONS].include?(:stop_button!)
91
- @label = Such::Label.new(vbox)
85
+ @label = Such::Label.new(vbox, :id_label!)
92
86
  menu.each{|_|_.destroy if _.key==:fs! or _.key==:help!}
93
87
  minime.each{|_|_.destroy}
94
88
  minime.add_menu_item(:stop_item!){stop_song!} if CONFIG[:ITEMS].include?(:stop_item!)
@@ -111,8 +105,15 @@ module Gtk2Mp3
111
105
  window.show_all
112
106
 
113
107
  # Handle Signal.trap
114
- GLib::Timeout.add(750) do
115
- next_song! if Gtk2Mp3.next!
108
+ GLib::Timeout.add(500) do
109
+ case Gtk2Mp3.signal!
110
+ when :USR1
111
+ next_song!
112
+ when :USR2
113
+ stop_song!
114
+ when :TERM
115
+ Gtk3App.quit!
116
+ end
116
117
  true # repeat
117
118
  end
118
119
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtk2mp3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.5.191217
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-15 00:00:00.000000000 Z
11
+ date: 2019-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: help_parser