From e2ec6208875a1f54b438b3495a1374a0d304d3ee Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 29 Mar 2017 19:03:32 +0200 Subject: [PATCH] Provide useful W530 scripts in bin/. --- bin/w530_backlight.sh | 17 +++++++++++++++++ .../w530_startx_force_nvidia.sh | 0 2 files changed, 17 insertions(+) create mode 100755 bin/w530_backlight.sh rename dotfiles/user/thinkpad/W530/startx_force_nvidia.sh => bin/w530_startx_force_nvidia.sh (100%) diff --git a/bin/w530_backlight.sh b/bin/w530_backlight.sh new file mode 100755 index 0000000..bce6b30 --- /dev/null +++ b/bin/w530_backlight.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# A very primitive backlight setter with a hardcoded backlight path, to replace +# xbacklight which currently does not work on my system. +if ! echo "${1}" | egrep -q '^[0-9]+$'; then + echo 'Argument must be a number.' + exit 1 +fi +percentage=${1} +backlight_dir=/sys/class/backlight/intel_backlight +max_brightness=$(cat "${backlight_dir}"/max_brightness) +if [ "${percentage}" = '100' ]; then + sudo sh -c 'echo '"${max_brightness}"' > '"${backlight_dir}"'/brightness' +else + fract=$(expr "${max_brightness}" / 100) + brightness=$(expr "${percentage}" \* "${fract}") + sudo sh -c 'echo '"${brightness}"' > '"${backlight_dir}"'/brightness' +fi diff --git a/dotfiles/user/thinkpad/W530/startx_force_nvidia.sh b/bin/w530_startx_force_nvidia.sh similarity index 100% rename from dotfiles/user/thinkpad/W530/startx_force_nvidia.sh rename to bin/w530_startx_force_nvidia.sh -- 2.30.2