driechers 2025-01-01 22:14:18 +00:00 zatwierdzone przez GitHub
commit a9b94c8b92
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 42 dodań i 12 usunięć

Wyświetl plik

@ -8,7 +8,7 @@
<?php
// Get all the available controls
$output = shell_exec("sudo amixer scontrols");
$output = shell_exec("sudo amixer -M scontrols");
preg_match_all('/\'.*\'/', $output, $scontrols);
// Handle POST
@ -20,6 +20,7 @@ if (isset($_POST["audio"])) {
$phpname = str_replace(" ", "_", $name);
$plevel = $_POST["pl$phpname"];
$clevel = $_POST["cl$phpname"];
$eselect = $_POST["e$phpname"];
$mute = 'mute';
$cap = 'nocap';
@ -28,7 +29,10 @@ if (isset($_POST["audio"])) {
if($_POST["cs$phpname"] == 'on')
$cap = 'cap';
shell_exec("sudo amixer set $scontrol $mute playback $plevel% capture $clevel% $cap");
if($eselect)
shell_exec("sudo amixer -M set $scontrol $eselect");
else
shell_exec("sudo amixer -M set $scontrol $mute playback $plevel% capture $clevel% $cap");
}
}
}
@ -42,7 +46,7 @@ foreach ($scontrols[0] as $scontrol) {
$name = substr($scontrol, 1, -1);
// Get the current control settings and capabilties
$output = shell_exec("sudo amixer get $scontrol");
$output = shell_exec("sudo amixer -M get $scontrol");
$checked = 0;
foreach(preg_split("/((\r?\n)|(\r\n?))/", $output) as $line) {
@ -51,8 +55,6 @@ foreach ($scontrols[0] as $scontrol) {
}
if (preg_match_all('/Capabilities:.*pvolume/', $output)) {
//$level = $level_match[1];
// Grab the first level. Not supporting stereo.
preg_match_all('/Playback [0-9]+ \[([0-9]+)%\]/', $output, $levels);
$level = $levels[1][0];
@ -67,6 +69,8 @@ foreach ($scontrols[0] as $scontrol) {
echo " checked";
echo "></td>";
}
else
echo "<td></td>";
echo "</tr>";
}
elseif (preg_match_all('/Capabilities:.*pswitch/', $output)) {
@ -79,6 +83,25 @@ foreach ($scontrols[0] as $scontrol) {
echo "></td>";
echo "</tr>";
}
elseif (preg_match_all('/Capabilities:.*enum/', $output)) {
preg_match_all('/Items: (.*)/', $output, $sitems);
$items = preg_split("/('[^']*')|\h+/", $sitems[1][0], -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
preg_match_all('/Item0: (.*)/', $output, $mitem0);
$item0 = $mitem0[1][0];
echo "<tr>";
echo "<td>$name</td><td></td><td></td>";
echo "<td><select name='e$name'>";
foreach($items as $item) {
$itemname = substr($item, 1, -1);
echo '<option value="'.$item.'"';
if($item0 == $item)
echo 'selected';
echo '>'.$itemname.'</option>';
}
echo "</select></td>";
echo "</tr>";
}
}
// Create the Capture sliders
@ -88,7 +111,7 @@ foreach ($scontrols[0] as $scontrol) {
$name = substr($scontrol, 1, -1);
// Get the current control settings and capabilties
$output = shell_exec("sudo amixer get $scontrol");
$output = shell_exec("sudo amixer -M get $scontrol");
$checked = 0;
foreach(preg_split("/((\r?\n)|(\r\n?))/", $output) as $line) {
@ -96,12 +119,17 @@ foreach ($scontrols[0] as $scontrol) {
$checked = 1;
}
if (preg_match_all('/Capabilities:.*cvolume/', $output)) {
//$level = $level_match[1];
if (preg_match_all('/Capabilities:.*[c ]volume/', $output)) {
$level = 0;
// Grab the first level. Not supporting stereo.
preg_match_all('/Capture [0-9]+ \[([0-9]+)%\]/', $output, $levels);
if(preg_match_all('/Capture [0-9]+ \[([0-9]+)%\]/', $output, $levels))
$level = $levels[1][0];
else {
// Handle generic volume control as capture device
preg_match_all('/ [0-9]+ \[([0-9]+)%\]/', $output, $levels);
$level = $levels[1][0];
}
echo "<tr>";
echo "<td>$name</td>";
@ -113,10 +141,12 @@ foreach ($scontrols[0] as $scontrol) {
echo " checked";
echo "></td>";
}
else
echo "<td></td>";
echo "</tr>";
}
elseif (preg_match_all('/Capabilities:.*cswitch/', $output)) {
$checked = preg_match_all('/Playback.*\[on\]/', $output);
$checked = preg_match_all('/Capture.*\[on\]/', $output);
echo "<tr>";
echo "<td>$name</td><td></td><td></td>";
echo "<td><input type='checkbox' name='cs$name'";