From e3dc5a6aca9ed271fe05b722a7fbac335ed57e9a Mon Sep 17 00:00:00 2001 From: joy Date: Fri, 9 Aug 2024 01:14:56 +0200 Subject: [PATCH] pactl --- home/hyprland/default.nix | 6 ++--- home/hyprland/volume.sh | 51 ++++++++++++++++++++++++++++++++++++ modules/packages/default.nix | 1 + 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100755 home/hyprland/volume.sh diff --git a/home/hyprland/default.nix b/home/hyprland/default.nix index b7b34db..0044847 100644 --- a/home/hyprland/default.nix +++ b/home/hyprland/default.nix @@ -2,7 +2,7 @@ home.packages = with pkgs; [ rofi-wayland - pavucontrol + pwvucontrol swww wl-clipboard cliphist @@ -144,8 +144,8 @@ bindl = [ ", XF86MonBrightnessUp, exec, brightnessctl set +10%" ", XF86MonBrightnessDown, exec, brightnessctl set 10%-" - ", XF86AudioRaiseVolume, exec, amixer set Master 10%+" - ", XF86AudioLowerVolume, exec, amixer set Master 10%-" + ", XF86AudioRaiseVolume, exec, sh volume.sh -i" + ", XF86AudioLowerVolume, exec, sh volume.sh -d" ]; general = { diff --git a/home/hyprland/volume.sh b/home/hyprland/volume.sh new file mode 100755 index 0000000..6ca189b --- /dev/null +++ b/home/hyprland/volume.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# Function to display usage +usage() { + echo "Usage: $0 [-d|-i|-m]" + echo " -d Decrease volume by 10%" + echo " -i Increase volume by 10%" + echo " -m Toggle mute/unmute" + exit 1 +} + +# Get the default sink +sink=$(pactl info | grep "Default Sink" | awk '{print $3}') + +# Check if a sink was found +if [ -z "$sink" ]; then + echo "No default sink found." + exit 1 +fi + +# Process command-line options +while getopts "dim" opt; do + case $opt in + d) + # Decrease volume by 10% + pactl set-sink-volume "$sink" -10% + ;; + i) + # Increase volume by 10% + pactl set-sink-volume "$sink" +10% + ;; + m) + # Toggle mute/unmute + current_mute=$(pactl get-sink-mute "$sink" | awk '{print $2}') + if [ "$current_mute" = "yes" ]; then + pactl set-sink-mute "$sink" 0 + echo "Unmuted" + else + pactl set-sink-mute "$sink" 1 + echo "Muted" + fi + ;; + *) + usage + ;; + esac +done + +# Display current volume level +echo "Current volume:" +pactl list sinks | grep -A 15 "$sink" | grep "Volume:" diff --git a/modules/packages/default.nix b/modules/packages/default.nix index 10b7c21..2b2f1fe 100644 --- a/modules/packages/default.nix +++ b/modules/packages/default.nix @@ -26,6 +26,7 @@ mpv cmus obs-studio + pulseaudioFull #gui stuff keepassxc vesktop