doti3/bar/src/volume.php

35 lines
795 B
PHP
Raw Normal View History

2019-01-28 11:13:11 +01:00
#!/usr/bin/php7.1
2017-06-19 16:36:59 +02:00
<?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])) {
2019-01-21 16:20:04 +01:00
$v = (int) str_replace('%', '', $mach[1]);
2019-01-28 11:13:11 +01:00
$fullText = ' '.$mach[1].' ';
if ($v === 0) {
$fullText.= emoji(0xf026);
} elseif ($v < 50) {
$fullText.= emoji(0xf027);
} else {
$fullText.= emoji(0xf028);
}
2019-01-21 16:20:04 +01:00
2017-06-19 16:36:59 +02:00
echo block(
'volume',
[
2019-01-21 16:20:04 +01:00
'full_text' => $fullText,
2017-06-19 16:36:59 +02:00
'color' => color('music'),
2019-01-21 16:20:04 +01:00
'markup' => 'pango',
'separator' => false,
'separator_block_width' => 0,
2017-06-19 16:36:59 +02:00
]
);
}
}