Compare commits
No commits in common. "6f643052e14c71ea6824593da2c6de01e2e0e206" and "6ebfa1a8cc63bb9117d40529307da5ffb379204f" have entirely different histories.
6f643052e1
...
6ebfa1a8cc
|
@ -249,8 +249,8 @@ in
|
|||
"XF86AudioLowerVolume" = "exec --no-startup-id ${changeAudio} down 5";
|
||||
"Control+XF86AudioRaiseVolume" = "exec --no-startup-id ${changeAudio} up 1";
|
||||
"Control+XF86AudioLowerVolume" = "exec --no-startup-id ${changeAudio} down 1";
|
||||
"XF86AudioMute" = "exec --no-startup-id ${changeAudio} toggle";
|
||||
"XF86AudioMicMute" = "exec --no-startup-id ${changeAudio} toggle mic";
|
||||
"XF86AudioMute" = "exec pamixer --toggle-mute";
|
||||
"XF86AudioMicMute" = "exec pamixer --default-source --toggle-mute";
|
||||
|
||||
"XF86AudioPlay" = "exec playerctl play-pause";
|
||||
"XF86AudioNext" = "exec playerctl next";
|
||||
|
|
|
@ -2,61 +2,16 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
NOTIFY=(
|
||||
notify-send
|
||||
-u low
|
||||
-h string:x-canonical-private-synchronous:change-audio
|
||||
)
|
||||
if [ "$1" = "up" ]; then
|
||||
upDown="-i"
|
||||
else
|
||||
upDown="-d"
|
||||
fi
|
||||
|
||||
do_change_volume() {
|
||||
if [ "$1" = "up" ]; then
|
||||
upDown="-i"
|
||||
else
|
||||
upDown="-d"
|
||||
fi
|
||||
pamixer --allow-boost "$upDown" "$2"
|
||||
newVolume="$(pamixer --get-volume || true)"
|
||||
|
||||
pamixer --allow-boost "$upDown" "$2"
|
||||
newVolume="$(pamixer --get-volume || true)"
|
||||
[ "$(pamixer --get-volume-human)" = "muted" ] && isMuted=true
|
||||
|
||||
MSG="Set volume to $newVolume%"
|
||||
if [ "${isMuted:-false}" = true ]; then
|
||||
MSG="$MSG (muted)"
|
||||
fi
|
||||
"${NOTIFY[@]}" \
|
||||
-h "int:value:$newVolume" \
|
||||
-- "$MSG"
|
||||
}
|
||||
|
||||
do_toggle() {
|
||||
args=()
|
||||
if [ "${2:-audio}" = mic ]; then
|
||||
args+=(--default-source)
|
||||
MSG="Toggled microphone"
|
||||
else
|
||||
MSG="Toggled audio output"
|
||||
fi
|
||||
|
||||
pamixer "${args[@]}" --toggle-mute
|
||||
|
||||
if [ "$(pamixer "${args[@]}" --get-mute)" = true ]; then
|
||||
MSG="$MSG (muted)"
|
||||
else
|
||||
MSG="$MSG (unmuted)"
|
||||
fi
|
||||
|
||||
"${NOTIFY[@]}" -- "$MSG"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
up|down)
|
||||
do_change_volume "$@"
|
||||
;;
|
||||
toggle)
|
||||
do_toggle "$@"
|
||||
;;
|
||||
*)
|
||||
echo "No suche option '$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
notify-send -u low \
|
||||
-h string:x-canonical-private-synchronous:change-audio \
|
||||
-h "int:value:$newVolume" \
|
||||
-- "Set volume to $newVolume%"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ lib, libnotify, makeWrapper, pamixer, shellcheck, stdenvNoCC }:
|
||||
stdenvNoCC.mkDerivation rec {
|
||||
pname = "change-audio";
|
||||
version = "0.2.0";
|
||||
version = "0.1.1";
|
||||
|
||||
src = ./change-audio;
|
||||
|
||||
|
|
Loading…
Reference in a new issue