From 50b89c1d4abf28501488ff7886fc541c0edba4f3 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Sun, 24 Sep 2023 15:49:41 +0300 Subject: [PATCH] Add information display script --- display.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 display.sh diff --git a/display.sh b/display.sh new file mode 100755 index 0000000..ac5c8f6 --- /dev/null +++ b/display.sh @@ -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