pkgs: add change-audio

This commit is contained in:
Bruno BELANYI 2021-11-04 15:56:01 +01:00
parent f6381b14b0
commit fe455ffe9f
3 changed files with 63 additions and 0 deletions

17
pkgs/change-audio/change-audio Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail
if [ "$1" = "up" ]; then
upDown="-i"
else
upDown="-d"
fi
pamixer --allow-boost "$upDown" "$2"
newVolume="$(pamixer --get-volume)"
notify-send -u low \
-h string:x-canonical-private-synchronous:change-audio \
-h "int:value:$newVolume" \
-- "Set volume to $newVolume%"

View file

@ -0,0 +1,44 @@
{ lib, libnotify, makeWrapper, pamixer, shellcheck, stdenvNoCC }:
stdenvNoCC.mkDerivation rec {
pname = "change-audio";
version = "0.1.0";
src = ./change-audio;
buildInputs = [
makeWrapper
shellcheck
];
dontUnpack = true;
buildPhase = ''
shellcheck $src
'';
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/change-audio
chmod a+x $out/bin/change-audio
'';
wrapperPath = lib.makeBinPath [
libnotify
pamixer
];
fixupPhase = ''
patchShebangs $out/bin/change-audio
wrapProgram $out/bin/change-audio --prefix PATH : "${wrapperPath}"
'';
meta = with lib; {
description = ''
A script to change the volume 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-audio = pkgs.callPackage ./change-audio { };
change-backlight = pkgs.callPackage ./change-backlight { };
comma = pkgs.callPackage ./comma { };