Click handlers

This commit is contained in:
Simon Vieille 2017-12-04 19:41:16 +01:00
parent a149460074
commit e98c632fb0
No known key found for this signature in database
GPG key ID: 919533E2B946EA10
7 changed files with 44 additions and 19 deletions

View file

@ -21,40 +21,43 @@ command=/home/simon/.i3/bar/src/ip.php eth0
format=json format=json
interval=10 interval=10
[inet_eth0] [ip_eth0_inet]
command=/home/simon/.i3/bar/src/ip.php eth0 command=/home/simon/.i3/bar/src/ip.php eth0
format=json format=json
interval=10 interval=10
[inet_eth1] [ip_eth1_inet]
command=/home/simon/.i3/bar/src/ip.php eth1 command=/home/simon/.i3/bar/src/ip.php eth1
format=json format=json
interval=10 interval=10
[inet_wlan0] [ip_wlan0_inet]
command=/home/simon/.i3/bar/src/ip.php wlan0 command=/home/simon/.i3/bar/src/ip.php wlan0
format=json format=json
interval=10 interval=10
min_width=button=1
[inet_easytether0] [ip_easytether0_inet]
command=/home/simon/.i3/bar/src/ip.php easytether0 command=/home/simon/.i3/bar/src/ip.php easytether0
format=json format=json
interval=100 interval=100
[inet_wan] [ip_wan]
command=/home/simon/.i3/bar/src/ip_wan.php command=/home/simon/.i3/bar/src/ip_wan.php
format=json format=json
interval=100 interval=100
[mount_point_space_root] [mount_point_space_root]
command=/home/simon/.i3/bar/src/mount_point_space.php / command=/home/simon/.i3/bar/src/mount_point_space.php root /
format=json format=json
interval=5 interval=5
min_width=button=1
[mount_point_space_home] [mount_point_space_home]
command=/home/simon/.i3/bar/src/mount_point_space.php /home 90 95 command=/home/simon/.i3/bar/src/mount_point_space.php home /home 90 95
format=json format=json
interval=5 interval=5
min_width=button=1
[memory] [memory]
command=memory command=memory
@ -63,6 +66,7 @@ command=memory
command=/home/simon/.i3/bar/src/spotify.php command=/home/simon/.i3/bar/src/spotify.php
format=json format=json
interval=1 interval=1
min_width=button=1
[volume] [volume]
command=/home/simon/.i3/bar/src/volume.php command=/home/simon/.i3/bar/src/volume.php

View file

@ -7,8 +7,12 @@ $format = $argv[1] ?? 'd/m/Y';
$fullText = date($format); $fullText = date($format);
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('i3-msg \'workspace "3. MAIL"\'');
}
echo block( echo block(
'date_'.$format, 'date',
[ [
'full_text' => $fullText, 'full_text' => $fullText,
'color' => color('date'), 'color' => color('date'),

View file

@ -21,8 +21,12 @@ if (empty($ip)) {
$fullText = sprintf('[%s] %s', $iface, $ip); $fullText = sprintf('[%s] %s', $iface, $ip);
$shortText = sprintf('%s: %s', $iface, $ip); $shortText = sprintf('%s: %s', $iface, $ip);
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('echo "'.escapeshellarg($ip).'" | xclip');
}
echo block( echo block(
'ip_'.$iface.'_'.$inet, 'ip_'.$iface.'_'.trim($inet),
[ [
'full_text' => $fullText, 'full_text' => $fullText,
'short_text' => $shortText, 'short_text' => $shortText,

View file

@ -21,7 +21,7 @@ $fullText = sprintf('[%s] %s', $iface, $ip);
$shortText = sprintf('%s: %s', $iface, $ip); $shortText = sprintf('%s: %s', $iface, $ip);
echo block( echo block(
'ip_'.$iface, 'ip_wan',
[ [
'full_text' => $fullText, 'full_text' => $fullText,
'short_text' => $shortText, 'short_text' => $shortText,

View file

@ -3,9 +3,10 @@
require __DIR__.'/base/block.php'; require __DIR__.'/base/block.php';
$mountPoint = $argv[1] ?? '/'; $name = $argv[1] ?? 'root';
$range1 = $argv[2] ?? 70; $mountPoint = $argv[2] ?? '/';
$range2 = $argv[3] ?? 90; $range1 = $argv[3] ?? 70;
$range2 = $argv[4] ?? 90;
$command = sprintf( $command = sprintf(
'df -h %s | tail -n 1', 'df -h %s | tail -n 1',
@ -33,8 +34,13 @@ if ($percent < $range1) {
$fullText = sprintf('[%s] %s%%', $mountPoint, $percent); $fullText = sprintf('[%s] %s%%', $mountPoint, $percent);
$shortText = sprintf('%s: %s%%', $mountPoint, $percent); $shortText = sprintf('%s: %s%%', $mountPoint, $percent);
if (getenv('BLOCK_BUTTON') === '1') {
$command = 'export DISPLAY=:0; pcmanfm '.escapeshellarg('file://'.$mountPoint).'&';
pclose(popen($command, 'r'));
}
echo block( echo block(
'mount_point_space_'.$mountPoint, 'mount_point_space_'.$name,
[ [
'full_text' => $fullText, 'full_text' => $fullText,
'short_text' => $shortText, 'short_text' => $shortText,

View file

@ -9,12 +9,12 @@ if (!in_array($status, ['Playing'])) {
die; die;
} }
function cleanUp($d) function cleanUp($d, $max = 30)
{ {
$string = trim(str_replace(['"', "'"], ' ', $d)); $string = trim(str_replace(['"', "'"], ' ', $d));
if (mb_strlen($string) > 15) { if (mb_strlen($string) > $max) {
$string = substr($string, 0, 15).'…'; $string = substr($string, 0, $max).'…';
} }
return $string; return $string;
@ -24,9 +24,12 @@ $title = cleanUp(shell_exec('playerctl -p spotify metadata xesam:title'));
$artist = cleanUp(shell_exec('playerctl -p spotify metadata xesam:artist')); $artist = cleanUp(shell_exec('playerctl -p spotify metadata xesam:artist'));
$label = sprintf('%s %s', $title, $artist); $label = sprintf('%s %s', $title, $artist);
$fullText = sprintf('%s %s', $title, $artist); $fullText = sprintf('%s %s', $title, $artist);
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('i3-msg \'workspace "6. MEDIA"\'');
}
echo block( echo block(
'spotify', 'spotify',
[ [

View file

@ -7,8 +7,12 @@ $format = $argv[1] ?? 'H:i:s';
$fullText = date($format); $fullText = date($format);
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('i3-msg \'workspace "3. MAIL"\'');
}
echo block( echo block(
'time_'.$format, 'time',
[ [
'full_text' => $fullText, 'full_text' => $fullText,
'color' => color('date'), 'color' => color('date'),