stevetunes/mpc_shim.rb
2021-12-22 14:48:31 -05:00

54 lines
795 B
Ruby

class MpcShim
def update()
`mpc #{host_arg} update`
end
def clear()
`mpc #{host_arg} clear`
end
def play()
`mpc #{host_arg} play`
end
def stop()
`mpc #{host_arg} stop`
end
def next()
`mpc #{host_arg} next`
end
def reset()
`mpc #{host_arg} clear`
`mpc #{host_arg} add /`
`mpc #{host_arg} shuffle`
`mpc #{host_arg} repeat`
end
def update()
`mpc #{host_arg} update`
end
def toggle()
`mpc #{host_arg} toggle`
end
def add(filename = nil)
if filename == nil
`mpc #{host_arg} add /`
else
`mpc #{host_arg} add #{filename}`
end
return $?.success?
end
def initialize(hostname=:localhost)
if hostname != :localhost
@host_arg = "--host #{hostname} "
end
true
end
end