doti3/bar/src/volume.php
2019-01-21 16:20:04 +01:00

27 lines
598 B
PHP
Executable file

#!/usr/bin/php
<?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].' ♪ ';
echo block(
'volume',
[
'full_text' => $fullText,
'color' => color('music'),
'markup' => 'pango',
'separator' => false,
'separator_block_width' => 0,
]
);
}
}