First draft of i3blocks status bar
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
e0fbd6d874
commit
001b490654
11 changed files with 253 additions and 0 deletions
21
.config/i3blocks/battery
Executable file
21
.config/i3blocks/battery
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
BATTERY=/sys/class/power_supply/BAT0
|
||||
|
||||
ac_conn=0
|
||||
|
||||
for ac in $(find /sys/class/power_supply -type l -name 'A*'); do
|
||||
[ $(cat "${ac}/online") -eq 1 ] && ac_conn=1
|
||||
done
|
||||
|
||||
bat_cap=()
|
||||
for bat in $(find /sys/class/power_supply -type l -name 'B*'); do
|
||||
bat_cap+="$(cat "${bat}/capacity")%"
|
||||
done
|
||||
|
||||
if [ ${ac_conn} -eq 0 ]; then
|
||||
printf '\uf58d %s' ${bat_cap[@]}
|
||||
else
|
||||
printf '\uf740 %s' ${bat_cap[@]}
|
||||
fi
|
67
.config/i3blocks/config
Normal file
67
.config/i3blocks/config
Normal file
|
@ -0,0 +1,67 @@
|
|||
# i3blocks config file
|
||||
#
|
||||
# Please see man i3blocks for a complete reference!
|
||||
# The man page is also hosted at http://vivien.github.io/i3blocks
|
||||
#
|
||||
# List of valid properties:
|
||||
#
|
||||
# align
|
||||
# color
|
||||
# command
|
||||
# full_text
|
||||
# instance
|
||||
# interval
|
||||
# label
|
||||
# min_width
|
||||
# name
|
||||
# separator
|
||||
# separator_block_width
|
||||
# short_text
|
||||
# signal
|
||||
# urgent
|
||||
|
||||
# Global properties
|
||||
#
|
||||
# The top properties below are applied to every block, but can be overridden.
|
||||
# Each block command defaults to the script name to avoid boilerplate.
|
||||
command=$HOME/.config/i3blocks/$BLOCK_NAME
|
||||
separator_block_width=15
|
||||
markup=none
|
||||
|
||||
|
||||
[disk]
|
||||
interval=30
|
||||
|
||||
[volume]
|
||||
interval=1
|
||||
|
||||
[dropbox]
|
||||
interval=30
|
||||
|
||||
[keyboard]
|
||||
interval=2
|
||||
|
||||
[mem]
|
||||
interval=30
|
||||
|
||||
[load]
|
||||
interval=30
|
||||
|
||||
[wifi]
|
||||
interval=30
|
||||
|
||||
[battery]
|
||||
interval=30
|
||||
|
||||
[temp]
|
||||
interval=10
|
||||
|
||||
[time]
|
||||
interval=1
|
||||
separator=false
|
||||
separator_block_width=30
|
||||
|
||||
|
||||
[empty]
|
||||
command=echo " "
|
||||
interval=once
|
54
.config/i3blocks/disk
Executable file
54
.config/i3blocks/disk
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
CRIT = 90.0
|
||||
MOUNT_BLACKLIST = ['/dev', '/efi', '/proc', '/run', '/sys', '/tmp']
|
||||
|
||||
|
||||
def main():
|
||||
output = subprocess.check_output([
|
||||
'sh', '-c', 'df -a -B 1 | awk \'{ printf "%s\\t%d\\t%d\\n", $6, $2, $4 }\''
|
||||
]).decode('utf-8')
|
||||
|
||||
fs = {}
|
||||
for line in output.split('\n'):
|
||||
if len(line) == 0 or line[0] != '/':
|
||||
continue
|
||||
(mountpoint, total, available) = line.split('\t')
|
||||
fs[mountpoint] = (total, available)
|
||||
|
||||
color = ''
|
||||
|
||||
strings = []
|
||||
for mount, data in fs.items():
|
||||
skip = False
|
||||
for b in MOUNT_BLACKLIST:
|
||||
if mount.startswith(b):
|
||||
skip = True
|
||||
|
||||
if skip:
|
||||
continue
|
||||
|
||||
usage = 0.0
|
||||
if float(data[0]) > 0.0:
|
||||
usage = (1 - float(data[1])/float(data[0])) * 100.0
|
||||
|
||||
strings.append('{}: {:.0f}%'.format(
|
||||
mount,
|
||||
usage,
|
||||
))
|
||||
|
||||
if usage > CRIT:
|
||||
color = '#dd0000'
|
||||
|
||||
print('\ufaed '+'\n'.join([
|
||||
' '.join(strings),
|
||||
' '.join(strings),
|
||||
color,
|
||||
]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
5
.config/i3blocks/dropbox
Executable file
5
.config/i3blocks/dropbox
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
printf '\uf6e2 '
|
||||
|
||||
${HOME}/bin/dropbox.py status | head -n1 || true
|
10
.config/i3blocks/keyboard
Executable file
10
.config/i3blocks/keyboard
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
which getxkblayout >/dev/null 2>/dev/null || {
|
||||
printf '\uf071 getxkblayout package missing'
|
||||
exit 1
|
||||
}
|
||||
|
||||
printf '\uf812 '
|
||||
|
||||
getxkblayout | awk '/short/{ print $2 }'
|
5
.config/i3blocks/load
Executable file
5
.config/i3blocks/load
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
printf '\uf085 '
|
||||
|
||||
uptime | sed 's/.*average: //'
|
5
.config/i3blocks/mem
Executable file
5
.config/i3blocks/mem
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
printf '\uf85a '
|
||||
|
||||
free | awk '/Mem:/{ printf "%.0f%", (($2 - $7) / $2) * 100 }'
|
35
.config/i3blocks/temp
Executable file
35
.config/i3blocks/temp
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
CRIT = 70.0
|
||||
|
||||
|
||||
def main():
|
||||
sensors = subprocess.check_output(['sensors', '-u']).decode('utf-8')
|
||||
|
||||
max_temp = 0.0
|
||||
for line in sensors.split('\n'):
|
||||
if not re.match(r'.*temp._input:.*', line):
|
||||
continue
|
||||
temp = float(line.split(':')[1])
|
||||
|
||||
if temp > max_temp:
|
||||
max_temp = temp
|
||||
|
||||
text = '\uf2c7 {:.1f}°C'.format(max_temp)
|
||||
color = ''
|
||||
|
||||
if max_temp > CRIT:
|
||||
color = '#dd0000'
|
||||
|
||||
print('\n'.join([
|
||||
text,
|
||||
text,
|
||||
color,
|
||||
]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
5
.config/i3blocks/time
Executable file
5
.config/i3blocks/time
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
printf '\uf5ec '
|
||||
|
||||
date "+%Y-%m-%d %H:%M:%S"
|
28
.config/i3blocks/volume
Executable file
28
.config/i3blocks/volume
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import subprocess
|
||||
|
||||
|
||||
def main():
|
||||
volume = subprocess.check_output([
|
||||
'pulsemixer', '--get-volume',
|
||||
]).decode('utf-8').strip().split(' ')
|
||||
minvol = min([int(i) for i in volume])
|
||||
|
||||
mute = int(subprocess.check_output([
|
||||
'pulsemixer', '--get-mute',
|
||||
]).decode('utf-8').strip()) == 1
|
||||
|
||||
icon = '\uf9c3' if mute else '\uf9c2'
|
||||
text = '{} {}%'.format(icon, minvol)
|
||||
color = '#7f7f7f' if mute else ''
|
||||
|
||||
print('\n'.join([
|
||||
text,
|
||||
text,
|
||||
color,
|
||||
]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
18
.config/i3blocks/wifi
Executable file
18
.config/i3blocks/wifi
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
interface=$(ip a | grep 'wlp.*:' | sed -E 's/^[0-9]*: ([^:]+):.*/\1/')
|
||||
|
||||
# We found no wlp* interface: Get out here
|
||||
[ -z "${interface}" ] && exit
|
||||
|
||||
ip=$(ip a show ${interface} | awk '/inet .* scope global/{ print $2 }' | cut -d '/' -f1)
|
||||
|
||||
# We found no ip: Get out here
|
||||
[ -z "${ip}" ] && exit
|
||||
|
||||
network=$(iwgetid -r)
|
||||
|
||||
# We found no network: Get out here
|
||||
[ -z "${network}" ] && exit
|
||||
|
||||
printf "\uf1eb %s (%s)" ${network} ${ip}
|
Loading…
Reference in a new issue