Fix and notifications

This commit is contained in:
Simon Vieille 2018-01-03 13:53:49 +01:00
parent 9b654ba474
commit eb7c133232
No known key found for this signature in database
GPG key ID: 919533E2B946EA10
7 changed files with 33 additions and 7 deletions

View file

@ -26,7 +26,7 @@ if (!preg_match('`Discharging`', $acpi)) {
$charging .= '↑'; $charging .= '↑';
$block = block( $block = block(
'volume', 'acpi',
[ [
'full_text' => $charging, 'full_text' => $charging,
'color' => $color, 'color' => $color,
@ -34,7 +34,7 @@ if (!preg_match('`Discharging`', $acpi)) {
); );
} else { } else {
$block = block( $block = block(
'volume', 'acpi',
[ [
'full_text' => '??? ↑', 'full_text' => '??? ↑',
'color' => color('info'), 'color' => color('info'),
@ -54,10 +54,10 @@ if (!preg_match('`Discharging`', $acpi)) {
$charging = $values[1].'↓'; $charging = $values[1].'↓';
$times = str_replace(':', 'h', $values[2]); $times = str_replace(':', 'h', $values[2]);
$text = implode(' ', array($charging, $times)); $text = implode(' ', [$charging, $times]);
$block = block( $block = block(
'volume', 'acpi',
[ [
'full_text' => $text, 'full_text' => $text,
'color' => $color, 'color' => $color,

View file

@ -31,5 +31,6 @@ echo block(
[ [
'full_text' => $fullText, 'full_text' => $fullText,
'color' => '#ffffff', 'color' => '#ffffff',
'urgent' => 1,
] ]
); );

View file

@ -1,5 +1,12 @@
<?php <?php
/**
* Get the hexa code of a color by its label.
*
* @param string $label
*
* @return string
*/
function color($label) function color($label)
{ {
$colors = [ $colors = [
@ -14,6 +21,14 @@ function color($label)
return $colors[$label] ?? $colors['info']; return $colors[$label] ?? $colors['info'];
} }
/**
* Returns a json of a block.
*
* @param string $name
* @param array $options
*
* @return string
*/
function block(string $name, array $options = []) function block(string $name, array $options = [])
{ {
$options = array_merge( $options = array_merge(
@ -28,5 +43,5 @@ function block(string $name, array $options = [])
$options $options
); );
echo stripslashes(json_encode($options, JSON_UNESCAPED_UNICODE)); return stripslashes(json_encode($options, JSON_UNESCAPED_UNICODE));
} }

View file

@ -22,7 +22,8 @@ $fullText = sprintf('[%s] %s', $iface, $ip);
$shortText = sprintf('%s: %s', $iface, $ip); $shortText = sprintf('%s: %s', $iface, $ip);
if (getenv('BLOCK_BUTTON') === '1') { if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('echo '.escapeshellarg($ip).' | xclip'); shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip');
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip --selection c');
} }
echo block( echo block(

View file

@ -17,6 +17,11 @@ if (empty($ip)) {
die; die;
} }
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip');
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip -sel c');
}
$fullText = sprintf('[%s] %s', $iface, $ip); $fullText = sprintf('[%s] %s', $iface, $ip);
$shortText = sprintf('%s: %s', $iface, $ip); $shortText = sprintf('%s: %s', $iface, $ip);

View file

@ -23,7 +23,7 @@ $fullText = sprintf('[%s] %s', $title, $count = count($matches));
$blockButton = (int) getenv('BLOCK_BUTTON'); $blockButton = (int) getenv('BLOCK_BUTTON');
if ($blockButton === 1) { if ($blockButton === 1) {
shell_exec('xdg-open https://tiny.deblan.org/index.php'); shell_exec('xdg-open "https://tiny.deblan.org/index.php"');
} }
echo block( echo block(

View file

@ -11,6 +11,10 @@ if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('i3-msg \'workspace "3. MAIL"\''); shell_exec('i3-msg \'workspace "3. MAIL"\'');
} }
if (date('H:i:s') === '13:37:00') {
shell_exec('notify-send "1337" "Powaaaa" --icon=/home/simon/Images/if_geek_zombie_60815.png');
}
echo block( echo block(
'time', 'time',
[ [