# Path: py3status/exceptions.py
# class CommandError(Py3Exception):
#     """
#     An error occurred running the given command.
# 
#     This exception provides some additional attributes
# 
#     ``error_code``: The error code returned from the call
# 
#     ``output``: Any output returned by the call
# 
#     ``error``: Any error output returned by the call
#     """
# 
#     def __init__(self, msg=None, error_code=0, output="", error=""):
#         Py3Exception.__init__(self, msg)
#         self.error_code = error_code
#         self.output = output
#         self.error = error


import re
import math
from py3status.exceptions import CommandError
    from py3status.module_test import module_test
        # find percentage and status
        p = re.compile(r"\[(\d{1,3})%\].*\[(\w{2,3})\]")
        perc, muted = p.search(output).groups()

        # muted should be 'on' or 'off'
        if muted in ["on", "off"]:
            muted = muted == "off"
        else:
            muted = False

        return perc, muted

    def volume_up(self, delta):
        self.run_cmd(self.cmd + [f"{delta}%+"])

    def volume_down(self, delta):
        self.run_cmd(self.cmd + [f"{delta}%-"])

    def toggle_mute(self):
        self.run_cmd(self.cmd + ["toggle"])


class Pamixer(Audio):
    def setup(self, parent):
        is_input = "--source" if self.is_input else "--sink"
        self.cmd = ["pamixer", "--allow-boost", is_input, self.device or "0"]

    def get_volume(self):
        try:
            line = self.command_output(self.cmd + ["--get-mute", "--get-volume"])

# Path: py3status/exceptions.py
# class CommandError(Py3Exception):
#     """
#     An error occurred running the given command.
# 
#     This exception provides some additional attributes
# 
#     ``error_code``: The error code returned from the call
# 
#     ``output``: Any output returned by the call
# 
#     ``error``: Any error output returned by the call
#     """
# 
#     def __init__(self, msg=None, error_code=0, output="", error=""):
#         Py3Exception.__init__(self, msg)
#         self.error_code = error_code
#         self.output = output
#         self.error = error


# Path: py3status/modules/volume_status.py
import re
import math
from py3status.exceptions import CommandError
    from py3status.module_test import module_test

        # find percentage and status
        p = re.compile(r"\[(\d{1,3})%\].*\[(\w{2,3})\]")
        perc, muted = p.search(output).groups()

        # muted should be 'on' or 'off'
        if muted in ["on", "off"]:
            muted = muted == "off"
        else:
            muted = False

        return perc, muted

    def volume_up(self, delta):
        self.run_cmd(self.cmd + [f"{delta}%+"])

    def volume_down(self, delta):
        self.run_cmd(self.cmd + [f"{delta}%-"])

    def toggle_mute(self):
        self.run_cmd(self.cmd + ["toggle"])


class Pamixer(Audio):
    def setup(self, parent):
        is_input = "--source" if self.is_input else "--sink"
        self.cmd = ["pamixer", "--allow-boost", is_input, self.device or "0"]

    def get_volume(self):
        try:
            line = self.command_output(self.cmd + ["--get-mute", "--get-volume"])

        except CommandError as ce: