This commit is contained in:
Simon Vieille 2019-01-21 16:20:04 +01:00
parent f550909a8c
commit 0ef0093106
Signed by: deblan
GPG Key ID: 03383D15A1D31745
14 changed files with 187 additions and 46 deletions

View File

@ -1,104 +1,135 @@
[bandwidth_eth0]
command=/home/simon/.i3/bar/src/bandwidth.php eth0
format=json
markup=pango
interval=5
[bandwidth_eth1]
command=/home/simon/.i3/bar/src/bandwidth.php eth1
format=json
markup=pango
interval=5
[bandwidth_wlan0]
command=/home/simon/.i3/bar/src/bandwidth.php wlan0
format=json
markup=pango
interval=1
[inet_eth0]
command=/home/simon/.i3/bar/src/ip.php eth0
format=json
markup=pango
interval=10
[ip_eth0_inet]
command=/home/simon/.i3/bar/src/ip.php eth0
format=json
markup=pango
interval=10
[ip_eth1_inet]
command=/home/simon/.i3/bar/src/ip.php eth1
format=json
markup=pango
interval=10
[ip_wlan0_inet]
command=/home/simon/.i3/bar/src/ip.php wlan0
format=json
markup=pango
interval=10
[ip_easytether0_inet]
command=/home/simon/.i3/bar/src/ip.php easytether0
format=json
markup=pango
interval=100
[ip_wan]
command=/home/simon/.i3/bar/src/ip_wan.php
format=json
markup=pango
interval=100
[mount_point_space_root]
command=/home/simon/.i3/bar/src/mount_point_space.php root /
format=json
markup=pango
interval=5
[mount_point_space_home]
command=/home/simon/.i3/bar/src/mount_point_space.php home /home 90 95
format=json
markup=pango
interval=5
[memory]
command=memory
[spotify]
command=/home/simon/.i3/bar/src/spotify.php
format=json
interval=1
markup=pango
interval=3
[app_S]
command=/home/simon/.i3/bar/src/app.php S "i3-msg workspace '6. MEDIA'" '#1db954' 0
#[spotify_ctrl]
#command=/home/simon/.i3/bar/src/spotify_ctrl.php
#format=json
#interval=1
#[app_S]
#command=/home/simon/.i3/bar/src/app.php S "i3-msg workspace '6. MEDIA'" '#1db954' 0
#format=json
#interval=1000
[app_J]
command=/home/simon/.i3/bar/src/app.php J "/home/simon/bin/joplin" '#057bdd' '#fff' 0
format=json
markup=pango
interval=1000
[app_Y]
command=/home/simon/.i3/bar/src/app.php Y "xdg-open https://www.youtube.com/feed/subscriptions" '#f00' 0
command=/home/simon/.i3/bar/src/app.php Y "xdg-open https://www.youtube.com/feed/subscriptions" '#c74a42' '#fff' 0
format=json
markup=pango
interval=1000
[app_F]
command=/home/simon/.i3/bar/src/app.php F "xdg-open https://www.facebook.com/" '#598df3' 0
command=/home/simon/.i3/bar/src/app.php F "xdg-open https://www.facebook.com/" '#598df3' '#fff' 1
format=json
markup=pango
interval=1000
[app_C]
command=/home/simon/.i3/bar/src/app.php C "xdg-open https://choualbox.com/new" '#eeb819' 0
format=json
interval=1000
#[app_C]
#command=/home/simon/.i3/bar/src/app.php C "xdg-open https://choualbox.com/new" '#eeb819' 0
#format=json
#interval=1000
[app_R]
command=/home/simon/.i3/bar/src/app.php R "xdg-open https://redmine.like-inn-developpement.com/client" '#ff4e51'
format=json
interval=1000
#[app_R]
#command=/home/simon/.i3/bar/src/app.php "R" "xdg-open https://redmine.like-inn-developpement.com/client" '#ff4e51'
#format=json
#interval=1000
[volume]
command=/home/simon/.i3/bar/src/volume.php
format=json
markup=pango
interval=1
[screensaver]
command=/home/simon/.i3/bar/src/screensaver.php
format=json
markup=pango
interval=3
[time]
command=/home/simon/.i3/bar/src/time.php
format=json
markup=pango
interval=1
[date]
command=/home/simon/.i3/bar/src/date.php
format=json
markup=pango
interval=30
[rss]
@ -106,8 +137,10 @@ command=/home/simon/.i3/bar/src/rss.php "https://tiny.deblan.org/public.php?op=r
align=left
interval=30
format=json
markup=pango
[acpi]
command=/home/simon/.i3/bar/src/acpi.php
format=json
markup=pango
interval=20

View File

@ -23,7 +23,7 @@ if (!preg_match('`Discharging`', $acpi)) {
$color = color('normal');
}
$charging .= '↑';
$charging .= '%↑';
$block = block(
'acpi',

View File

@ -5,14 +5,15 @@ require __DIR__.'/base/block.php';
$name = $argv[1] ?? null;
$app = $argv[2] ?? null;
$color = $argv[3] ?? color('normal');
$separator = (bool) ($argv[4] ?? true);
$background = $argv[3];
$foreground = $argv[4];
$separator = (bool) ($argv[5] ?? true);
if (empty($name) && empty($app)) {
die;
}
$fullText = sprintf('[%s]', $name);
$fullText = sprintf(' %s ', $name);
if (getenv('BLOCK_BUTTON') === '1') {
pclose(popen($app, 'r'));
@ -21,10 +22,10 @@ if (getenv('BLOCK_BUTTON') === '1') {
echo block(
'app_'.$name,
[
'full_text' => $fullText,
'short_text' => $shortText,
'color' => $color,
'separator' => $separator,
'separator_block_width' => $separator ? 20 : 0,
'full_text' => span($fullText, $foreground, $background),
//'separator' => $separator,
//'separator_block_width' => $separator ? 20 : 0,
'separator' => false,
'separator_block_width' => 0,
]
);

View File

@ -24,7 +24,7 @@ if (empty($bwidth)) {
die;
}
$fullText = '['.$iface.'] '.$bwidth[0].'Ko/s↓ '.$bwidth[1].'Ko/s↑';
$fullText = span(' '.$iface.' ', '#ccc', '#222').span(' '.$bwidth[0].'Ko/s↓ '.$bwidth[1].'Ko/s↑', '#ddd', '#000').' ';
echo block(
'bandwidth_'.$iface,
@ -32,5 +32,7 @@ echo block(
'full_text' => $fullText,
'color' => '#ffffff',
'urgent' => 1,
'separator' => false,
'separator_block_width' => 0,
]
);

View File

@ -21,11 +21,30 @@ function color($label)
return $colors[$label] ?? $colors['info'];
}
/**
* Creates span.
*
* @param string $text
* @param string $foreground
* @param string $background
*
* @return string
*/
function span($text, $foreground = null, $background = null)
{
return sprintf(
'<span background=\'%s\' foreground=\'%s\'>%s</span>',
$background ?? '#333333',
$foreground ?? color('normal'),
$text
);
}
/**
* Returns a json of a block.
*
* @param string $name
* @param array $options
* @param array $options
*
* @return string
*/

View File

@ -5,7 +5,7 @@ require __DIR__.'/base/block.php';
$format = $argv[1] ?? 'd/m/Y';
$fullText = date($format);
$fullText = span(' '.date($format).' ', color('date'), '#444');
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('i3-msg \'workspace "3. MAIL"\'');
@ -15,6 +15,7 @@ echo block(
'date',
[
'full_text' => $fullText,
'color' => color('date'),
'separator' => false,
'separator_block_width' => 0,
]
);

View File

@ -18,18 +18,18 @@ if (empty($ip)) {
die;
}
$fullText = sprintf('[%s] %s', $iface, $ip);
$shortText = sprintf('%s: %s', $iface, $ip);
$fullText = span(' '.$iface.' ', '#ccc', '#222').span(' '.$ip, '#ddd', '#000').' ';
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip');
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip --selection c');
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip --selection clip');
}
echo block(
'ip_'.$iface.'_'.trim($inet),
[
'full_text' => $fullText,
'short_text' => $shortText,
'separator' => false,
'separator_block_width' => 0,
]
);

View File

@ -7,7 +7,7 @@ $ipv6 = !empty($argv[1]);
$iface = 'wan';
$command = sprintf(
'wget -O - -q %s "https://api.ipify.org/?format=text" | head -n 1 | cut -c1-50',
'dig +short myip.opendns.com @resolver1.opendns.com',
$ipv6 ? '-6' : null
);
@ -19,16 +19,16 @@ if (empty($ip)) {
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');
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip -sel clip');
}
$fullText = sprintf('[%s] %s', $iface, $ip);
$shortText = sprintf('%s: %s', $iface, $ip);
$fullText = span(' '.$iface.' ', '#ccc', '#222').span(' '.$ip, '#ddd', '#000').' ';
echo block(
'ip_wan',
[
'full_text' => $fullText,
'short_text' => $shortText,
'separator' => false,
'separator_block_width' => 0,
]
);

View File

@ -31,8 +31,7 @@ if ($percent < $range1) {
$color = color('critical');
}
$fullText = sprintf('[%s] %s%%', $mountPoint, $percent);
$shortText = sprintf('%s: %s%%', $mountPoint, $percent);
$fullText = span(' '.$mountPoint.' ', '#ccc', '#222').span(' '.$percent.'% ', $color, '#000').' ';
if (getenv('BLOCK_BUTTON') === '1') {
$command = 'export DISPLAY=:0; pcmanfm '.escapeshellarg('file://'.$mountPoint).'&';
@ -43,7 +42,8 @@ echo block(
'mount_point_space_'.$name,
[
'full_text' => $fullText,
'short_text' => $shortText,
'color' => $color,
'separator' => false,
'separator_block_width' => 0,
]
);

View File

@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
@ -18,7 +18,14 @@ if (empty($content)) {
preg_match_all('/<entry/isU', $content, $matches, PREG_SET_ORDER);
$fullText = sprintf('[%s] %s', $title, $count = count($matches));
$title = IntlChar::chr(0xf09e);
$count = count($matches);
if ($count > 0) {
$title .= ' +'.$count;
}
$fullText = span(' '.$title.' ', $count ? color('normal') : color('info'), '#333'); // sprintf('[%s] %s', $title, $count = count($matches));
$blockButton = (int) getenv('BLOCK_BUTTON');
@ -30,6 +37,6 @@ echo block(
'rss',
[
'full_text' => $fullText,
'color' => $count ? color('normal') : color('info'),
// 'color' => $count ? color('normal') : color('info'),
]
);

41
bar/src/screensaver.php Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
$command = 'ps aux | grep no-screensaver | grep -v grep';
$output = trim(shell_exec($command));
if (empty($output)) {
echo block(
'screensaver',
[
'full_text' => span(' • ', color('normal'), '#333'),//IntlChar::chr(0x1F5B5),
'color' => color('normal'),
'separator' => false,
'separator_block_width' => 0,
]
);
if (getenv('BLOCK_BUTTON') === '1') {
$command = '/home/simon/bin/no-screensaver >/dev/null 2>/dev/null &';
pclose(popen($command, 'r'));
}
} else {
echo block(
'screensaver',
[
'full_text' => span(' • ', color('warning'), '#333'),//IntlChar::chr(0x1F5B5),
'color' => color('warning'),
'separator' => false,
'separator_block_width' => 0,
]
);
if (getenv('BLOCK_BUTTON') === '1') {
$command = 'pkill no-screensaver';
shell_exec($command);
}
}

28
bar/src/spotify_ctrl.php Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/php
<?php
require __DIR__.'/base/block.php';
$status = trim(shell_exec('playerctl -p spotify status'));
if ($status === 'Playing') {
$fullText = '▮▮';
} elseif ($status === 'Paused') {
$fullText = '▶';
}
if (empty($fullText)) {
die(0);
}
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause');
}
echo block(
'spotify_ctrl',
[
'full_text' => $fullText,
'color' => color('music'),
]
);

View File

@ -15,10 +15,13 @@ if (date('H:i:s') === '13:37:00') {
shell_exec('notify-send "1337" "Powaaaa" --icon=/home/simon/Images/if_geek_zombie_60815.png');
}
$fullText = span(' '.$fullText.' ', color('date'), '#444');
echo block(
'time',
[
'full_text' => $fullText,
'color' => color('date'),
'separator' => false,
'separator_block_width' => 0,
]
);

View File

@ -9,11 +9,17 @@ 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' => $mach[1].' ♪',
'full_text' => $fullText,
'color' => color('music'),
'markup' => 'pango',
'separator' => false,
'separator_block_width' => 0,
]
);
}