From 73909187df8ad31c630e8f753c19fd2a00f19533 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 3 Oct 2021 16:54:22 +0300 Subject: feat(rpi): add services and packages to dashboard --- raspberry/.config/tmuxinator/display.yml | 8 +++++--- raspberry/.local/bin/clock.sh | 2 ++ raspberry/.local/bin/services-status.sh | 27 +++++++++++++++++++++++++++ raspberry/.local/bin/temp.sh | 4 ++++ raspberry/clock.sh | 2 -- raspberry/temp.sh | 4 ---- 6 files changed, 38 insertions(+), 9 deletions(-) create mode 100755 raspberry/.local/bin/clock.sh create mode 100755 raspberry/.local/bin/services-status.sh create mode 100755 raspberry/.local/bin/temp.sh delete mode 100755 raspberry/clock.sh delete mode 100755 raspberry/temp.sh diff --git a/raspberry/.config/tmuxinator/display.yml b/raspberry/.config/tmuxinator/display.yml index 64450c2..bf615b5 100644 --- a/raspberry/.config/tmuxinator/display.yml +++ b/raspberry/.config/tmuxinator/display.yml @@ -5,6 +5,8 @@ windows: - dashboard: layout: main-vertical panes: - - cbonsai --life 40 --time 60 -liWC -m=$(/opt/vc/bin/vcgencmd measure_temp) - - ./clock.sh - - pipes.sh -t 5 -p 10 + - cbonsai --life 40 --time 60 -liWC + - clock.sh + - watch --no-title -n 60 /opt/vc/bin/vcgencmd measure_temp + - watch --no-title --color -n 5 services-status.sh + - watch --no-title -n 3600 "echo $(pacman -Qu | wc -l) packages waiting to be upgraded && pacman -Qu" diff --git a/raspberry/.local/bin/clock.sh b/raspberry/.local/bin/clock.sh new file mode 100755 index 0000000..8cd5b4a --- /dev/null +++ b/raspberry/.local/bin/clock.sh @@ -0,0 +1,2 @@ +#!/bin/sh +tty-clock -scnS diff --git a/raspberry/.local/bin/services-status.sh b/raspberry/.local/bin/services-status.sh new file mode 100755 index 0000000..5eabee2 --- /dev/null +++ b/raspberry/.local/bin/services-status.sh @@ -0,0 +1,27 @@ +#!/bin/sh +SERVICES="nginx taskd syncthing@eug-vs sshd iwd chronyd" +USER_SERVICES="spotifyd" + +RED='\033[1;31m' +GREEN='\033[1;32m' +NC='\033[0m' # No Color + +for SERVICE in $SERVICES $USER_SERVICES; do + if [[ $(echo $USER_SERVICES | grep $SERVICE) ]]; then + SYSTEMD="systemctl --user" + else + SYSTEMD="systemctl" + fi; + + IS_ACTIVE=$($SYSTEMD is-active $SERVICE) + + if [[ "$IS_ACTIVE" == 'active' ]]; then + INDICATOR="$GREEN *$NC" + STATUS="$GREEN $IS_ACTIVE $NC" + else + STATUS="$RED $IS_ACTIVE $NC" + INDICATOR="$RED *$NC" + fi; + + echo -e "$INDICATOR $SERVICE $STATUS" +done; diff --git a/raspberry/.local/bin/temp.sh b/raspberry/.local/bin/temp.sh new file mode 100755 index 0000000..2c60aa2 --- /dev/null +++ b/raspberry/.local/bin/temp.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# Show CPU temperature in a cool way. Requires superuser permissions. + +watch -n 2 --no-title "/opt/vc/bin/vcgencmd measure_temp | sed 's/temp=//' | figlet -W | /usr/bin/cowsay -f ghostbusters -n | sed 's/^/ /'" diff --git a/raspberry/clock.sh b/raspberry/clock.sh deleted file mode 100755 index 8cd5b4a..0000000 --- a/raspberry/clock.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -tty-clock -scnS diff --git a/raspberry/temp.sh b/raspberry/temp.sh deleted file mode 100755 index 2c60aa2..0000000 --- a/raspberry/temp.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Show CPU temperature in a cool way. Requires superuser permissions. - -watch -n 2 --no-title "/opt/vc/bin/vcgencmd measure_temp | sed 's/temp=//' | figlet -W | /usr/bin/cowsay -f ghostbusters -n | sed 's/^/ /'" -- cgit v1.2.3