pkgs: add change-backlight

This commit is contained in:
Bruno BELANYI 2021-11-04 15:55:33 +01:00
parent d724c205ea
commit 10b8ee50c1
3 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
if [ "$1" = "up" ]; then
upDown="+$2%"
else
upDown="$2%-"
fi
newBrightness="$(brightnessctl -m set "$upDown" | cut -d, -f4)"
notify-send -u low \
-h string:x-canonical-private-synchronous:change-backlight \
-h "int:value:${newBrightness/\%/}" \
-- "Set brightness to $newBrightness"

View File

@ -0,0 +1,44 @@
{ lib, brightnessctl, libnotify, makeWrapper, shellcheck, stdenvNoCC }:
stdenvNoCC.mkDerivation rec {
pname = "change-backlight";
version = "0.1.0";
src = ./change-backlight;
buildInputs = [
makeWrapper
shellcheck
];
dontUnpack = true;
buildPhase = ''
shellcheck $src
'';
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/change-backlight
chmod a+x $out/bin/change-backlight
'';
wrapperPath = lib.makeBinPath [
brightnessctl
libnotify
];
fixupPhase = ''
patchShebangs $out/bin/change-backlight
wrapProgram $out/bin/change-backlight --prefix PATH : "${wrapperPath}"
'';
meta = with lib; {
description = ''
A script to change a screen's brightness and notify about it
'';
homepage = "https://gitea.belanyi.fr/ambroisie/nix-config";
license = with licenses; [ mit ];
platforms = platforms.linux;
maintainers = with maintainers; [ ambroisie ];
};
}

View File

@ -2,6 +2,8 @@
pkgs.lib.makeScope pkgs.newScope (pkgs: {
bw-pass = pkgs.callPackage ./bw-pass { };
change-backlight = pkgs.callPackage ./change-backlight { };
comma = pkgs.callPackage ./comma { };
diff-flake = pkgs.callPackage ./diff-flake { };