#!/bin/sh set -x set -e # Note the trailing slash # base="/sys/class/backlight/amdgpu_bl0/" base="/sys/class/backlight/intel_backlight/" percent="$1"; shift _backlight="${base}brightness" _max="${base}max_brightness" # Since `bc` is often not installed by default, just use awk _max="$(awk '{print $1/100;}' "$_max")" percent="$(echo "${percent}" | awk '{print int($1*'"$_max"');}')" echo $percent sudo sh -c "echo \"$percent\" > $_backlight"