-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.rb
executable file
·32 lines (28 loc) · 1.15 KB
/
event.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/ruby
#event-command script based on this post: http://francojc.wordpress.com/2011/12/03/pianobar-on-mac-osx/
require 'net/telnet'
trigger = ARGV.shift
# This is the start up settings for my Yamaha receiver:
if trigger == 'userlogin'
webserver = Net::Telnet::new('Host' => '10.0.1.9', 'Port' => 50000, 'Wait-time' => 0.1, 'Prompt' => /.*/, 'Telnet-mode' => false)
input = "@MAIN:INP=HDMI3"
power = "@MAIN:PWR=On"
vol = "@MAIN:VOL=-45.5"
webserver.cmd(power)
sleep 3
webserver.cmd(input)
webserver.cmd(vol)
end
if trigger == 'songstart'
songinfo = {}
STDIN.each_line { |line| songinfo.store(*line.chomp.split('=',2))}
`rm ~/Ruby/sinPan/public/art.jpg 2> /dev/null`
`wget -q --directory-prefix=$HOME/Ruby/sinPan/public/ "#{songinfo['coverArt']}"`
img=`ls $HOME/Ruby/sinPan/public/`
`mv $HOME/Ruby/sinPan/public/*.jpg $HOME/Ruby/sinPan/public/art.jpg`
title=songinfo['title']
artist=songinfo['artist']
`echo "<link href="txtstyle.css" rel="stylesheet" type="text/css" />" > $HOME/Ruby/sinPan/public/song.html`
`echo "#{title} by #{artist}" >> $HOME/Ruby/sinPan/public/song.html`
@songInfo="#{songinfo['title']}\nby #{songinfo['artist']}"
end