This commit is contained in:
2017-09-06 18:25:17 +01:00
commit efb71c4e57
28 changed files with 6865 additions and 0 deletions

54
i3blocks/desktop.config Normal file
View File

@@ -0,0 +1,54 @@
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=30
separator=false
[disk]
label=/home
interval=30
separator=false
[disk]
label=/tmp
instance=/tmp
interval=30
[memory]
label=RAM
interval=30
[volume]
label=Vol:
interval=1
signal=12
[time]
command=date '+%d-%m-%Y %H:%M:%S'
interval=1

16
i3blocks/ipaddress.py Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/python
from urllib.request import urlopen
from xml.etree import ElementTree as ET
url = 'http://freegeoip.net/xml/'
with urlopen(url) as res:
s = res.read()
root = ET.fromstring(s)
ip = root.find('IP').text
country = root.find('CountryName').text
print('/ %s (%s)' % (ip, country))
print('/ %s (%s)' % (ip, country))

25
i3blocks/openvpn.py Executable file
View File

@@ -0,0 +1,25 @@
#!/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')

17
i3blocks/ping.py Executable file
View File

@@ -0,0 +1,17 @@
#!/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')

20
i3blocks/wifi.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/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