Created
February 27, 2020 06:30
-
-
Save zikaeroh/b687938443a59d3f0645ed7dabe67aea to your computer and use it in GitHub Desktop.
redshift for brightness control for OLED display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maintainer: zikaeroh | |
# Contributor: Andrey Solomatin <toadron[at]yandex[dot]ru> | |
# Contributor: carstene1ns <arch carsten-teibes de> - http://git.io/ctPKG | |
# Contributor: Lukas Fleischer <lfleischer@archlinux.org> | |
# Contributor: Geoffrey Teale <tealeg@stop-squark> | |
# Contributor: Mark, Huo Mian <markhuomian[at]gmail[dot]com> | |
# Contributor: Biginoz <biginoz a free dot fr> | |
# Contributor: Mattias Andrée <`base64 -d`(bWFhbmRyZWUK)@member.fsf.org> | |
pkgname=redshift-wlr-gamma-control-stdin-git | |
pkgver=1.11.r200.gcca74ee | |
pkgrel=1 | |
pkgdesc="Adjusts the color temperature of your screen according to your surroundings with Wayland wlr-gamma-control protocol support. (development version)" | |
arch=('i686' 'x86_64') | |
url='https://github.com/jonls/redshift/issues/690' | |
license=('GPL3') | |
provides=('redshift') | |
conflicts=('redshift') | |
depends=('geoclue2' 'libdrm' 'libxcb' 'libxxf86vm') | |
optdepends=('python-gobject: for redshift-gtk' | |
'python-xdg: for redshift-gtk' | |
'librsvg: for redshift-gtk' | |
'sway-git: supporting wayland environment with wlr-gamma-control protocol') | |
makedepends=('git' 'intltool' 'python' 'wayland') | |
source=(redshift::"git+https://github.com/martinetd/redshift.git#commit=cca74ee" | |
0001.patch::'https://gist.githubusercontent.com/piater/c9fe144aa4f1537174f348c1572939c4/raw/9ea6242299a2df52ddc3cdfe227c51bd78aa4807/0001-redshift.c-use-poll-instead-of-select.patch' | |
0002.patch::'https://gist.githubusercontent.com/piater/c9fe144aa4f1537174f348c1572939c4/raw/9ea6242299a2df52ddc3cdfe227c51bd78aa4807/0002-redshift.c-continual-mode-only-block-at-end-of-loop.patch' | |
0003.patch::'https://gist.githubusercontent.com/piater/c9fe144aa4f1537174f348c1572939c4/raw/9ea6242299a2df52ddc3cdfe227c51bd78aa4807/0003-With-C-on-q-exit-the-same-way-as-on-SIGINT.patch' | |
0004.patch::'https://gist.githubusercontent.com/piater/c9fe144aa4f1537174f348c1572939c4/raw/9ea6242299a2df52ddc3cdfe227c51bd78aa4807/0004-options_parse_continual_cmds-declare-argv-static.patch') | |
md5sums=('SKIP' | |
'ee5796b66be55898f1a67be6fa493afc' | |
'626f94d75bf4107c67a592aae5ad2a92' | |
'0b0ce697f69cfce743bb067235e93837' | |
'fa2dd39b0094410a1af6f23101f79bc1') | |
pkgver() { | |
cd redshift | |
git describe --long --tags | sed 's/^v//;s/-/.r/;s/-/./g' | |
} | |
prepare() { | |
cd redshift | |
patch --forward --strip=1 --input="${srcdir}/0001.patch" | |
patch --forward --strip=1 --input="${srcdir}/0002.patch" | |
patch --forward --strip=1 --input="${srcdir}/0003.patch" | |
patch --forward --strip=1 --input="${srcdir}/0004.patch" | |
} | |
build() { | |
cd redshift | |
./bootstrap | |
./configure --prefix=/usr --enable-drm --enable-randr --enable-vidmode --enable-geoclue2 --enable-wayland \ | |
--with-systemduserunitdir=/usr/lib/systemd/user | |
make | |
} | |
package() { | |
cd redshift | |
make DESTDIR="${pkgdir}" install | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
path=/sys/class/backlight/intel_backlight | |
tmpdir=$(mktemp -d) | |
function remove_tmpdir { | |
rm -rf $tmpdir | |
} | |
trap remove_tmpdir EXIT | |
fifo=$tmpdir/fifo | |
mkfifo $fifo | |
redshift -C $fifo & | |
read -r max < "$path"/max_brightness | |
luminance() { | |
read -r level < "$path"/actual_brightness | |
factor=$((max / 100)) | |
ret=`printf '%d\n' "$((level / factor))"` | |
if [ $ret -gt 100 ]; then | |
ret=100 | |
fi | |
printf `echo "$ret / 100" | bc -l` | |
} | |
echo "-b $(luminance)" >> $fifo | |
inotifywait -me modify --format '' "$path"/actual_brightness | while read -r directory events filename; do | |
echo "-b $(luminance)" >> $fifo | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment