1
0

Add information display script

This commit is contained in:
Arti Zirk 2023-09-24 15:49:41 +03:00
parent 7375f10887
commit 50b89c1d4a

43
display.sh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
#set -x
msg() {
./ssd1306_bin "$@"
}
netaddrs() {
ip -p -o -br -4 address show | (
current_line=1
while IFS= read -r line; do
IFS=' ' read -r -a iface <<< "$line"
if [[ "${iface[0]}" == lo* ]]; then
continue
fi
msg -x0 -y$current_line -m "${iface[0]} ${iface[1]} "
((current_line=current_line+1))
if [[ ${#iface[@]} -gt 2 ]]; then
for addr in ${iface[@]:2}; do
msg -x4 -y$current_line -l "${addr}"
((current_line=current_line+1))
done
fi
done
)
}
msg -I 128x64 -c -i 0 -x 0 -y 0 -f 1 -l "`hostname`"
msg -x0 -y 7 -l " <- X ->"
while true; do
netaddrs
msg -f 0 -x 8 -y 6 -l "`date '+%Y-%m-%d %H:%M:%S'`"
sleep 1
done