pkgs: add change-audio
This commit is contained in:
parent
f6381b14b0
commit
fe455ffe9f
17
pkgs/change-audio/change-audio
Executable file
17
pkgs/change-audio/change-audio
Executable 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%"
|
44
pkgs/change-audio/default.nix
Normal file
44
pkgs/change-audio/default.nix
Normal 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 ];
|
||||
};
|
||||
}
|
|
@ -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 { };
|
||||
|
|
Loading…
Reference in a new issue