gtk2mp3 1.0.1 → 1.1.0

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
  SHA256:
3
- metadata.gz: ff3ce4cc3415163918519fbeec8cdfa71fcbf340df80bac3ef663b0912ca8efc
4
- data.tar.gz: 8daa2512b2839eaca23f00cf386454c09e64b38af51dc5f9513bf6a1ea624f72
3
+ metadata.gz: 3515c77889dc15cf89235fd164443b80b52f55c1052a63bddffdc3134d1ba930
4
+ data.tar.gz: fdc71a22c0db5e6086d3850f42f77d21103981d8ee24ed56f22413280e245f1a
5
5
  SHA512:
6
- metadata.gz: c2d5fc9e6ce4de2f7a17a3bd40a994bec68f28d26037796e0007a788f5d3bf4d6164f1239f4fe47cee9db3b4166c117eae6c5ccec37902b4f960451d0c9fd1d2
7
- data.tar.gz: d9a193c9d81289aca47834dd9756cebc5a9462e53e01b9e14feed157827a927c78c7a21629074bc91a7f3ee29562a5595b6d3a428df21596725aec5f4815359c
6
+ metadata.gz: 47fc42de3ac52bd3435a5ec08ba9bac4b9acef21e81faf5bbe94c30002e076b4f2ca6e156f610ece4c3037bd7e5ce75c3c60b4bc411b29fbfeb8af23cc8e9a69
7
+ data.tar.gz: c0a5989939c273894e105aa7600574991e2f812b601c52b61aebaea651d59b078f7ff8c3593dd9029d611ce6357a79c8e9b9158c2ff57ee72f41e14173a25219
data/README.md CHANGED
@@ -23,7 +23,6 @@ A "Next!" button gui for MPD/MPC.
23
23
  Options:
24
24
  -h --help
25
25
  -v --version
26
- -f --force Skips mpd prechecks
27
26
  --noinit Don't reset the playlist
28
27
  # Notes #
29
28
  # Requires MPD/MPC.
data/bin/gtk2mp3 CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'help_parser'
3
3
 
4
4
  module Gtk2Mp3
5
- VERSION = '1.0.1'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  OPTIONS = HelpParser[Gtk2Mp3::VERSION,<<HELP]
8
8
  Usage:
@@ -10,36 +10,30 @@ Usage:
10
10
  Options:
11
11
  -h --help
12
12
  -v --version
13
- -f --force \tSkips mpd prechecks
14
13
  --noinit \tDon't reset the playlist
15
14
  # Notes #
16
15
  # Requires MPD/MPC.
17
16
  # See https://www.musicpd.org/clients/mpc/.
18
17
  HELP
19
18
 
20
- unless OPTIONS.force?
21
- unless ['/etc/mpd.conf','~/.mpdconf'].all?{|_|File.exist? File.expand_path _}
22
- $stderr.puts 'Missing /etc/mpd.conf and/or ~/.mpdconf'
23
- exit 72 # EX_OSFILE
24
- end
19
+ unless OPTIONS.noinit?
25
20
  unless system 'ps -C mpd'
26
21
  unless system 'mpd'
27
22
  $stderr.puts 'Could not start the mpd daemon.'
28
23
  exit 69 # EX_UNAVAILABLE
29
24
  end
30
25
  end
31
- end
32
-
33
- unless OPTIONS.noinit?
34
- unless system 'mpc clear' and system 'mpc ls | mpc add'
26
+ unless system 'mpc --wait update' and
27
+ system 'mpc clear' and
28
+ system 'mpc ls | mpc add' and
29
+ system 'mpc consume off' and
30
+ system 'mpc repeat off' and
31
+ system 'mpc random on' and
32
+ system 'mpc single on'
35
33
  $stderr.puts 'Could not initialize mpd\'s playlist'
36
34
  exit 76 # EX_PROTOCOL
37
35
  end
38
- system 'mpc random on'
39
- system 'mpc consume off'
40
- system 'mpc repeat on'
41
36
  end
42
37
 
43
38
  require 'gtk2mp3'
44
39
  Gtk3App.main(Gtk2Mp3)
45
- system 'mpc stop'
data/data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.0
@@ -4,6 +4,8 @@ module Gtk2Mp3
4
4
  CONFIG = {
5
5
  PLAYED: 30,
6
6
  DBM: "#{XDG['CACHE']}/gtk3app/gtk2mp3/dbm.json",
7
+ BUTTONS: [:next_button!, :stop_button!],
8
+ ITEMS: [:next_item!, :stop_item!],
7
9
  thing: {
8
10
  HelpFile: 'https://github.com/carlosjhr64/gtk2mp3',
9
11
  Logo: "#{XDG['DATA']}/gtk3app/gtk2mp3/logo.png",
data/lib/gtk2mp3/gui.rb CHANGED
@@ -20,7 +20,7 @@ module Gtk2Mp3
20
20
  end
21
21
 
22
22
  def next_song
23
- @label.text = @playing = ID[`mpc searchplay filename #{random_song.shellescape}`]
23
+ @label.text = @playing = ID[`mpc -f '%file%' searchplay filename #{random_song.shellescape}`]
24
24
  end
25
25
 
26
26
  def down(id)
@@ -43,12 +43,7 @@ module Gtk2Mp3
43
43
  up(@skipped) if Time.now-@time<CONFIG[:PLAYED]
44
44
  elsif @played
45
45
  down(@played)
46
- @playing = ID[`mpc current`]
47
- if play?(@playing)
48
- @label.text = @playing
49
- else
50
- next_song
51
- end
46
+ next_song
52
47
  end
53
48
  @time,@played,@skipped = Time.now,@playing,nil
54
49
  end
@@ -75,23 +70,25 @@ module Gtk2Mp3
75
70
  end
76
71
 
77
72
  def initialize(program)
78
- window,minime,menu = program.window,program.mini_menu,program.app_menu
79
- @db = JSON.parse File.read(CONFIG[:DBM])
80
- window.signal_connect('delete-event'){File.write(CONFIG[:DBM], JSON.pretty_generate(@db))}
81
-
82
73
  # Build
74
+ window,minime,menu = program.window,program.mini_menu,program.app_menu
83
75
  vbox = Such::Box.new(window, :VBOX)
84
76
  hbox = Such::Box.new(vbox, :HBOX)
85
- Such::Button.new(hbox, :next_button!){next_song!}
86
- Such::Button.new(hbox, :stop_button!){stop_song!}
77
+ Such::Button.new(hbox, :next_button!){next_song!} if CONFIG[:BUTTONS].include?(:next_button!)
78
+ Such::Button.new(hbox, :stop_button!){stop_song!} if CONFIG[:BUTTONS].include?(:stop_button!)
87
79
  @label = Such::Label.new(vbox)
88
80
  menu.each{|_|_.destroy if _.key==:fs! or _.key==:help!}
89
81
  minime.each{|_|_.destroy}
90
- minime.append_menu_item(:stop_item!){stop_song!}
91
- minime.append_menu_item(:next_item!){next_song!}
82
+ minime.append_menu_item(:stop_item!){stop_song!} if CONFIG[:ITEMS].include?(:stop_item!)
83
+ minime.append_menu_item(:next_item!){next_song!} if CONFIG[:ITEMS].include?(:next_item!)
92
84
 
93
85
  # Inits
86
+ @db = JSON.parse File.read(CONFIG[:DBM])
94
87
  @list = `mpc listall`.lines.map{|_|ID[_]}.uniq
88
+ # A fuzzy delete of possibly gone keys...
89
+ @db.keys.each{|id| down(id) unless @list.include?(id)}
90
+
91
+ # Run
95
92
  @skipped=@playing=nil
96
93
  next_song!
97
94
  @time,@played = Time.now,@playing
@@ -99,7 +96,10 @@ module Gtk2Mp3
99
96
  sleep(1) # mpd needs a little time to settle
100
97
  mpc_idle_player
101
98
  end
102
-
99
+ window.signal_connect('delete-event') do
100
+ stop_song!
101
+ File.write(CONFIG[:DBM], JSON.pretty_generate(@db))
102
+ end
103
103
  window.show_all
104
104
  end
105
105
  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.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-04 00:00:00.000000000 Z
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: help_parser
@@ -87,7 +87,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements:
90
- - 'mpc: off'
91
90
  - 'ruby: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]'
92
91
  - 'mpd: Music Player Daemon 0.20.10'
93
92
  rubyforge_project: