doti3/bar/src/volume.php

38 lines
821 B
PHP
Raw Normal View History

2021-03-03 21:31:06 +01:00
#!/usr/bin/env php
2017-06-19 16:36:59 +02:00
<?php
require __DIR__.'/base/block.php';
2020-01-14 11:35:27 +01:00
$volume = trim(shell_exec('/usr/bin/amixer get Master'));
2017-06-19 16:36:59 +02:00
2020-01-14 11:35:27 +01:00
if (!empty($volume)) {
preg_match('/\[([0-9%]+)\]/', $volume, $match);
if ($match[1]) {
$v = (int) str_replace('%', '', $match[1]);
$fullText = ' '.$match[1].' ';
2019-01-28 11:13:11 +01:00
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
]
);
2020-01-14 11:35:27 +01:00
die(0);
2017-06-19 16:36:59 +02:00
}
}