diff options
author | kyak | 2015-08-11 17:54:08 +0300 |
---|---|---|
committer | kyak | 2015-08-11 17:54:08 +0300 |
commit | c761834d067893b2bb3ff377902e07394231fc18 (patch) | |
tree | cff26f19c6f980e211115fb2b5873e7496986737 /PKGBUILD | |
download | aur-c761834d067893b2bb3ff377902e07394231fc18.tar.gz |
Initial import
Diffstat (limited to 'PKGBUILD')
-rw-r--r-- | PKGBUILD | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..16ac811b8079 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,113 @@ +# Author: Stefan Majewsky <majewsky at-the-server gmx with-the-tld net> + +pkgname=asus-kbd-backlight +pkgver=1.1 +pkgrel=1 +pkgdesc="Helper for adjusting keyboard backlight brightness in Asus Zenbook UX31A and similar models" +url="https://wiki.archlinux.org/index.php/ASUS_Zenbook_Prime_UX31A#keyboard_backlight_script" +arch=('any') +license=(FDL1.3) +depends=('bash') +optdepends=('systemd: automatically grant user access to keyboard backlight control') +install="asus-kbd-backlight.install" + +# general note: this package contains only two files; I don't see any added +# value in stuffing these into a tarball when I can also place them in here +# using heredocs (cf. http://stackoverflow.com/a/2954835/334761 for reference) +build() { + mkdir -p $srcdir/$pkgname-$pkgver/ + cd $srcdir/$pkgname-$pkgver/ + # write the backlight helper script + cat <<-'EOF' > ./asus-kbd-backlight + #!/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 + sudo chgrp users ${path}/brightness + sudo chmod g+w ${path}/brightness + ;; + disallowusers) + # Allow members of users group to change brightness + sudo chgrp root ${path}/brightness + sudo chmod g-w ${path}/brightness + ;; + *) + commit $1 + esac + + exit 0 + EOF + # write the systemd unit file + cat <<-'EOF' > ./asus-kbd-backlight.service + [Unit] + Description=Allow user access to keyboard backlight + After=systemd-udevd.service + + [Service] + Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/bin/asus-kbd-backlight allowusers + ExecStop=/usr/bin/asus-kbd-backlight disallowusers + + [Install] + WantedBy=multi-user.target + EOF +} + +package() { + cd $srcdir/$pkgname-$pkgver/ + install -D -m 0755 asus-kbd-backlight "$pkgdir/usr/bin/asus-kbd-backlight" + install -D -m 0644 asus-kbd-backlight.service "$pkgdir/usr/lib/systemd/system/asus-kbd-backlight.service" +} |