doti3/bar/src/volume.php
2019-01-28 11:13:11 +01:00

35 lines
795 B
PHP
Executable file

#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
$volume = shell_exec('amixer get Master | grep Mono:');
if ($volume) {
preg_match('/\[([0-9%]+)\]/', $volume, $mach);
if (isset($mach[1])) {
$v = (int) str_replace('%', '', $mach[1]);
$fullText = ' '.$mach[1].' ';
if ($v === 0) {
$fullText.= emoji(0xf026);
} elseif ($v < 50) {
$fullText.= emoji(0xf027);
} else {
$fullText.= emoji(0xf028);
}
echo block(
'volume',
[
'full_text' => $fullText,
'color' => color('music'),
'markup' => 'pango',
'separator' => false,
'separator_block_width' => 0,
]
);
}
}