Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- # desc: adjusts screen brightness via menu + args
- # created:: Jul 9th 2012
- # updated: Jul 24th 2012.
- dir="/sys/class/backlight/intel_backlight"
- level=$(cat "$dir/brightness")
- max=$(cat "$dir/max_brightness")
- div=$(($max/10))
- cycle=$(($max/20))
- function commit {
- echo $1 > "$dir/brightness"
- echo -e "${cr}Set brightness to ${cy}$1${cr}/$max (${cy}$(($1*100/$max))%${cr}).${c0}"
- }
- function menu {
- if [ -n "$Err" ]; then
- echo "Invalid selection. [$Sel] Try again."
- fi
- echo
- echo -e "${cr}Screen brightness is ${cy}$level${cr}/$max (${cy}$(($level*100/$max))%${cr}). Options:"
- echo -e "- ${cy}1-10${cr} for 10%-100% brightness"
- echo -e "- ${cy}xvl, vl, l, m, h${cr} for 5%, 10%, 20%, 50%, 100% respectively"
- echo -e "- ${cy}''${cr} to increase by 5% or anything else to decrease by 5%"
- echo -e "- ${cy}e${cr} to exit script${c0}"
- read -p "- Make a selection: " Sel
- switch $Sel
- }
- function switch {
- case $1 in
- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
- commit $((div*$1))
- ;;
- h)
- commit $max
- ;;
- m)
- commit $(($max/2))
- ;;
- l)
- commit $(($max/5))
- ;;
- vl|l2)
- commit $(($max/10))
- ;;
- xvl|l3)
- commit $(($max/20))
- ;;
- #! /bin/bash
- # desc: adjusts screen brightness via menu + args
- # created:: Jul 9th 2012
- # updated: Jul 24th 2012.
- dir="/sys/class/backlight/intel_backlight"
- level=$(cat "$dir/brightness")
- max=$(cat "$dir/max_brightness")
- div=$(($max/10))
- cycle=$(($max/20))
- function commit {
- echo $1 > "$dir/brightness"
- echo -e "${cr}Set brightness to ${cy}$1${cr}/$max (${cy}$(($1*100/$max))%${cr}).${c0}"
- }
- function menu {
- if [ -n "$Err" ]; then
- echo "Invalid selection. [$Sel] Try again."
- fi
- echo
- echo -e "${cr}Screen brightness is ${cy}$level${cr}/$max (${cy}$(($level*100/$max))%${cr}). Options:"
- echo -e "- ${cy}1-10${cr} for 10%-100% brightness"
- echo -e "- ${cy}xvl, vl, l, m, h${cr} for 5%, 10%, 20%, 50%, 100% respectively"
- echo -e "- ${cy}''${cr} to increase by 5% or anything else to decrease by 5%"
- echo -e "- ${cy}e${cr} to exit script${c0}"
- read -p "- Make a selection: " Sel
- switch $Sel
- }
- function switch {
- case $1 in
- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
- commit $((div*$1))
- ;;
- h)
- commit $max
- ;;
- m)
- commit $(($max/2))
- ;;
- l)
- commit $(($max/5))
- ;;
- vl|l2)
- commit $(($max/10))
- ;;
- xvl|l3)
- commit $(($max/20))
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement