Here are some scripts that can be used with pianobar
brew install pianobar
You'll also need the firebase gem if you want to save to firebase
gem install firebase
You'll need to modify the firebase url and the paths
#!/usr/bin/ruby | |
require 'cgi' | |
trigger = ARGV.shift | |
if trigger == 'songstart' | |
songinfo = {} | |
STDIN.each_line { |line| songinfo.store(*line.chomp.split('=', 2))} | |
File.open('/Users/adamharris/.config/pianobar/nowplaying', 'w') do |f2| | |
f2.puts "#{songinfo['artist']}\n#{songinfo['album']}\n#{songinfo['title']}" | |
end | |
system("ruby pianobarFirebase.rb") | |
end |
#!/usr/bin/ruby | |
require 'cgi' | |
trigger = ARGV.shift | |
if trigger == 'songstart' | |
songinfo = {} | |
STDIN.each_line { |line| songinfo.store(*line.chomp.split('=', 2))} | |
File.open('/Users/adamharris/.config/pianobar/nowplaying', 'w') do |f2| | |
f2.puts "#{songinfo['artist']}\n#{songinfo['album']}\n#{songinfo['title']}" | |
end | |
system("ruby pianobarFirebase.rb") | |
end |
#!/usr/bin/ruby | |
require 'cgi' | |
require 'firebase' | |
title = "" | |
artist = "" | |
album = "" | |
flag = ARGV[0] | |
counter = 1 | |
file = File.new('/Users/adamharris/.config/pianobar/nowplaying', 'r') | |
while (line = file.gets) | |
if counter == 1 | |
artist = line | |
end | |
if counter == 2 | |
album = line | |
end | |
if counter == 3 | |
title = line | |
end | |
counter = counter + 1 | |
end | |
base_uri = 'https://blazing-fire-5020.firebaseio.com/' | |
firebase = Firebase::Client.new(base_uri) | |
firebase.push("songs", { :artist => artist, :title => title, :album => album}) |
#!/usr/bin/ruby | |
title = "" | |
artist = "" | |
album = "" | |
flag = ARGV[0] | |
counter = 1 | |
file = File.new('/Users/adamharris/.config/pianobar/nowplaying', 'r') | |
while (line = file.gets) | |
if counter == 1 | |
artist = line | |
end | |
if counter == 2 | |
album = line | |
end | |
if counter == 3 | |
title = line | |
end | |
counter = counter + 1 | |
end | |
if flag == "--notification" || flag == "-n" | |
`terminal-notifier -message "Artist: #{artist}\rAlbum: #{album}" -title "#{title}"` | |
else | |
puts "Song: #{title}\rArtist: #{artist}\rAlbum: #{album}" | |
end |