Permalink
Browse files

ad: Config and fav songs

  • Loading branch information...
1 parent 234447c commit 70e4f033c8df8431cf258dfdd0a88bfc0b3de2bc @jpablobr committed May 27, 2012
Showing with 29 additions and 1 deletion.
  1. +8 −0 .playrrc.rb
  2. +21 −1 playr → playr.rb
View
@@ -0,0 +1,8 @@
+# $LOAD_PATH.unshift '/playr/'
+require 'playr'
+Playr::Conf.music_dir = '~/music/'
+Playr::Conf.mpd_dir = '~/.private/.mpd/'
+Playr::Conf.playlists_dir = Playr::Conf.mpd_dir + "playlists/"
+Playr::Conf.playlists = {
+ fav: Playr::Conf.playlists_dir + 'fav.m3u'
+}
View
@@ -1,13 +1,27 @@
#!/usr/bin/env ruby
# coding: utf-8
require 'optparse'
+require 'ostruct'
module Playr
require 'librmpd'
require 'term/ansicolor'
extend Module.new { attr_accessor :out }
+ # ~/.playrrc.rb
+ _user_config_file = ENV['HOME']+'/.playrrc.rb'
+
+ # Defaults
+ Conf ||= OpenStruct.new(music_dir: '~/music/', mpd_dir: '~/.mpd/')
+ Conf.playlists_dir = Conf.mpd_dir + 'playlists/'
+ Conf.playlists = {
+ fav: Conf.playlists_dir + 'fav.m3u'
+ }
+
+ # overrides
+ load _user_config_file if File.exist? _user_config_file
+
class Client
require 'readline'
include Term::ANSIColor
@@ -101,13 +115,19 @@ def remove
`rm #{s}` if File.exist?(s)
end
+ def fav
+ file = Conf.music_dir + @mpd.current_song.fetch('file')
+ `echo #{file} >> #{Conf.playlists[:fav]}`
+ end
+
alias :p :play
alias :c :continue
alias :s :search
alias :h :help
alias :n :next
alias :r :random
alias :v :vol
+ alias :f :fav
alias :m :mute
alias :d :disconnect
alias :ps :pause
@@ -197,7 +217,7 @@ def playlist pl
end
def help cmd
- aliased = cmd[1].nil? ? '' : ' or: '+ green(cmd[1].to_s)
+ aliased = cmd[1].nil? ? '' : ' || '+ green(cmd[1].to_s)
write(blue(cmd[0].to_s) + aliased + "\n")
end

0 comments on commit 70e4f03

Please sign in to comment.