-
Notifications
You must be signed in to change notification settings - Fork 8
/
nvidia-led.sh
executable file
·78 lines (68 loc) · 1.92 KB
/
nvidia-led.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
#! /bin/bash
app_version="1.0.0"
styles="/home/$USER/.config/nvidia-led/styles"
set_brightness() {
nvidia-settings -a GPULogoBrightness=$1 > /dev/null 2>&1
}
test_value() {
if [[ ! $3 =~ ^-?[0-9]+$ ]]; then
return 1
fi
[[ $3 -ge $1 && $3 -le $2 ]]
}
test_range() {
if [[ $3 != *"-"* ]]; then
return 1
fi
min=$(echo $3 | cut -d "-" -f1)
max=$(echo $3 | cut -d "-" -f2)
if $(test_value $1 $2 $min) && $(test_value $1 $2 $max); then
[ $min -le $max ];
else
return 1
fi
}
show_help() {
echo "nvidia-led: Awesome effects for NVIDIA GeForce GTX leds"
echo "Usage: nvidia-led [options] [values]"
echo -e "\nOptions:"
for animation in $(ls $styles); do
echo " $(source $styles/$animation info)"
done
echo " help Print this help"
echo " version Show version"
echo -e "\nValues:"
echo " intensity Light intensity of effect. Type: Integer/Range [0-100]. E.g., 80, 10-50, 0-100"
echo " interval Interval time of effect. Type: Integer [1-100]. E.g., 20, 100, 70"
exit 0
}
show_version() {
echo "nvidia-led $app_version"
exit 0
}
custom_style() {
if [[ $(ls $styles | grep $1.sh) ]]; then
source $styles/$1.sh $2 $3 $4
else
echo "Unknown argument. Try: 'nvidia-led help'"
fi
}
# MAIN
if [ ! -f "/usr/bin/nvidia-settings" ]; then
echo "'nvidia-settings' is not found. Need it to work. Exiting..."
exit 0
fi
if [[ $(nvidia-settings -q NvidiaDriverVersion | grep Attribute | tail -c 7) < 331.38 ]]; then
echo "'nvidia-settings' is not found. Need it to work. Exiting..."
exit 0
fi
case "$1" in
no-animation) source $styles/no-animation.sh $2 ;;
flashing) source $styles/flashing.sh $2 $3 ;;
dual-flashing) source $styles/dual-flashing.sh $2 $3 ;;
breathing) source $styles/breathing.sh $2 $3 $4 ;;
help) show_help ;;
version) show_version ;;
"") echo "Unknown argument. Try: 'nvidia-led help'" ;;
*) custom_style $1 $2 $3 $4 ;;
esac