From 4165338666f124a897d0dfae06184c485e3970c1 Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Fri, 25 Mar 2016 17:40:25 +0100 Subject: [PATCH] New package: asus-kbd-backlight-1.2 --- .../files/asus-kbd-backlight | 69 +++++++++++++++++++ srcpkgs/asus-kbd-backlight/files/asus-kbd/run | 5 ++ srcpkgs/asus-kbd-backlight/template | 16 +++++ 3 files changed, 90 insertions(+) create mode 100755 srcpkgs/asus-kbd-backlight/files/asus-kbd-backlight create mode 100644 srcpkgs/asus-kbd-backlight/files/asus-kbd/run create mode 100644 srcpkgs/asus-kbd-backlight/template diff --git a/srcpkgs/asus-kbd-backlight/files/asus-kbd-backlight b/srcpkgs/asus-kbd-backlight/files/asus-kbd-backlight new file mode 100755 index 00000000000..ebc76bff690 --- /dev/null +++ b/srcpkgs/asus-kbd-backlight/files/asus-kbd-backlight @@ -0,0 +1,69 @@ +#!/bin/bash + +path="/sys/class/leds/asus::kbd_backlight" +if [ ! -e "$path" ]; then + path="/sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight" +fi + +# max should be 3 +max=$(cat ${path}/max_brightness) +# step: represent the difference between previous and next brightness +step=1 +previous=$(cat ${path}/brightness) + +function commit { + if [[ $1 = [0-9]* ]] + then + if [[ $1 -gt $max ]] + then + next=$max + elif [[ $1 -lt 0 ]] + then + next=0 + else + next=$1 + fi + echo $next >> ${path}/brightness + exit 0 + else + exit 1 + fi +} + +case "$1" in + up) + commit $(($previous + $step)) + ;; + down) + commit $(($previous - $step)) + ;; + max) + commit $max + ;; + on) + $0 max + ;; + off) + commit 0 + ;; + show) + echo $previous + ;; + night) + commit 1 + ;; + allowusers) + # Allow members of users group to change brightness + chgrp users ${path}/brightness + chmod g+w ${path}/brightness + ;; + disallowusers) + # Allow members of users group to change brightness + chgrp root ${path}/brightness + chmod g-w ${path}/brightness + ;; + *) + commit $1 +esac + +exit 0 diff --git a/srcpkgs/asus-kbd-backlight/files/asus-kbd/run b/srcpkgs/asus-kbd-backlight/files/asus-kbd/run new file mode 100644 index 00000000000..dc41b16f87b --- /dev/null +++ b/srcpkgs/asus-kbd-backlight/files/asus-kbd/run @@ -0,0 +1,5 @@ +#!/bin/sh + +asus-kbd-backlight allowusers + +exec chpst -b asus-kbd pause diff --git a/srcpkgs/asus-kbd-backlight/template b/srcpkgs/asus-kbd-backlight/template new file mode 100644 index 00000000000..120c473359d --- /dev/null +++ b/srcpkgs/asus-kbd-backlight/template @@ -0,0 +1,16 @@ +# Template file for 'asus-kbd-backlight' +pkgname=asus-kbd-backlight +version=1.2 +revision=1 +create_wrksrc=yes +noarch=yes +depends="bash" +short_desc="Helper for adjusting keyboard backlight brightness in Asus Zenbook" +maintainer="Andrea Brancaleoni " +license="FDL1.3" +homepage="https://wiki.archlinux.org/index.php/ASUS_Zenbook_Prime_UX31A#keyboard_backlight_script" + +do_install() { + vbin $FILESDIR/asus-kbd-backlight + vsv asus-kbd +}