aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/personal/volctl
blob: 628449ef62fc0aec59bf095ef82b0aae04fe3a6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

# A script to manage the volume on my system universally

sink="$(pactl list short sinks | grep "pci-0000_00_1f.3" | awk '{print $1}')"
volume="$(pamixer --get-volume)"
last_volume=45

if [ "$1" = "increase" ]; then
  pactl set-sink-volume "$sink" +5%
  volctl save
elif [ "$1" = "decrease" ]; then
  pactl set-sink-volume "$sink" -5%
  volctl save
elif [ "$1" = "mute" ]; then
  if [ "$volume" = "0" ]; then
    pactl set-sink-volume "$sink" "$last_volume%"
  else
    pactl set-sink-volume "$sink" 0%
  fi
elif [ "$1" = "save" ]; then
  sed -i "s/last_volume=45$last_volume/last_volume=45$volume/g" "$0"
elif [ "$1" = "check" ]; then
  printf "%s\n" "$volume"
else
  printf "[ Error ] Not enough arguments.\n"
fi