aboutsummaryrefslogtreecommitdiffstats
path: root/bin/set_backlight
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-05-08 21:00:18 +0200
committerDavid Runge <dave@sleepmap.de>2016-05-08 21:00:18 +0200
commit2c2817931b08cba74c2f3b76a818bdb0acaaf82e (patch)
treebaac2a7ee02e78cb9ec03ac95a73dbc61289b3ad /bin/set_backlight
parentf143560385292600886a4826f254a76d53b41a68 (diff)
downloaddotfiles-2c2817931b08cba74c2f3b76a818bdb0acaaf82e.tar.gz
dotfiles-2c2817931b08cba74c2f3b76a818bdb0acaaf82e.tar.bz2
dotfiles-2c2817931b08cba74c2f3b76a818bdb0acaaf82e.tar.xz
dotfiles-2c2817931b08cba74c2f3b76a818bdb0acaaf82e.zip
bin/set_backlight: No separate backlight script for W540 needed, if kernel parameter acpi_backlight=vendor is given.
Diffstat (limited to 'bin/set_backlight')
-rwxr-xr-xbin/set_backlight56
1 files changed, 0 insertions, 56 deletions
diff --git a/bin/set_backlight b/bin/set_backlight
deleted file mode 100755
index c110321..0000000
--- a/bin/set_backlight
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-# Script to set backlight on startup on Lenovo W540 using
-# /sys/class/backlight/intel_backlight/brightness
-# This must be run as root.
-
-# check if root
-if [[ $EUID -ne 0 ]];then
- echo "This must be run as root."
-else
- # get current and maximum brightness, set maximum steps allowed
- brightness_current=$(cat /sys/class/backlight/intel_backlight/brightness)
- brightness_max=$(cat /sys/class/backlight/intel_backlight/max_brightness)
- brightness_max=$(($brightness_max-1000))
- brightness_steps=20
- brightness_steps_width=$(($brightness_max/$brightness_steps))
- brightness_new=0
- # if first parameter to this script is a number
- re='^[0-9]+$'
- if [[ $1 =~ $re ]]; then
- echo "Direct step called"
- if [[ $1 -gt brightness_steps && $1 -ne 0 ]];then
- brightness_new=$(($1*brightness_steps_width))
- fi
- elif [[ $1 == "up" || $1 == "down" ]];then
- brightness_calc=$(($brightness_current / $brightness_steps_width))
- case $1 in
- "up" )
- brightness_calc=$((($brightness_calc+1) * $brightness_steps_width))
- echo "brightness_calc: $brightness_calc"
- echo "brightness_max: $brightness_max"
- if [[ $brightness_max -gt $brightness_calc ]];then
- echo "true"
- brightness_new=$brightness_calc
- else
- echo "false"
- brightness_new=$brightness_current
- fi
- ;;
- "down" )
- brightness_calc=$((($brightness_calc-1) * $brightness_steps_width))
- echo "brightness_calc: $brightness_calc"
- if [[ $brightness_calc -gt 0 ]];then
- brightness_new=$brightness_calc
- else
- brightness_new=$brightness_current
- fi
- ;;
- esac
- echo "Step called with: $1"
- fi
- echo $brightness_current
- echo $brightness_new
- # set to 234 (around 4th step)
- #echo 234 > /sys/class/backlight/intel_backlight/brightness
- echo $brightness_new > /sys/class/backlight/intel_backlight/brightness
-fi