this repo has no description
dotfiles
at main 90 lines 1.2 kB view raw
1class Spotify 2 def [](_) 3 false 4 end 5 6 def available 7 run('status') != 'Not available' 8 end 9 10 def status 11 run('status').downcase.to_sym 12 end 13 14 def play 15 run 'play' 16 end 17 18 def pause 19 run 'pause' 20 end 21 22 def stop 23 run 'stop' 24 end 25 26 def toggle 27 run 'play-pause' 28 end 29 30 def next 31 run 'next' 32 end 33 34 def previous 35 run 'previous' 36 end 37 38 def long 39 data = metadata 40 41 return file if data[:title].empty? 42 43 output = data[:title] 44 45 output = "#{data[:artist]} - #{output}" unless data[:artist].empty? 46 output = "#{output} (#{data[:album]}" unless data[:album].empty? 47 48 output 49 end 50 51 def short 52 metadata[:title] 53 end 54 55 def file 56 run 'metadata mpris:trackid' 57 end 58 59 def to_s 60 data = metadata 61 return data[:title] if data[:artist].empty? 62 "#{data[:artist]} - #{data[:title]}" 63 end 64 65 private 66 67 def run(command) 68 `playerctl -p spotify #{command}`.strip 69 end 70 71 def artist 72 run 'metadata artist' 73 end 74 75 def title 76 run 'metadata title' 77 end 78 79 def album 80 run 'metadata album' 81 end 82 83 def metadata 84 { 85 artist: artist.strip, 86 title: title.strip, 87 album: album.strip 88 } 89 end 90end