Bring more color to the i3bar
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
647e190761
commit
4ae353dc51
11 changed files with 62 additions and 34 deletions
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
u=$(checkupdates | wc -l)
|
||||
[ $u -gt 0 ] || exit
|
||||
|
|
|
@ -8,7 +8,13 @@ done
|
|||
|
||||
bat_cap=()
|
||||
for bat in $(find /sys/class/power_supply -type l -name 'B*'); do
|
||||
bat_cap+=("$(cat "${bat}/capacity")%")
|
||||
color='#ffffff'
|
||||
cap=$(cat "${bat}/capacity")
|
||||
|
||||
[ ${cap} -lt 50 ] && color='#ffd966'
|
||||
[ ${cap} -lt 25 ] && color='#dd0000'
|
||||
|
||||
bat_cap+=("<span color=\"${color}\">${cap}%</span>")
|
||||
done
|
||||
|
||||
if [ ${ac_conn} -eq 0 ]; then
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
# Each block command defaults to the script name to avoid boilerplate.
|
||||
command=$HOME/.config/i3blocks/$BLOCK_NAME
|
||||
separator_block_width=15
|
||||
markup=none
|
||||
markup=pango
|
||||
|
||||
|
||||
[arch-update]
|
||||
|
@ -61,10 +61,3 @@ interval=10
|
|||
|
||||
[time]
|
||||
interval=1
|
||||
separator=false
|
||||
separator_block_width=30
|
||||
|
||||
|
||||
[empty]
|
||||
command=echo " "
|
||||
interval=once
|
||||
|
|
|
@ -19,7 +19,7 @@ def main():
|
|||
(mountpoint, total, available) = line.split('\t')
|
||||
fs[mountpoint] = (total, available)
|
||||
|
||||
color = ''
|
||||
color = '#50fa7b'
|
||||
|
||||
strings = []
|
||||
for mount, data in fs.items():
|
||||
|
@ -35,19 +35,16 @@ def main():
|
|||
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,
|
||||
]))
|
||||
strings.append('<span color="#8FAAFC">{}</span>: <span color="{}">{:.0f}%</span>'.format(
|
||||
mount,
|
||||
color,
|
||||
usage,
|
||||
))
|
||||
|
||||
print('\ufaed '+' '.join(strings))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
printf '\uf6e2 '
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
which getxkblayout >/dev/null 2>/dev/null || {
|
||||
printf '\uf071 getxkblayout package missing'
|
||||
|
|
|
@ -1,5 +1,31 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/python
|
||||
|
||||
printf '\uf085 '
|
||||
import multiprocessing
|
||||
import os
|
||||
|
||||
uptime | sed 's/.*average: //'
|
||||
|
||||
def load_fmt(load):
|
||||
cores = multiprocessing.cpu_count()
|
||||
color = '#ffffff'
|
||||
|
||||
if load > cores * 0.5:
|
||||
color = '#FFD966'
|
||||
|
||||
if load > cores * 0.7:
|
||||
color = '#dd0000'
|
||||
|
||||
return '<span color="{}">{:.2f}</span>'.format(color, load)
|
||||
|
||||
|
||||
def main():
|
||||
load1, load5, load15 = os.getloadavg()
|
||||
|
||||
print('\uf085 {}, {}, {}'.format(
|
||||
load_fmt(load1),
|
||||
load_fmt(load5),
|
||||
load_fmt(load15),
|
||||
))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
printf '\uf85a '
|
||||
mem_use=$(free | awk '/Mem:/{ printf "%.0f", (($2 - $7) / $2) * 100 }')
|
||||
|
||||
free | awk '/Mem:/{ printf "%.0f%", (($2 - $7) / $2) * 100 }'
|
||||
color='#ffffff'
|
||||
[ ${mem_use} -gt 70 ] && color='#ffd966'
|
||||
[ ${mem_use} -gt 90 ] && color='#dd0000'
|
||||
|
||||
printf '\uf85a <span color="%s">%.0f%%</span>' ${color} ${mem_use}
|
||||
|
|
|
@ -18,17 +18,13 @@ def main():
|
|||
if temp > max_temp:
|
||||
max_temp = temp
|
||||
|
||||
text = '\uf2c7 {:.1f}°C'.format(max_temp)
|
||||
color = ''
|
||||
|
||||
color = '#ffffff'
|
||||
if max_temp > CRIT:
|
||||
color = '#dd0000'
|
||||
|
||||
print('\n'.join([
|
||||
text,
|
||||
text,
|
||||
color,
|
||||
]))
|
||||
text = '\uf2c7 <span color="{}">{:.1f}°C</span>'.format(color, max_temp)
|
||||
|
||||
print(text)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
DIFF=$(${HOME}/bin/tmux-chrony-timediff)
|
||||
[ -n "${DIFF}" ] && DIFF="(${DIFF})"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
interface=$(ip a | grep 'wlp.*:' | sed -E 's/^[0-9]*: ([^:]+):.*/\1/')
|
||||
|
||||
|
@ -15,4 +16,4 @@ network=$(iwgetid -r)
|
|||
# We found no network: Get out here
|
||||
[ -z "${network}" ] && exit
|
||||
|
||||
printf "\uf1eb %s (%s)" ${network} ${ip}
|
||||
printf "\uf1eb <span color=\"#8FAAFC\">%s</span> <span color=\"#50fa7b\">(%s)</span>" ${network} ${ip}
|
||||
|
|
Loading…
Reference in a new issue