Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

g14control.sh 2.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/usr/bin/env bash
  2. # g14control.sh
  3. #
  4. # version: 1.0
  5. # date: 2021-08-01
  6. # author: hmk
  7. # description: A hardware interface script for ASUS ROG Zephyrus G14 laptops.
  8. # Primary purpose is to give a minimal wrapper for hardware control in
  9. # minimal desktop environments or without any desktop environment a all.
  10. #
  11. # Tested on:
  12. # - GA401IH-BM013T (2020)
  13. #
  14. #
  15. # TODO:
  16. # - POSIX compliancy (currently uses non-POSIX-complient bash extensions)
  17. # - is amdgpu_bl0 the only dsiplay backlight interface? What happens when dGPU
  18. # is active?
  19. #
  20. disp() {
  21. # Changes display backlight to a given level or steps up/down
  22. INTERFACE="/sys/class/backlight/amdgpu_bl0/brightness"
  23. MAX=$(cat /sys/class/backlight/amdgpu_bl0/max_brightness)
  24. STEP=$((MAX/10))
  25. CURRLEVEL=$(cat ${INTERFACE})
  26. [[ ${1} =~ ^[0-9]{1,${#MAX}}$ && ! ${1} > ${MAX} ]] && \
  27. LEVEL=${1}
  28. [[ ${1} == "up" && ${CURRLEVEL} < ${MAX} ]] && \
  29. LEVEL=$((CURRLEVEL+STEP))
  30. [[ ${1} == "down" && ${CURRLEVEL} > 0 ]] && \
  31. LEVEL=$((CURRLEVEL-STEP))
  32. echo ${LEVEL}
  33. echo ${LEVEL} > ${INTERFACE}
  34. CHKLEVEL=$(cat ${INTERFACE})
  35. notify-send -t 500 "Display backlight level changed" \
  36. "${CURRLEVEL} -> ${CHKLEVEL}"
  37. }
  38. kbd() {
  39. # Changes keyboard backlight to a given level or steps up/down.
  40. # param:[0-3] set backlight level to NUM
  41. # param:up step backlight up
  42. # param:down step backlight down
  43. INTERFACE="/sys/class/leds/asus::kbd_backlight/brightness"
  44. MAX=$(cat /sys/class/leds/asus::kbd_backlight/max_brightness)
  45. CURRLEVEL=$(cat ${INTERFACE})
  46. [[ ${1} =~ ^[0-${MAX}]$ ]] && \
  47. LEVEL=${1}
  48. [[ ${1} == "up" && ${CURRLEVEL} < ${MAX} ]] && \
  49. LEVEL=$((CURRLEVEL+1))
  50. [[ ${1} == "down" && ${CURRLEVEL} > 0 ]] && \
  51. LEVEL=$((CURRLEVEL-1))
  52. echo ${LEVEL} > ${INTERFACE}
  53. CHKLEVEL=$(cat ${INTERFACE})
  54. notify-send -t 500 "Keyboard backlight level changed" \
  55. "${CURRLEVEL} -> ${CHKLEVEL}"
  56. }
  57. fan() {
  58. # Changes fan mode to a given mode or rotates through modes.
  59. # 0 = Normal/Balanced
  60. # 1 = Boost
  61. # 2 = Silent.
  62. # param:[0-2] Set fan mode to given mode
  63. # param:NONE Rotate through modes Balanced -> Boost -> Silent
  64. MODELIST=("Balanced" "Boost" "Silent")
  65. INTERFACE="/sys/devices/platform/asus-nb-wmi/throttle_thermal_policy"
  66. CURRMODE=$(cat ${INTERFACE})
  67. if [[ ${1} =~ ^[0-2]$ ]]; then
  68. MODE=${1}
  69. else
  70. if [[ ${CURRMODE} == 2 ]]; then
  71. MODE=0
  72. else
  73. let MODE=$((CURRMODE+1))
  74. fi
  75. fi
  76. echo ${MODE} > ${INTERFACE}
  77. CHKMODE=$(cat ${INTERFACE})
  78. notify-send -t 500 "Fan mode changed" \
  79. "${MODELIST[${CURRMODE}]} -> ${MODELIST[${CHKMODE}]}"
  80. }
  81. usage() {
  82. echo "Usage: $0 [-d LEVEL|up|down] [-k LEVEL|up|down] [-f [MODE]] [-h]"
  83. }
  84. while getopts "d:k:f:h" ARG; do
  85. case "${ARG}" in
  86. d)
  87. disp ${OPTARG}
  88. ;;
  89. k)
  90. kbd ${OPTARG}
  91. ;;
  92. f)
  93. fan ${OPTARG}
  94. ;;
  95. h)
  96. usage
  97. exit 0
  98. ;;
  99. *)
  100. usage
  101. exit 1
  102. ;;
  103. esac
  104. done
  105. exit 0