Compare commits
No commits in common. "127b8b32f42db6ad08f9bfd71887f7c47212319d" and "e1e4a8b148cc0cfcc8517e169d5d2cd0c3472a6f" have entirely different histories.
127b8b32f4
...
e1e4a8b148
|
@ -5,28 +5,17 @@ function killPlayingSong() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSystemVolume($newvol = null) {
|
function setSystemVolume($newvol = null) {
|
||||||
global $globaldbh;
|
|
||||||
|
|
||||||
if ( is_null($newvol) ) return false;
|
if ( is_null($newvol) ) return false;
|
||||||
system("HOME=/home/web && /usr/bin/amixer -q sset Master " . $newvol);
|
system("HOME=/home/web && /usr/bin/amixer -q sset Master " . $newvol);
|
||||||
$query = "UPDATE " . SETTINGSTABLE . " SET value=:value WHERE parameter='CURVOLUME'";
|
file_put_contents("/tmp/curvol", $newvol);
|
||||||
$fields = array();
|
|
||||||
$fields[':value'] = $newvol;
|
|
||||||
$sth = $globaldbh->prepare($query);
|
|
||||||
$sth->execute($fields);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSystemVolume() {
|
function getSystemVolume() {
|
||||||
global $globaldbh;
|
$curvol = file_get_contents("/tmp/curvol");
|
||||||
|
//$curvol = trim(shell_exec("HOME=/home/web && /usr/bin/amixer sget Master | grep \"Front Left:\" | awk '{print $4}'"));
|
||||||
$query = "SELECT value FROM " . SETTINGSTABLE . " WHERE parameter='CURVOLUME'";
|
|
||||||
$sth = $globaldbh->prepare($query);
|
|
||||||
$sth->execute();
|
|
||||||
if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
|
|
||||||
$curvol = $row['value'];
|
|
||||||
} else {
|
|
||||||
$curvol = '0';
|
|
||||||
}
|
|
||||||
return $curvol;
|
return $curvol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
use Time::HiRes qw(usleep);
|
use Time::HiRes qw(usleep);
|
||||||
use DBI;
|
|
||||||
use DBD::mysql;
|
|
||||||
use Config::INI::Reader;
|
|
||||||
|
|
||||||
sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
|
sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
|
||||||
|
|
||||||
my $confcontents = Config::INI::Reader->read_file('/etc/homeaudio.ini');
|
$maxvolume = 32768;
|
||||||
my $Config = $confcontents->{_};
|
|
||||||
|
|
||||||
$dsn = "DBI:mysql:" . $Config->{DBNAME} . ":" . $Config->{DBHOST};
|
|
||||||
$dbh = DBI->connect($dsn, $Config->{DBUSER}, $Config->{DBPASS}, {RaiseError=>1});
|
|
||||||
|
|
||||||
if ( $ARGV[0] eq "-show" ) {
|
if ( $ARGV[0] eq "-show" ) {
|
||||||
$showmute = 1;
|
$showmute = 1;
|
||||||
|
@ -21,16 +13,8 @@ if ( $ARGV[0] eq "-show" ) {
|
||||||
|
|
||||||
$sound = `/usr/bin/amixer sget Master`;
|
$sound = `/usr/bin/amixer sget Master`;
|
||||||
$mute = trim(`/usr/bin/amixer sget Master | grep "Front Left:" | awk '{print \$6}'`);
|
$mute = trim(`/usr/bin/amixer sget Master | grep "Front Left:" | awk '{print \$6}'`);
|
||||||
$sth = $dbh->prepare("SELECT value FROM settings WHERE parameter='CURVOLUME'");
|
$curvol = int(`cat /tmp/curvol`);
|
||||||
$sth->execute();
|
$stepval = int($maxvolume * 0.1);
|
||||||
if ( $sth->rows > 0 ) {
|
|
||||||
@result = $sth->fetchrow_array();
|
|
||||||
$curvol = $result[0];
|
|
||||||
} else {
|
|
||||||
$curvol = 0;
|
|
||||||
}
|
|
||||||
$sth->finish();
|
|
||||||
$stepval = int($curvol * 0.1);
|
|
||||||
@mixer = split(/\n/, $sound);
|
@mixer = split(/\n/, $sound);
|
||||||
#if ( index($mixer[@mixer-1], "[on]") > 0 ) {
|
#if ( index($mixer[@mixer-1], "[on]") > 0 ) {
|
||||||
if ( $mute eq "[on]" ) {
|
if ( $mute eq "[on]" ) {
|
||||||
|
|
|
@ -153,7 +153,7 @@ CREATE TABLE `settings` (
|
||||||
LOCK TABLES `settings` WRITE;
|
LOCK TABLES `settings` WRITE;
|
||||||
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
|
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
|
||||||
INSERT INTO `settings` VALUES (1,'CHRISTMAS','false');
|
INSERT INTO `settings` VALUES (1,'CHRISTMAS','false');
|
||||||
INSERT INTO `settings` VALUES (2,'CURVOLUME','0');
|
INSERT INTO `settings` VALUES (2,'CURVOLUME','28');
|
||||||
INSERT INTO `settings` VALUES (3,'CHRISTMASFREQ','4');
|
INSERT INTO `settings` VALUES (3,'CHRISTMASFREQ','4');
|
||||||
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
|
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
|
||||||
UNLOCK TABLES;
|
UNLOCK TABLES;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user