-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinky_update.sh
More file actions
50 lines (40 loc) · 1.07 KB
/
inky_update.sh
File metadata and controls
50 lines (40 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
echo 0 > /home/pi/inky_update/status.txt
while true; do
PREV_STATE=$(cat /home/pi/inky_update/status.txt)
PSI_STAT_M="0"
PSI_STAT_T="0"
PSI_STAT_I="0"
SERVICE="MCLINK.EXE"
ps -ef | grep $SERVICE | grep -v grep > /dev/null
if [ $? -eq 0 ]
then
PSI_STAT_M="1"
else
PSI_STAT_M="0"
fi
# test if user is logged in via tty/USB
w | grep ttyUSB | grep -v grep > /dev/null
if [ $? -eq 0 ]
then
PSI_STAT_T="1"
else
PSI_STAT_T="0"
fi
# test if connected to internet
test=$(/home/pi/inky_update/test_conn.sh)
if [ "$test" = "we have connectivity" ]
then
PSI_STAT_I="1"
else
PSI_STAT_I="0"
fi
PSI_STATUS=$((2#$PSI_STAT_I$PSI_STAT_T$PSI_STAT_M))
echo $PSI_STATUS > /home/pi/inky_update/status.txt
if [ "$PSI_STATUS" != "$PREV_STATE" ]; then
# display bitmap MCLS-x.png where x is the status bitmap number 0-7
/usr/bin/python3 /home/pi/inky_update/inky_display.py $PSI_STATUS > /dev/null 2>&1
echo "`date`: "$PREV_STATE" "$PSI_STATUS >> /home/pi/inky_update/states.txt
fi
sleep 37
done