Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. # desc: adjusts screen brightness via menu + args
  4. # created:: Jul 9th 2012
  5. # updated: Jul 24th 2012.
  6.  
  7. dir="/sys/class/backlight/intel_backlight"
  8. level=$(cat "$dir/brightness")
  9. max=$(cat "$dir/max_brightness")
  10. div=$(($max/10))
  11. cycle=$(($max/20))
  12.  
  13. function commit {
  14. echo $1 > "$dir/brightness"
  15. echo -e "${cr}Set brightness to ${cy}$1${cr}/$max (${cy}$(($1*100/$max))%${cr}).${c0}"
  16. }
  17.  
  18. function menu {
  19. if [ -n "$Err" ]; then
  20. echo "Invalid selection. [$Sel] Try again."
  21. fi
  22. echo
  23. echo -e "${cr}Screen brightness is ${cy}$level${cr}/$max (${cy}$(($level*100/$max))%${cr}). Options:"
  24. echo -e "- ${cy}1-10${cr} for 10%-100% brightness"
  25. echo -e "- ${cy}xvl, vl, l, m, h${cr} for 5%, 10%, 20%, 50%, 100% respectively"
  26. echo -e "- ${cy}''${cr} to increase by 5% or anything else to decrease by 5%"
  27. echo -e "- ${cy}e${cr} to exit script${c0}"
  28. read -p "- Make a selection: " Sel
  29. switch $Sel
  30. }
  31.  
  32. function switch {
  33. case $1 in
  34. 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
  35. commit $((div*$1))
  36. ;;
  37. h)
  38. commit $max
  39. ;;
  40. m)
  41. commit $(($max/2))
  42. ;;
  43. l)
  44. commit $(($max/5))
  45. ;;
  46. vl|l2)
  47. commit $(($max/10))
  48. ;;
  49. xvl|l3)
  50. commit $(($max/20))
  51. ;;
  52. #! /bin/bash
  53.  
  54. # desc: adjusts screen brightness via menu + args
  55. # created:: Jul 9th 2012
  56. # updated: Jul 24th 2012.
  57.  
  58. dir="/sys/class/backlight/intel_backlight"
  59. level=$(cat "$dir/brightness")
  60. max=$(cat "$dir/max_brightness")
  61. div=$(($max/10))
  62. cycle=$(($max/20))
  63.  
  64. function commit {
  65. echo $1 > "$dir/brightness"
  66. echo -e "${cr}Set brightness to ${cy}$1${cr}/$max (${cy}$(($1*100/$max))%${cr}).${c0}"
  67. }
  68.  
  69. function menu {
  70. if [ -n "$Err" ]; then
  71. echo "Invalid selection. [$Sel] Try again."
  72. fi
  73. echo
  74. echo -e "${cr}Screen brightness is ${cy}$level${cr}/$max (${cy}$(($level*100/$max))%${cr}). Options:"
  75. echo -e "- ${cy}1-10${cr} for 10%-100% brightness"
  76. echo -e "- ${cy}xvl, vl, l, m, h${cr} for 5%, 10%, 20%, 50%, 100% respectively"
  77. echo -e "- ${cy}''${cr} to increase by 5% or anything else to decrease by 5%"
  78. echo -e "- ${cy}e${cr} to exit script${c0}"
  79. read -p "- Make a selection: " Sel
  80. switch $Sel
  81. }
  82.  
  83. function switch {
  84. case $1 in
  85. 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
  86. commit $((div*$1))
  87. ;;
  88. h)
  89. commit $max
  90. ;;
  91. m)
  92. commit $(($max/2))
  93. ;;
  94. l)
  95. commit $(($max/5))
  96. ;;
  97. vl|l2)
  98. commit $(($max/10))
  99. ;;
  100. xvl|l3)
  101. commit $(($max/20))
  102. ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement