1 # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 require 'amazing/widget'
16 require 'amazing/proc_file'
21 description "Music On Console status"
22 option :mocp, "Path to mocp program", "mocp"
23 field :state, "Play state, :playing, :paused or :stopped"
24 field :file, "Playing file"
25 field :title, "Title as seen by MOC"
26 field :artist, "Artist name"
27 field :song_title, "Song title"
28 field :album, "Album of song"
29 field :total_time, "Total length of song"
30 field :time_left, "Time left of playing song"
31 field :total_sec, "Total length of song in seconds"
32 field :current_time, "Current position in playing song"
33 field :current_sec, "Current position in playing song in seconds"
34 field :bitrate, "Song bitrate"
35 field :rate, "Song sample rate"
40 "#@artist - #@song_title"
42 "#@artist - #@song_title [paused]"
49 moc = ProcFile.new(IO.popen("#@mocp --info"))[0]
50 @state = {:play => :playing, :pause => :paused, :stop => :stopped}[moc["State"].downcase.to_sym]
53 @artist = moc["Artist"]
54 @song_title = moc["SongTitle"]
56 @total_time = moc["TotalTime"]
57 @time_left = moc["TimeLeft"]
58 @total_sec = moc["TotalSec"].to_i
59 @current_time = moc["CurrentTime"]
60 @current_sec = moc["CurrentSec"].to_i
61 @bitrate = moc["Bitrate"]