configure bar

This commit is contained in:
Simon Vieille 2019-01-28 11:13:11 +01:00
förälder 542fa6e379
incheckning 62966c2fce
Signerad av: deblan
GPG-nyckel ID: 03383D15A1D31745
15 ändrade filer med 126 tillägg och 104 borttagningar

Visa fil

@ -70,43 +70,11 @@ format=json
markup=pango
interval=3
#[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
[spotify_ctrl]
command=/home/simon/.i3/bar/src/spotify_ctrl.php
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" '#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' '#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_R]
#command=/home/simon/.i3/bar/src/app.php "R" "xdg-open https://redmine.like-inn-developpement.com/client" '#ff4e51'
#format=json
#interval=1000
interval=1
[volume]
command=/home/simon/.i3/bar/src/volume.php
@ -120,20 +88,32 @@ format=json
markup=pango
interval=3
[app_C]
command=/home/simon/.i3/bar/src/app.php C "xdg-open https://cloud.deblan.org/nc/" '#5d5d7d' '#fff'
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" '#c74a42' '#fff'
format=json
markup=pango
interval=1000
[time]
command=/home/simon/.i3/bar/src/time.php
command=/home/simon/.i3/bar/src/time.php "H:i:s d/m/Y"
format=json
markup=pango
interval=1
[date]
command=/home/simon/.i3/bar/src/date.php
format=json
markup=pango
interval=30
#[date]
#command=/home/simon/.i3/bar/src/date.php
#format=json
#markup=pango
#interval=30
[rss]
command=/home/simon/.i3/bar/src/rss.php "https://tiny.deblan.org/public.php?op=rss&id=-3&key=17c659af1ad27f30941a724fcf48421d1e83081a" "RSS"
command=/home/simon/.i3/bar/src/rss.php "https://tiny.deblan.org/public.php?op=rss&id=-3&key=17c659af1ad27f30941a724fcf48421d1e83081a" "https://tiny.deblan.org/"
align=left
interval=30
format=json

Visa fil

@ -16,28 +16,37 @@ if (!preg_match('`Discharging`', $acpi)) {
}
if ($charging < 20) {
$color = color('critical');
$foreground = '#333';
$background = color('critical');
} elseif ($charging < 50) {
$color = color('warning');
$foreground = color('info');
$background = color('warning');
} else {
$color = color('normal');
$foreground = '#333';
$background = color('normal');
}
$charging .= '%↑';
$charging .= '% '.emoji(0xf0aa);
$text = span(' '.$charging.' ', $foreground, $background);
$block = block(
'acpi',
[
'full_text' => $charging,
'full_text' => $text,
'color' => $color,
'separator' => false,
'separator_block_width' => 0,
]
);
} else {
$block = block(
'acpi',
[
'full_text' => '??? ',
'full_text' => '??? '.emoji(0xf0aa),
'color' => color('info'),
'separator' => false,
'separator_block_width' => 0,
]
);
}
@ -45,22 +54,27 @@ if (!preg_match('`Discharging`', $acpi)) {
preg_match('`([0-9]+%), ([0-9]+:[0-9]+)`', $acpi, $values);
if ($values[0] < 20) {
$color = color('critical');
$foreground = '#333';
$background = color('critical');
} elseif ($values[0] < 50) {
$color = color('warning');
$foreground = color('info');
$background = color('warning');
} else {
$color = color('info');
$foreground = '#333';
$background = color('normal');
}
$charging = $values[1].'↓';
$charging = $values[1];
$times = str_replace(':', 'h', $values[2]);
$text = implode(' ', [$charging, $times]);
$text = span(' '.implode(' ', [$charging, $times, emoji(0xf0ab)]).' ', $foreground, $background);
$block = block(
'acpi',
[
'full_text' => $text,
'color' => $color,
'separator' => false,
'separator_block_width' => 0,
]
);
}

Visa fil

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

Visa fil

@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
@ -18,21 +18,20 @@ if (empty($ip)) {
die;
}
$bwidth = explode(' ', preg_replace('/ +/', ' ', trim(shell_exec('ifstat -i '.escapeshellcmd($iface).' 1 1 | tail -n 1'))));
$bwidth = explode(' ', preg_replace('/ +/', ' ', trim(shell_exec('ifstat -i '.escapeshellcmd($iface).' 0.1 1 | tail -n 1'))));
if (empty($bwidth)) {
die;
}
$fullText = span(' '.$iface.' ', '#ccc', '#222').span(' '.$bwidth[0].'Ko/s↓ '.$bwidth[1].'Ko/s↑', '#ddd', '#000').' ';
$up = $bwidth[1].'Ko/s'.pemoji(0xf0aa);
$down = pemoji(0xf0ab).$bwidth[0].'Ko/s ';
$fullText = pspan($iface, '#ccc', '#222').pspan($down.$up, '#ddd', '#000');
echo block(
'bandwidth_'.$iface,
[
'full_text' => $fullText,
'color' => '#ffffff',
'urgent' => 1,
'separator' => false,
'separator_block_width' => 0,
]
);

Visa fil

@ -10,7 +10,7 @@
function color($label)
{
$colors = [
'music' => '#C3D4FF',
'music' => '#cccccc',
'date' => '#E9F1FF',
'info' => '#E9F1FF',
'critical' => '#FF474A',
@ -21,6 +21,40 @@ function color($label)
return $colors[$label] ?? $colors['info'];
}
/**
* Create emoji with padding.
*
* @param mixed $char
*/
function pemoji($char)
{
return '<span font=\'FontAwesome\'> '.IntlChar::chr($char).' </span>';
}
/**
* Create emoji.
*
* @param mixed $char
*/
function emoji($char)
{
return '<span font=\'FontAwesome\'>'.IntlChar::chr($char).'</span>';
}
/**
* Creates span with padding.
*
* @param string $text
* @param string $foreground
* @param string $background
*
* @return string
*/
function pspan($text, $foreground = null, $background = null)
{
return span(sprintf(' %s ', $text), $foreground, $background);
}
/**
* Creates span.
*
@ -56,8 +90,8 @@ function block(string $name, array $options = [])
'align' => 'left',
'name' => $name,
'urgent' => false,
'separator' => true,
'separator_block_width' => 20,
'separator' => false,
'separator_block_width' => 0,
],
$options
);

Visa fil

@ -1,11 +1,11 @@
#!/usr/bin/php
#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
$format = $argv[1] ?? 'd/m/Y';
$fullText = span(' '.date($format).' ', color('date'), '#444');
$fullText = span(' '.emoji(0xf073).' '.date($format).' ', color('date'), '#444');
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('i3-msg \'workspace "3. MAIL"\'');

Visa fil

@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
@ -18,7 +18,7 @@ if (empty($ip)) {
die;
}
$fullText = span(' '.$iface.' ', '#ccc', '#222').span(' '.$ip, '#ddd', '#000').' ';
$fullText = pspan($iface, '#ccc', '#222').pspan($ip, '#ddd', '#000');
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip');

Visa fil

@ -22,7 +22,7 @@ if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('export DISPLAY=:0; echo '.escapeshellarg($ip).' | xclip -sel clip');
}
$fullText = span(' '.$iface.' ', '#ccc', '#222').span(' '.$ip, '#ddd', '#000').' ';
$fullText = pspan($iface, '#ccc', '#222').pspan($ip, '#ddd', '#000');
echo block(
'ip_wan',

Visa fil

@ -31,13 +31,13 @@ if ($percent < $range1) {
$color = color('critical');
}
$fullText = span(' '.$mountPoint.' ', '#ccc', '#222').span(' '.$percent.'% ', $color, '#000').' ';
if (getenv('BLOCK_BUTTON') === '1') {
$command = 'export DISPLAY=:0; pcmanfm '.escapeshellarg('file://'.$mountPoint).'&';
pclose(popen($command, 'r'));
}
$fullText = pspan($mountPoint, '#ccc', '#222').pspan($percent.'%', $color, '#000');
echo block(
'mount_point_space_'.$name,
[

Visa fil

@ -4,9 +4,9 @@
require __DIR__.'/base/block.php';
$rss = $argv[1] ?? null;
$title = $argv[2] ?? null;
$client = $argv[2] ?? null;
if (empty($rss) || empty($title)) {
if (empty($rss)) {
die;
}
@ -18,25 +18,22 @@ if (empty($content)) {
preg_match_all('/<entry/isU', $content, $matches, PREG_SET_ORDER);
$title = IntlChar::chr(0xf09e);
$title = pemoji(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));
$fullText = span($title, $count ? color('normal') : color('info'), '#333');
$blockButton = (int) getenv('BLOCK_BUTTON');
if ($blockButton === 1) {
shell_exec('xdg-open "https://tiny.deblan.org/index.php"');
if ($client && (int) getenv('BLOCK_BUTTON') === 1) {
shell_exec(sprintf('xdg-open %s', escapeshellarg($client)));
}
echo block(
'rss',
[
'full_text' => $fullText,
// 'color' => $count ? color('normal') : color('info'),
]
);

Visa fil

@ -11,10 +11,8 @@ if (empty($output)) {
echo block(
'screensaver',
[
'full_text' => span(' • ', color('normal'), '#333'),//IntlChar::chr(0x1F5B5),
'full_text' => pspan(emoji(0xf108), color('normal'), '#000'),
'color' => color('normal'),
'separator' => false,
'separator_block_width' => 0,
]
);
@ -26,10 +24,8 @@ if (empty($output)) {
echo block(
'screensaver',
[
'full_text' => span(' • ', color('warning'), '#333'),//IntlChar::chr(0x1F5B5),
'full_text' => pspan(emoji(0xf108), color('warning'), '#000'),
'color' => color('warning'),
'separator' => false,
'separator_block_width' => 0,
]
);

Visa fil

@ -23,8 +23,7 @@ function cleanUp($d, $max = 20)
$title = cleanUp(shell_exec('playerctl -p spotify metadata xesam:title'));
$artist = cleanUp(shell_exec('playerctl -p spotify metadata xesam:artist'));
$label = sprintf('%s %s', $title, $artist);
$fullText = sprintf('%s %s', $title, $artist);
$fullText = pspan($artist, '#ccc', '#222').pspan($title, '#ddd', '#000');
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('i3-msg \'workspace "6. MEDIA"\'');
@ -35,5 +34,7 @@ echo block(
[
'full_text' => $fullText,
'color' => color('music'),
'separator' => false,
'separator_block_width' => 0,
]
);

Visa fil

@ -6,9 +6,9 @@ require __DIR__.'/base/block.php';
$status = trim(shell_exec('playerctl -p spotify status'));
if ($status === 'Playing') {
$fullText = '▮▮';
$fullText = pemoji(0xf04c);
} elseif ($status === 'Paused') {
$fullText = '▶';
$fullText = pemoji(0xf04b);
}
if (empty($fullText)) {
@ -22,7 +22,7 @@ if (getenv('BLOCK_BUTTON') === '1') {
echo block(
'spotify_ctrl',
[
'full_text' => $fullText,
'full_text' => span($fullText, '#ccc', '#000'),
'color' => color('music'),
]
);

Visa fil

@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
@ -15,7 +15,7 @@ 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');
$fullText = span(pemoji(0xf073).$fullText, color('date'), '#444');
echo block(
'time',

Visa fil

@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/bin/php7.1
<?php
require __DIR__.'/base/block.php';
@ -10,7 +10,15 @@ if ($volume) {
if (isset($mach[1])) {
$v = (int) str_replace('%', '', $mach[1]);
$fullText = ' '.$mach[1].' ♪ ';
$fullText = ' '.$mach[1].' ';
if ($v === 0) {
$fullText.= emoji(0xf026);
} elseif ($v < 50) {
$fullText.= emoji(0xf027);
} else {
$fullText.= emoji(0xf028);
}
echo block(
'volume',