44 lines
753 B
Bash
44 lines
753 B
Bash
|
#!/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
|