diff --git a/bar/bar1.conf b/bar/bar1.conf index 1984bff..2be4051 100644 --- a/bar/bar1.conf +++ b/bar/bar1.conf @@ -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 diff --git a/bar/src/acpi.php b/bar/src/acpi.php index 0d55cd6..ebdebc8 100755 --- a/bar/src/acpi.php +++ b/bar/src/acpi.php @@ -23,7 +23,7 @@ if (!preg_match('`Discharging`', $acpi)) { $color = color('normal'); } - $charging .= '↑'; + $charging .= '%↑'; $block = block( 'acpi', diff --git a/bar/src/app.php b/bar/src/app.php index 6a43085..08a565e 100755 --- a/bar/src/app.php +++ b/bar/src/app.php @@ -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, ] ); diff --git a/bar/src/bandwidth.php b/bar/src/bandwidth.php index 779d546..6f152d9 100755 --- a/bar/src/bandwidth.php +++ b/bar/src/bandwidth.php @@ -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, ] ); diff --git a/bar/src/base/block.php b/bar/src/base/block.php index 7aaa574..593f142 100644 --- a/bar/src/base/block.php +++ b/bar/src/base/block.php @@ -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( + '%s', + $background ?? '#333333', + $foreground ?? color('normal'), + $text + ); +} + /** * Returns a json of a block. * * @param string $name - * @param array $options + * @param array $options * * @return string */ diff --git a/bar/src/date.php b/bar/src/date.php index df1c3b3..e0291be 100755 --- a/bar/src/date.php +++ b/bar/src/date.php @@ -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, ] ); diff --git a/bar/src/ip.php b/bar/src/ip.php index e2ccfa5..a3e9333 100755 --- a/bar/src/ip.php +++ b/bar/src/ip.php @@ -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, ] ); diff --git a/bar/src/ip_wan.php b/bar/src/ip_wan.php index 22e80c6..f024b20 100755 --- a/bar/src/ip_wan.php +++ b/bar/src/ip_wan.php @@ -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, ] ); diff --git a/bar/src/mount_point_space.php b/bar/src/mount_point_space.php index 46bcfa4..a1084ec 100755 --- a/bar/src/mount_point_space.php +++ b/bar/src/mount_point_space.php @@ -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, ] ); diff --git a/bar/src/rss.php b/bar/src/rss.php index 9285285..d7151b2 100755 --- a/bar/src/rss.php +++ b/bar/src/rss.php @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/php7.1 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'), ] ); diff --git a/bar/src/screensaver.php b/bar/src/screensaver.php new file mode 100755 index 0000000..2440c17 --- /dev/null +++ b/bar/src/screensaver.php @@ -0,0 +1,41 @@ +#!/usr/bin/php7.1 + 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); + } +} + diff --git a/bar/src/spotify_ctrl.php b/bar/src/spotify_ctrl.php new file mode 100755 index 0000000..86b1d72 --- /dev/null +++ b/bar/src/spotify_ctrl.php @@ -0,0 +1,28 @@ +#!/usr/bin/php + $fullText, + 'color' => color('music'), + ] +); diff --git a/bar/src/time.php b/bar/src/time.php index cfdcf90..e60bd30 100755 --- a/bar/src/time.php +++ b/bar/src/time.php @@ -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, ] ); diff --git a/bar/src/volume.php b/bar/src/volume.php index 309af8d..60f2937 100755 --- a/bar/src/volume.php +++ b/bar/src/volume.php @@ -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, ] ); }