From 490b1b13f014030a580dcef0f12bb9274df64a94 Mon Sep 17 00:00:00 2001 From: abuisman Date: Fri, 6 Apr 2012 11:35:40 -0300 Subject: [PATCH] The mpg123 client is now also able to return the current volume level correctly. Tested on CentOS. --- lib/play/clients/mpg123_client.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/play/clients/mpg123_client.rb b/lib/play/clients/mpg123_client.rb index cfff71ff..049ca9d4 100644 --- a/lib/play/clients/mpg123_client.rb +++ b/lib/play/clients/mpg123_client.rb @@ -62,5 +62,14 @@ def self.say(msg) def self.volume=(volume) system "amixer set Master #{volume}% > /dev/null 2>&1" end + + # Get the current volume level + # + # Returns the current volume from 0 to 100 + def self.volume + vol = `amixer get Master`.scan(/([0-9]+)%/).first.last + vol.to_i + end + end end