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
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
u=$(checkupdates | wc -l)
|
u=$(checkupdates | wc -l)
|
||||||
[ $u -gt 0 ] || exit
|
[ $u -gt 0 ] || exit
|
||||||
|
|
|
@ -8,7 +8,13 @@ done
|
||||||
|
|
||||||
bat_cap=()
|
bat_cap=()
|
||||||
for bat in $(find /sys/class/power_supply -type l -name 'B*'); do
|
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
|
done
|
||||||
|
|
||||||
if [ ${ac_conn} -eq 0 ]; then
|
if [ ${ac_conn} -eq 0 ]; then
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
# Each block command defaults to the script name to avoid boilerplate.
|
# Each block command defaults to the script name to avoid boilerplate.
|
||||||
command=$HOME/.config/i3blocks/$BLOCK_NAME
|
command=$HOME/.config/i3blocks/$BLOCK_NAME
|
||||||
separator_block_width=15
|
separator_block_width=15
|
||||||
markup=none
|
markup=pango
|
||||||
|
|
||||||
|
|
||||||
[arch-update]
|
[arch-update]
|
||||||
|
@ -61,10 +61,3 @@ interval=10
|
||||||
|
|
||||||
[time]
|
[time]
|
||||||
interval=1
|
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')
|
(mountpoint, total, available) = line.split('\t')
|
||||||
fs[mountpoint] = (total, available)
|
fs[mountpoint] = (total, available)
|
||||||
|
|
||||||
color = ''
|
color = '#50fa7b'
|
||||||
|
|
||||||
strings = []
|
strings = []
|
||||||
for mount, data in fs.items():
|
for mount, data in fs.items():
|
||||||
|
@ -35,19 +35,16 @@ def main():
|
||||||
if float(data[0]) > 0.0:
|
if float(data[0]) > 0.0:
|
||||||
usage = (1 - float(data[1])/float(data[0])) * 100.0
|
usage = (1 - float(data[1])/float(data[0])) * 100.0
|
||||||
|
|
||||||
strings.append('{}: {:.0f}%'.format(
|
|
||||||
mount,
|
|
||||||
usage,
|
|
||||||
))
|
|
||||||
|
|
||||||
if usage > CRIT:
|
if usage > CRIT:
|
||||||
color = '#dd0000'
|
color = '#dd0000'
|
||||||
|
|
||||||
print('\ufaed '+'\n'.join([
|
strings.append('<span color="#8FAAFC">{}</span>: <span color="{}">{:.0f}%</span>'.format(
|
||||||
' '.join(strings),
|
mount,
|
||||||
' '.join(strings),
|
color,
|
||||||
color,
|
usage,
|
||||||
]))
|
))
|
||||||
|
|
||||||
|
print('\ufaed '+' '.join(strings))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
printf '\uf6e2 '
|
printf '\uf6e2 '
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
which getxkblayout >/dev/null 2>/dev/null || {
|
which getxkblayout >/dev/null 2>/dev/null || {
|
||||||
printf '\uf071 getxkblayout package missing'
|
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
|
#!/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:
|
if temp > max_temp:
|
||||||
max_temp = temp
|
max_temp = temp
|
||||||
|
|
||||||
text = '\uf2c7 {:.1f}°C'.format(max_temp)
|
color = '#ffffff'
|
||||||
color = ''
|
|
||||||
|
|
||||||
if max_temp > CRIT:
|
if max_temp > CRIT:
|
||||||
color = '#dd0000'
|
color = '#dd0000'
|
||||||
|
|
||||||
print('\n'.join([
|
text = '\uf2c7 <span color="{}">{:.1f}°C</span>'.format(color, max_temp)
|
||||||
text,
|
|
||||||
text,
|
print(text)
|
||||||
color,
|
|
||||||
]))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
DIFF=$(${HOME}/bin/tmux-chrony-timediff)
|
DIFF=$(${HOME}/bin/tmux-chrony-timediff)
|
||||||
[ -n "${DIFF}" ] && DIFF="(${DIFF})"
|
[ -n "${DIFF}" ] && DIFF="(${DIFF})"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
interface=$(ip a | grep 'wlp.*:' | sed -E 's/^[0-9]*: ([^:]+):.*/\1/')
|
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
|
# We found no network: Get out here
|
||||||
[ -z "${network}" ] && exit
|
[ -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