1
0
mirror of https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git synced 2025-09-02 20:52:41 +02:00
Files
xiaomi-dafang-hacks/firmware_mod/controlscripts/auto-night-detection
Combie81 5548ab554f Moving config entries/cleanup
Moved some configutation options to the config files

Minor text changes

Converted a lot of spaces to tabs
2020-07-16 10:20:39 +02:00

47 lines
922 B
Bash

#!/bin/sh
PIDFILE="/run/auto-night-detection.pid"
CONF_FILE="/system/sdcard/config/autonight.conf"
status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
. $CONF_FILE
if [ -f /run/auto-night-detection.pid ]; then
echo "Auto night detection already running";
else
if [ "$autonight_mode" == "sw" ]; then
echo "Starting software auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $sw_parameters &>/dev/null &
else
echo "Starting hardware auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $hw_parameters &>/dev/null &
fi
echo "$!" > "$PIDFILE"
fi
}
stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid" && rm "$PIDFILE"
fi
}
if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
esac
fi