-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path50-als.sh
More file actions
51 lines (46 loc) · 1.45 KB
/
Copy path50-als.sh
File metadata and controls
51 lines (46 loc) · 1.45 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
51
#!/bin/bash
# Author: Cata <xkill@locolandia.net>
# Description: Change the ALS status (HP laptop)
als-toggle(){
LOGGER="/usr/bin/logger"
APP=$0
ALSDEV="/sys/devices/platform/hp-wmi/als"
EXIT=0
if [ -f $ALSDEV -a -r $ALSDEV ]
then
STATUS=`cat $ALSDEV`
case "$STATUS" in
"0")
$LOGGER -i "ALS status is disabled"
;;
"1")
$LOGGER -i "ALS status is enabled"
;;
*)
$LOGGER -p user.err -i "ALS: unkown status [$STATUS]"
;;
esac
else
$LOGGER -p user.err -i "ALS: Can't read status at file $ALSDEV, check if module hp-wmi is loaded"
fi
if [ -w $ALSDEV ]
then
case "$STATUS" in
"0")
echo 1 > $ALSDEV && \
$LOGGER -i "ALS status changed: now is enabled" || \
$LOGGER -p user.err -i "Error changing ALS status to enabled"
;;
"1")
echo 0 > $ALSDEV && \
$LOGGER -i "ALS status changed: now is disabled" || \
$LOGGER -p user.err -i "Error changing ALS status to disabled"
;;
*)
$LOGGER -p user.err -i "ALS: unkown status [$STATUS]"
;;
esac
else
$LOGGER -p user.err -i "ALS: Can't change the status at file $ALSDEV, check if your user have permisions."
fi
}