aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2016-12-22 10:22:36 +0100
committerache <ache@ache.one>2016-12-22 10:22:36 +0100
commit51d17c409488465eb957951e8b42fa3fa47dc272 (patch)
tree54b3fc557f1fd8d6ebf63f0a77c6b16de6bbb517
parentDetect Wireless interface (diff)
Use sudo only if needed
Now sudo will be only used if the user isn't in the group video. In case of the use of sudo, a message will explain that.
-rwxr-xr-xlight2.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/light2.sh b/light2.sh
index 20e68a9..40b9410 100755
--- a/light2.sh
+++ b/light2.sh
@@ -12,10 +12,22 @@ else
val="$1"
fi
+right="sudo"
+for r in `groups`; do
+ if [ $r == "video" ] ; then
+ right=""
+ fi
+done
+
+
+if [ -n right ] ; then
+ echo 'To not use sudo, add yourself to the group "video"'
+fi
+
if [ -n "$listBacklight" ] ; then
for backlight in "$listBacklight"
do
- echo "${val}" | sudo tee "/sys/class/backlight/${backlight}/brightness" 2>&1 /dev/null
+ echo "${val}" | $right tee "/sys/class/backlight/${backlight}/brightness" 2>&1 /dev/null
done
else
echo 'No backlight detected'