You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Botspot-Pi-Apps/etc/viewlog

33 lines
757 B
Bash

#!/bin/bash
#this script is executed whenever you click on an entry from the logviewer script. This script handles opening a text editor to view your log file.
DIRECTORY="$(readlink -f "$(dirname "$(dirname "$0")")")"
file="$6"
if [ -z "$file" ];then
file="$1"
fi
echo "$file" > "$DIRECTORY/data/current-viewed-logfile"
if command -v mousepad ;then
mousepad "$file" &
pid=$!
elif command -v leafpad ;then
leafpad "$file" &
pid=$!
else
#for text_editor function
source "${DIRECTORY}/api"
text_editor "$file" &
pid=$!
fi
#while the user-selection stays the same, AND the text editor is still running, wait.
while [ "$(cat "$DIRECTORY/data/current-viewed-logfile")" == "$file" ] && kill -0 $pid;do
sleep 1
done
kill $pid 2>/dev/null