pkgs: add change-backlight
This commit is contained in:
parent
d724c205ea
commit
10b8ee50c1
15
pkgs/change-backlight/change-backlight
Executable file
15
pkgs/change-backlight/change-backlight
Executable 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"
|
44
pkgs/change-backlight/default.nix
Normal file
44
pkgs/change-backlight/default.nix
Normal 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 ];
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,6 +2,8 @@
|
||||||
pkgs.lib.makeScope pkgs.newScope (pkgs: {
|
pkgs.lib.makeScope pkgs.newScope (pkgs: {
|
||||||
bw-pass = pkgs.callPackage ./bw-pass { };
|
bw-pass = pkgs.callPackage ./bw-pass { };
|
||||||
|
|
||||||
|
change-backlight = pkgs.callPackage ./change-backlight { };
|
||||||
|
|
||||||
comma = pkgs.callPackage ./comma { };
|
comma = pkgs.callPackage ./comma { };
|
||||||
|
|
||||||
diff-flake = pkgs.callPackage ./diff-flake { };
|
diff-flake = pkgs.callPackage ./diff-flake { };
|
||||||
|
|
Loading…
Reference in a new issue