From a0ab663573aac1d0f262ff78cc13597ddf23c45d Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 19 Jun 2017 16:36:59 +0200 Subject: [PATCH] i3bar --- bar/bar1.conf | 90 +++++++++++++++++++++++++++++++++++ bar/src/acpi.php | 64 +++++++++++++++++++++++++ bar/src/bandwidth.php | 35 ++++++++++++++ bar/src/base/block.php | 32 +++++++++++++ bar/src/date.php | 16 +++++++ bar/src/ip.php | 30 ++++++++++++ bar/src/ip_wan.php | 29 +++++++++++ bar/src/mount_point_space.php | 43 +++++++++++++++++ bar/src/spotify.php | 36 ++++++++++++++ bar/src/time.php | 16 +++++++ bar/src/volume.php | 20 ++++++++ config | 56 +++++++--------------- 12 files changed, 427 insertions(+), 40 deletions(-) create mode 100644 bar/bar1.conf create mode 100755 bar/src/acpi.php create mode 100755 bar/src/bandwidth.php create mode 100644 bar/src/base/block.php create mode 100755 bar/src/date.php create mode 100755 bar/src/ip.php create mode 100755 bar/src/ip_wan.php create mode 100755 bar/src/mount_point_space.php create mode 100755 bar/src/spotify.php create mode 100755 bar/src/time.php create mode 100755 bar/src/volume.php diff --git a/bar/bar1.conf b/bar/bar1.conf new file mode 100644 index 0000000..a664f38 --- /dev/null +++ b/bar/bar1.conf @@ -0,0 +1,90 @@ +interval=1 +color=#E9F1FF + +[bandwidth_eth0] +command=/home/simon/.i3/bar/src/bandwidth.php eth0 +format=json +interval=5 + +[bandwidth_eth1] +command=/home/simon/.i3/bar/src/bandwidth.php eth1 +format=json +interval=5 + +[bandwidth_wlan0] +command=/home/simon/.i3/bar/src/bandwidth.php wlan0 +format=json +interval=1 + +[inet_eth0] +command=/home/simon/.i3/bar/src/ip.php eth0 +format=json +interval=10 + +[inet_eth0] +command=/home/simon/.i3/bar/src/ip.php eth0 +format=json +interval=10 + +[inet_eth1] +command=/home/simon/.i3/bar/src/ip.php eth1 +format=json +interval=10 + +[inet_wlan0] +command=/home/simon/.i3/bar/src/ip.php wlan0 +format=json +interval=10 + +[inet_easytether0] +command=/home/simon/.i3/bar/src/ip.php easytether0 +format=json +interval=100 + +[inet_wan] +command=/home/simon/.i3/bar/src/ip_wan.php +format=json +interval=100 + +[mount_point_space_root] +command=/home/simon/.i3/bar/src/mount_point_space.php / +format=json +interval=5 + +[mount_point_space_home] +command=/home/simon/.i3/bar/src/mount_point_space.php /home 80 90 +format=json +interval=5 + +[mount_point_space_secured] +command=/home/simon/.i3/bar/src/mount_point_space.php /secured +format=json +interval=5 + +[memory] +command=memory + +[spotify] +command=/home/simon/.i3/bar/src/spotify.php +format=json +interval=1 + +[volume] +command=/home/simon/.i3/bar/src/volume.php +format=json +interval=1 + +[time] +command=/home/simon/.i3/bar/src/time.php +format=json +interval=1 + +[date] +command=/home/simon/.i3/bar/src/date.php +format=json +interval=30 + +[acpi] +command=/home/simon/.i3/bar/src/acpi.php +format=json +interval=1 diff --git a/bar/src/acpi.php b/bar/src/acpi.php new file mode 100755 index 0000000..d7bb137 --- /dev/null +++ b/bar/src/acpi.php @@ -0,0 +1,64 @@ +#!/usr/bin/php + $charging, + 'color' => $color, + ] + ); + } else { + $block = block( + 'volume', + [ + 'full_text' => '??? ↑', + 'color' => color('info'), + ] + ); + } +} else { + preg_match('`([0-9]+%), ([0-9]+:[0-9]+)`', $acpi, $values); + + if ($values[0] < 20) { + $color = color('critical'); + } elseif ($values[0] < 50) { + $color = color('warning'); + } else { + $color = color('info'); + } + + $charging = $values[1].'↓'; + $times = str_replace(':', 'h', $values[2]); + $text = implode(' ', array($charging, $times)); + + $block = block( + 'volume', + [ + 'full_text' => $text, + 'color' => $color, + ] + ); +} + +echo $block; diff --git a/bar/src/bandwidth.php b/bar/src/bandwidth.php new file mode 100755 index 0000000..752c357 --- /dev/null +++ b/bar/src/bandwidth.php @@ -0,0 +1,35 @@ +#!/usr/bin/php + $fullText, + 'color' => color('info'), + ] +); diff --git a/bar/src/base/block.php b/bar/src/base/block.php new file mode 100644 index 0000000..263c975 --- /dev/null +++ b/bar/src/base/block.php @@ -0,0 +1,32 @@ + '#C3D4FF', + 'date' => '#98A6C7', + 'info' => '#E9F1FF', + 'critical' => '#FF474A', + 'warning' => '#FF6836', + 'normal' => '#B3FF6C', + ]; + + return $colors[$label] ?? '#ffffff'; +} + +function block(string $name, array $options = []) +{ + $options = array_merge( + [ + 'full_text' => '', + 'align' => 'left', + 'name' => $name, + 'urgent' => false, + 'separator' => true, + 'separator_block_width' => 20, + ], + $options + ); + + echo stripslashes(json_encode($options, JSON_UNESCAPED_UNICODE)); +} diff --git a/bar/src/date.php b/bar/src/date.php new file mode 100755 index 0000000..af56ac2 --- /dev/null +++ b/bar/src/date.php @@ -0,0 +1,16 @@ +#!/usr/bin/php + $fullText, + 'color' => color('date'), + ] +); diff --git a/bar/src/ip.php b/bar/src/ip.php new file mode 100755 index 0000000..ce18e43 --- /dev/null +++ b/bar/src/ip.php @@ -0,0 +1,30 @@ +#!/usr/bin/php + $fullText, + 'short_text' => $shortText, + ] +); diff --git a/bar/src/ip_wan.php b/bar/src/ip_wan.php new file mode 100755 index 0000000..648a08d --- /dev/null +++ b/bar/src/ip_wan.php @@ -0,0 +1,29 @@ +#!/usr/bin/php + $fullText, + 'short_text' => $shortText, + ] +); diff --git a/bar/src/mount_point_space.php b/bar/src/mount_point_space.php new file mode 100755 index 0000000..98d9f95 --- /dev/null +++ b/bar/src/mount_point_space.php @@ -0,0 +1,43 @@ +#!/usr/bin/php + $fullText, + 'short_text' => $shortText, + 'color' => $color, + ] +); diff --git a/bar/src/spotify.php b/bar/src/spotify.php new file mode 100755 index 0000000..244465d --- /dev/null +++ b/bar/src/spotify.php @@ -0,0 +1,36 @@ +#!/usr/bin/php + 15) { + $string = substr($string, 0, 15).'…'; + } + + return $string; +} + +$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); + +echo block( + 'spotify', + [ + 'full_text' => $fullText, + 'color' => color('music'), + ] +); diff --git a/bar/src/time.php b/bar/src/time.php new file mode 100755 index 0000000..b0d22c1 --- /dev/null +++ b/bar/src/time.php @@ -0,0 +1,16 @@ +#!/usr/bin/php + $fullText, + 'color' => color('date'), + ] +); diff --git a/bar/src/volume.php b/bar/src/volume.php new file mode 100755 index 0000000..309af8d --- /dev/null +++ b/bar/src/volume.php @@ -0,0 +1,20 @@ +#!/usr/bin/php + $mach[1].' ♪', + 'color' => color('music'), + ] + ); + } +} diff --git a/config b/config index f172318..4c2a29f 100644 --- a/config +++ b/config @@ -19,8 +19,7 @@ bindsym $mod+Return exec /home/simon/bin/urxvt bindsym $mod+Shift+A kill # start dmenu (a program launcher) -bindsym $mod+d exec dmenu_run -nb '#333333' -nf '#ffffff' -sb '#982323' -p "$" - +bindsym $mod+d exec dmenu_run -nb '#333333' -nf '#ffffff' -sb '#982323' -p "$" -fn 'Bitstream Vera Sans Mono-9' # change focus bindsym $mod+j focus left @@ -78,19 +77,7 @@ bindsym $mod+q focus parent # bindsym $mod+x move workspace to output right bindsym $mod+b workspace back_and_forth -# bindsym $mod+F1 workspace "1: IRC" -# bindsym $mod+F2 workspace "2: WWW" -# bindsym $mod+F3 workspace "3: MAIL" -# bindsym $mod+F4 workspace "4" -# bindsym $mod+F5 workspace "5" -# bindsym $mod+F6 workspace "6: MEDIA" -# bindsym $mod+F7 workspace "7" -# bindsym $mod+F8 workspace "8" -# bindsym $mod+F9 workspace "9" -# bindsym $mod+F10 workspace "10" -# bindsym $mod+F11 workspace "11" -# bindsym $mod+F12 workspace "12" - +# Go to a workspace bindsym $mod+F1 workspace "1. IRC" bindsym $mod+F2 workspace "2. WWW" bindsym $mod+F3 workspace "3. MAIL" @@ -98,28 +85,13 @@ bindsym $mod+F4 workspace "4" bindsym $mod+F5 workspace "5" bindsym $mod+F6 workspace "6. MEDIA" bindsym $mod+F7 workspace "7: WORK" -bindsym $mod+F8 workspace "8" +bindsym $mod+F8 workspace "8: VM" bindsym $mod+F9 workspace "9" bindsym $mod+F10 workspace "10" bindsym $mod+F11 workspace "11" bindsym $mod+F12 workspace "12" - - # move focused container to workspace -# bindsym $mod+Shift+F1 move container to workspace "1: IRC" -# bindsym $mod+Shift+F2 move container to workspace "2: WWW" -# bindsym $mod+Shift+F3 move container to workspace "3: MAIL" -# bindsym $mod+Shift+F4 move container to workspace "4" -# bindsym $mod+Shift+F5 move container to workspace "5" -# bindsym $mod+Shift+F6 move container to workspace "6: MEDIA" -# bindsym $mod+Shift+F7 move container to workspace "7" -# bindsym $mod+Shift+F8 move container to workspace "8" -# bindsym $mod+Shift+F9 move container to workspace "9" -# bindsym $mod+Shift+F10 move container to workspace "10" -# bindsym $mod+Shift+F11 move container to workspace "11" -# bindsym $mod+Shift+F12 move container to workspace "12" - bindsym $mod+Shift+F1 move container to workspace "1. IRC" bindsym $mod+Shift+F2 move container to workspace "2. WWW" bindsym $mod+Shift+F3 move container to workspace "3. MAIL" @@ -127,7 +99,7 @@ bindsym $mod+Shift+F4 move container to workspace "4" bindsym $mod+Shift+F5 move container to workspace "5" bindsym $mod+Shift+F6 move container to workspace "6. MEDIA" bindsym $mod+Shift+F7 move container to workspace "7: WORK" -bindsym $mod+Shift+F8 move container to workspace "8" +bindsym $mod+Shift+F8 move container to workspace "8: VM" bindsym $mod+Shift+F9 move container to workspace "9" bindsym $mod+Shift+F10 move container to workspace "10" bindsym $mod+Shift+F11 move container to workspace "11" @@ -172,12 +144,13 @@ bindsym $mod+r mode "resize" # finds out, if available) bar { - status_command ~/.i3/i3status.sh + #status_command ~/.i3/i3status.sh + status_command i3blocks -c /home/simon/.i3/bar/bar1.conf position top output eDP1 output DP1 output HDMI1 - + colors { #background #111111 background #000000 @@ -187,7 +160,7 @@ bar { active_workspace #333333 #5f676a #ffffff inactive_workspace #111111 #111111 #888888 urgent_workspace #2f343a #87af15 #ffffff - } + } } #bar { @@ -203,11 +176,12 @@ bar { # active_workspace #333333 #5f676a #ffffff # inactive_workspace #111111 #111111 #888888 # urgent_workspace #2f343a #87af15 #ffffff -# } +# } #} bar { status_command ~/.i3/processList.sh + #status_command i3blocks workspace_buttons yes position top tray_output none @@ -226,7 +200,7 @@ bar { active_workspace #333333 #5f676a #ffffff inactive_workspace #111111 #111111 #888888 urgent_workspace #2f343a #87af15 #ffffff - } + } } for_window [title="OBS"] floating enable @@ -244,6 +218,7 @@ for_window [title="Wicd"] floating enable for_window [title="Qalculate!"] floating enable for_window [title="Gnuplot"] floating enable for_window [title="Network Connect"] floating enable +for_window [title="Android Emulator"] floating enable for_window [title=".*"] border 1pixel #exec utox @@ -258,7 +233,7 @@ exec alsactl init -c 1 exec volumeicon exec /home/simon/bin/sshplus.py exec dunst -exec /home/simon/bin/dual_screen_dp1.sh off +exec sleep 2 && /home/simon/bin/dual_screen_dp1.sh off exec /home/simon/bin/reload_wallpaper exec redshift-gtk -l 47.51659:6.7809 #exec pulseaudio --start @@ -266,11 +241,10 @@ exec redshift-gtk -l 47.51659:6.7809 # exec synclient MiddleButtonAreaLeft=2700 # exec synclient MiddleButtonAreaRight=3500 # exec synclient MiddleButtonAreaLeft=2700 -exec xcompmgr -c +# exec xcompmgr -c exec xbacklight + 100 # Softwares bind - bindsym Print exec ~/bin/screenshot bindsym mod1+F10 exec ~/bin/screenshot_zone bindsym $mod+Print exec ~/bin/upload_wall @@ -327,6 +301,8 @@ bindsym XF86Mail exec icedove bindsym $mod+l exec mlclipboard +bindsym $mod+Shift+S exec i3-msg "sticky toggle" + # class border backgr. text indicator client.focused #9B2A5D #000000 #ffffff #2e9ef4 client.focused_inactive #333333 #5f676a #ffffff #484e50