diff --git a/pkgs/change-audio/change-audio b/pkgs/change-audio/change-audio new file mode 100755 index 0000000..9f7f1d2 --- /dev/null +++ b/pkgs/change-audio/change-audio @@ -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%" diff --git a/pkgs/change-audio/default.nix b/pkgs/change-audio/default.nix new file mode 100644 index 0000000..5027826 --- /dev/null +++ b/pkgs/change-audio/default.nix @@ -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 ]; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 3f7b1df..a179dfb 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -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 { };