-
Notifications
You must be signed in to change notification settings - Fork 0
/
gauges_right.sh
89 lines (67 loc) · 3.32 KB
/
gauges_right.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
###############################################
# #
# Made by: Dario Novoa V. #
# darionovoa [ at ] ideartte.com #
# Activate the front "Gauges" LED lights #
# to show the amount of used space in the #
# specified device #
# #
# usage add * * * * * /path/to/this/script #
# to the end of your cronjobs #
# using: $ crontab -e #
# #
# This will execute the script every 1min #
# Read the README for a detailed step by step #
# #
###############################################
DISC=$1
PERCENT=`df -h|grep $DISC|awk '{print $5}'`
# Let's remove the % from the Percent variable like this var=${var%\%}
PERCENT=${PERCENT%\%}
if [ $PERCENT -le 25 ]
then
echo default-on > /sys/class/leds/status\:white\:right0/trigger
echo none > /sys/class/leds/status\:white\:right1/trigger
echo none > /sys/class/leds/status\:white\:right2/trigger
echo none > /sys/class/leds/status\:white\:right3/trigger
echo "Your using an amount of disk space that is less or equal to 25%"
elif [ $PERCENT -gt 25 -a $PERCENT -le 50 ]
then
echo default-on > /sys/class/leds/status\:white\:right0/trigger
echo default-on > /sys/class/leds/status\:white\:right1/trigger
echo none > /sys/class/leds/status\:white\:right2/trigger
echo none > /sys/class/leds/status\:white\:right3/trigger
echo "Your using an amount of disk space that is less or equal to 50%"
elif [ $PERCENT -gt 50 -a $PERCENT -le 75 ]
then
echo default-on > /sys/class/leds/status\:white\:right0/trigger
echo default-on > /sys/class/leds/status\:white\:right1/trigger
echo default-on > /sys/class/leds/status\:white\:right2/trigger
echo none > /sys/class/leds/status\:white\:right3/trigger
echo "Your using an amount of disk space that is less or equal to 75%"
elif [ $PERCENT -gt 75 -a $PERCENT -le 95 ]
then
echo default-on > /sys/class/leds/status\:white\:right0/trigger
echo default-on > /sys/class/leds/status\:white\:right1/trigger
echo default-on > /sys/class/leds/status\:white\:right2/trigger
echo none > /sys/class/leds/status\:white\:right3/trigger
echo "Your using an amount of disk space that is greater than 75 but less than 95%"
#When we hit 95% 972.8Mb or more flash the last 2 leds in a synchronized way to warn me Im running out of space
elif [ $PERCENT -gt 95 -a $PERCENT -le 100 ]
then
#3 is the upper most led and 0 is the one on the bottom
echo default-on > /sys/class/leds/status\:white\:right0/trigger
echo default-on > /sys/class/leds/status\:white\:right1/trigger
echo timer > /sys/class/leds/status\:white\:right2/trigger
echo 1000 > /sys/class/leds/status\:white\:right2/delay_on
echo timer > /sys/class/leds/status\:white\:right3/trigger
echo 500 > /sys/class/leds/status\:white\:right3/delay_on
echo "Your using an amount of disk space that is Greater or equal to 95%"
else
#We got no idea so let's turn all off
echo none > /sys/class/leds/status\:white\:right0/trigger
echo none > /sys/class/leds/status\:white\:right1/trigger
echo none > /sys/class/leds/status\:white\:right2/trigger
echo none > /sys/class/leds/status\:white\:right3/trigger
fi