From 511e029ec2718047f28b6b940fd22ac9ef2f3873 Mon Sep 17 00:00:00 2001 From: Dan Head Date: Thu, 16 Nov 2017 16:28:12 +0000 Subject: [PATCH] Swap i3blocks with polybar --- README.md | 2 +- i3/desktop.config | 60 ++--- i3blocks/desktop.config | 60 ----- i3blocks/openvpn.py | 25 -- i3blocks/ping.py | 17 -- i3blocks/wifi.sh | 20 -- polybar/config | 249 ++++++++++++++++++ polybar/launch.sh | 8 + polybar/scripts/bitcoin.py | 8 + polybar/scripts/cmus.sh | 32 +++ .../ipaddress.py => polybar/scripts/ipaddr.py | 3 +- polybar/scripts/pavolume.sh | 194 ++++++++++++++ polybar/scripts/ping.py | 7 + 13 files changed, 523 insertions(+), 162 deletions(-) delete mode 100644 i3blocks/desktop.config delete mode 100755 i3blocks/openvpn.py delete mode 100755 i3blocks/ping.py delete mode 100755 i3blocks/wifi.sh create mode 100644 polybar/config create mode 100755 polybar/launch.sh create mode 100755 polybar/scripts/bitcoin.py create mode 100755 polybar/scripts/cmus.sh rename i3blocks/ipaddress.py => polybar/scripts/ipaddr.py (79%) create mode 100755 polybar/scripts/pavolume.sh create mode 100755 polybar/scripts/ping.py diff --git a/README.md b/README.md index 78de6fc..b479185 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Folder | Description --- | --- bin | Binary files and scripts i3 | i3 config files -i3blocks | i3blocks config and associated scripts irssi | Irssi config and theme +polybar | polybar config and associated scripts termite | Termite config file and terminfo file vim | vimrc file and colours zsh | zsh config file and aliases diff --git a/i3/desktop.config b/i3/desktop.config index 1c22188..e0dff05 100644 --- a/i3/desktop.config +++ b/i3/desktop.config @@ -26,6 +26,8 @@ font pango:DejaVu Sans Mono 8 # X core fonts rendering does not support right-to-left and this being a bitmap # font, it doesn’t scale on retina/hidpi displays. +new_window 1pixel + # Use Mouse+$mod to drag floating windows to their wanted position floating_modifier $mod @@ -36,7 +38,7 @@ bindsym $mod+Return exec termite bindsym $mod+Shift+q kill # start dmenu (a program launcher) -bindsym $mod+d exec dmenu_run +bindsym $mod+d exec dmenu_run -b -p ">" # There also is the (new) i3-dmenu-desktop which only displays applications # shipping a .desktop file. It is a wrapper around dmenu, so you need that # installed. @@ -126,17 +128,6 @@ bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcu # resize window (you can also use the mouse for that) mode "resize" { # These bindings trigger as soon as you enter the resize mode - - # Pressing left will shrink the window’s width. - # Pressing right will grow the window’s width. - # Pressing up will shrink the window’s height. - # Pressing down will grow the window’s height. - bindsym j resize shrink width 10 px or 10 ppt - bindsym k resize grow height 10 px or 10 ppt - bindsym l resize shrink height 10 px or 10 ppt - bindsym semicolon resize grow width 10 px or 10 ppt - - # same bindings, but for the arrow keys bindsym Left resize shrink width 10 px or 10 ppt bindsym Down resize grow height 10 px or 10 ppt bindsym Up resize shrink height 10 px or 10 ppt @@ -164,38 +155,33 @@ mode "$mode_system" { } bindsym $mod+Pause mode "$mode_system" -# Start i3bar to display a workspace bar (plus the system information i3status -# finds out, if available) -bar { - output DVI-0 - status_command i3blocks -c ~/.dotfiles/i3blocks/desktop.config - position bottom - mode dock - workspace_buttons yes - tray_output none - - font pango:DejaVu Sans Mono 10 - - colors { - background #191716 - statusline #ffffff - - focused_workspace #ffffff #285577 - active_workspace #ffffff #333333 - inactive_workspace #888888 #222222 - urgent_workspace #ffffff #900000 - } -} - # Pulse Audio controls -bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +2% #increase sound volume -bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -2% #decrease sound volume +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +1% #increase sound volume +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -1% #decrease sound volume bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound # Media keys bindsym XF86AudioPlay exec ~/.dotfiles/bin/mediakeys-play bindsym XF86AudioPause exec ~/.dotfiles/bin/mediakeys-play +mode "cmus" { + bindsym z exec --no-startup-id cmus-remote --previous + bindsym x exec --no-startup-id cmus-remote --play + bindsym c exec --no-startup-id cmus-remote --pause + bindsym v exec --no-startup-id cmus-remote --stop + bindsym b exec --no-startup-id cmus-remote --next + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+c mode "cmus" + exec xrandr --output DVI-0 --primary --mode 1920x1200 --pos 1200x390 --output DVI-1 --mode 1920x1200 --rotate left --pos 0x0 +exec --no-startup-id feh --bg-fill ~/wallpapers/Forest.png +exec --no-startup-id compton +exec_always --no-startup-id ~/.dotfiles/polybar/launch.sh + exec "setxkbmap gb" diff --git a/i3blocks/desktop.config b/i3blocks/desktop.config deleted file mode 100644 index 693b864..0000000 --- a/i3blocks/desktop.config +++ /dev/null @@ -1,60 +0,0 @@ -command=/usr/lib/i3blocks/$BLOCK_NAME -separator_block_width=12 - -[iface] -label=IPs: -interval=10 -separator=false - -[ip] -command=$HOME/.dotfiles/i3blocks/ipaddress.py -interval=60 -separator=false - -[ping] -command=$HOME/.dotfiles/i3blocks/ping.py -interval=10 -separator=false - -[vpn] -command=$HOME/.dotfiles/i3blocks/openvpn.py -interval=10 - -[load_average] -interval=10 - -[disk] -label=/ -instance=/ -interval=60 -separator=false - -[disk] -label=/home -interval=60 -separator=false - -[disk] -label=/mnt/repo -instance=/mnt/repo -interval=60 -separator=false - -[disk] -label=/tmp -instance=/tmp -interval=60 - -[memory] -label=RAM -interval=15 - -[volume] -label=Vol: -interval=1 -signal=12 - -[time] -command=date '+%d-%m-%Y %H:%M:%S' -interval=1 - diff --git a/i3blocks/openvpn.py b/i3blocks/openvpn.py deleted file mode 100755 index ddb11e1..0000000 --- a/i3blocks/openvpn.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python -import subprocess -import re - -ps = subprocess.Popen('ps ax | grep openvpn | grep -v grep | tail -l | rev | cut -d \'/\' -f 1 | rev', shell=True, stdout=subprocess.PIPE) -line = str(ps.stdout.readline()) -process = str(ps.stdout.readline())[1:] -status = None -connected = False -if len(process) > 5: - connection = re.sub(r'[^0-9A-Za-z.]', '', process[1:]) - server = connection.upper().split('.')[0] - proto = re.sub(r'[^A-Z]', '', connection.upper().split('.')[3]) - status = '%s.%s' % (server, proto) - connected = True -else: - status = 'down' - -print('VPN: %s' % status) -print('VPN: %s' % status) - -if connected: - print('#00FF00') -else: - print('#FF0000') diff --git a/i3blocks/ping.py b/i3blocks/ping.py deleted file mode 100755 index f1c96ad..0000000 --- a/i3blocks/ping.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python -import subprocess -import re -url = 'google.co.uk' - -ps = subprocess.Popen('ping -c 1 %s | tail -1 | awk \'{print $4}\' | cut -d \'/\' -f 2' % url, shell=True, stdout=subprocess.PIPE) -ping = re.sub(r'[^0-9.]', '', str(ps.stdout.read())) - -print('Ping %sms' % ping) -print('Ping %sms' % ping) - -if float(ping) > 100: - print('#FF0000') -elif float(ping) > 50: - print('#DDDD00') -else: - print('#00FF00') diff --git a/i3blocks/wifi.sh b/i3blocks/wifi.sh deleted file mode 100755 index d7c72ad..0000000 --- a/i3blocks/wifi.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -INTERFACE="wlo1" - -SSID=$(iw dev $INTERFACE link | grep 'SSID' | awk -F: '/SSID/ { print $NF }') - -QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') - -echo "$SSID ($QUALITY%)" # full text -echo "$SSID ($QUALITY%)" # short text - -# color -if [[ $QUALITY -ge 80 ]]; then - echo "#00FF00" -elif [[ $QUALITY -lt 80 ]]; then - echo "#FFF600" -elif [[ $QUALITY -lt 60 ]]; then - echo "#FFAE00" -elif [[ $QUALITY -lt 40 ]]; then - echo "#FF0000" -fi diff --git a/polybar/config b/polybar/config new file mode 100644 index 0000000..25f3779 --- /dev/null +++ b/polybar/config @@ -0,0 +1,249 @@ +[colors] +background = #222 +background-alt = #444 +background-deep = #111 +foreground = #dfdfdf +foreground-alt = #555 +primary = #ffb52a +secondary = #e60053 +alert = #bd2c40 + +[bar/top] +monitor = ${env:MONITOR:DVI-0} +height = 25 +width = 100% +fixed-center = true +background = ${colors.background} +foreground = ${colors.foreground} +module-margin = 2 +font-0 = NotoSans\-Regular:pixelsize=10;2 +font-1 = FontAwesome:pixelsize=10;2 + +modules-left = topmenu pavolume +modules-center = cmus +modules-right = vpn ping date + +[bar/bottom] +monitor = ${env:MONITOR:DVI-0} +bottom = true +width = 100% +height = 25 +fixed-center = true +background = ${colors.background} +foreground = ${colors.foreground} +line-size = 0 +line-color = #f00 +padding-left = 0 +padding-right = 4 +module-margin = 4 +tray-position = left +tray-padding = 5 +tray-transparent = true +tray-background = #0063ff +font-0 = NotoSans\-Regular:pixelsize=10;2 +font-1 = FontAwesome:pixelsize=10;2 + +modules-left = i3 +modules-center = xwindow +modules-right = cpu memory + +[bar/bottom2] +monitor = ${env:MONITOR:DVI-1} +bottom = true +width = 100% +height = 25 +background = ${colors.background} +foreground = ${colors.foreground} +padding-left = 0 +padding-right = 4 +module-margin = 4 +font-0 = fixed:pixelsize=10;2 +font-1 = FontAwesome:pixelsize=10;2 + +modules-left = i3 bitcoin +modules-right = filesystem + +[module/bspwm] +type = internal/bspwm + +label-focused = %index% +label-focused-background = ${colors.background-alt} +label-focused-underline= ${colors.primary} +label-focused-padding = 2 + +label-occupied = %index% +label-occupied-padding = 2 + +label-urgent = %index%! +label-urgent-background = ${colors.alert} +label-urgent-padding = 2 + +label-empty = %index% +label-empty-foreground = ${colors.foreground-alt} +label-empty-padding = 2 + +[module/i3] +type = internal/i3 +format = +index-sort = true +wrapping-scroll = false + +; Only show workspaces on the same output as the bar +pin-workspaces = true + +label-mode-padding = 2 +label-mode-foreground = #000 +label-mode-background = ${colors.primary} + +; focused = Active workspace on focused monitor +label-focused = %index% +label-focused-background = ${module/bspwm.label-focused-background} +label-focused-underline = ${module/bspwm.label-focused-underline} +label-focused-padding = ${module/bspwm.label-focused-padding} + +; unfocused = Inactive workspace on any monitor +label-unfocused = %index% +label-unfocused-padding = ${module/bspwm.label-occupied-padding} + +; visible = Active workspace on unfocused monitor +label-visible = %index% +label-visible-background = ${self.label-focused-background} +label-visible-underline = ${self.label-focused-underline} +label-visible-padding = ${self.label-focused-padding} + +; urgent = Workspace with urgency hint set +label-urgent = %index% +label-urgent-background = ${module/bspwm.label-urgent-background} +label-urgent-padding = ${module/bspwm.label-urgent-padding} + +[module/xwindow] +type = internal/xwindow +label = %title% +label-maxlen = 30 + +[module/pavolume] +type = custom/script +tail = true +label = %output% +exec = ~/.dotfiles/polybar/scripts/pavolume.sh --listen +click-right = exec pavucontrol +click-left = ~/.dotfiles/polybar/scripts/pavolume.sh --togmute +scroll-up = ~/.dotfiles/polybar/scripts/pavolume.sh --up +scroll-down = ~/.dotfiles/polybar/scripts/pavolume.sh --down + +[module/bitcoin] +type = custom/script +interval = 300 +format =