09-brightness.sh 485 B

123456789101112131415161718
  1. # shellcheck shell=sh
  2. (
  3. : "${BRIGHTNESS_DEV:=/sys/class/backlight/intel_backlight}"
  4. : "${BRIGHTNESS_SAVE:=/var/cache/brightness}"
  5. [ -r "${BRIGHTNESS_SAVE}" ] || exit
  6. read -r brightness < "${BRIGHTNESS_SAVE}"
  7. [ "${brightness}" -gt 100 ] || exit
  8. msg 'restoring brightness'
  9. [ -w "${BRIGHTNESS_DEV}/brightness" ] \
  10. && printf '%d' "${brightness}" > "${BRIGHTNESS_DEV}/brightness" \
  11. || error 'unable to restore brightness' \
  12. "(failed to write to '${BRIGHTNESS_DEV}/brightness')"
  13. ) &