Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow setting sink ID in pipewire module #977

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions bumblebee_status/modules/contrib/pipewire.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(self, config, theme):
/ 100.0
) # divide by 100 because wpctl represents 100% volume as 1.00, 50% as 0.50, etc

self.__id = self.parameter("sink_id") or "@DEFAULT_AUDIO_SINK@"

events = [
{
"type": "mute",
Expand All @@ -51,20 +53,16 @@ def __init__(self, config, theme):
core.input.register(self, button=event["button"], cmd=event["action"])

def toggle(self, event):
util.cli.execute("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle")
util.cli.execute("wpctl set-mute {} toggle".format(self.__id))

def increase_volume(self, event):
util.cli.execute(
"wpctl set-volume --limit 1.0 @DEFAULT_AUDIO_SINK@ {}+".format(
self.__change
)
"wpctl set-volume --limit 1.0 {} {}+".format(self.__change, self.__id)
)

def decrease_volume(self, event):
util.cli.execute(
"wpctl set-volume --limit 1.0 @DEFAULT_AUDIO_SINK@ {}-".format(
self.__change
)
"wpctl set-volume --limit 1.0 {} {}-".format(self.__change, self.__id)
)

def volume(self, widget):
Expand All @@ -75,7 +73,7 @@ def volume(self, widget):
def update(self):
try:
# `wpctl get-volume` will return a string like "Volume: n.nn" or "Volume: n.nn [MUTED]"
volume = util.cli.execute("wpctl get-volume @DEFAULT_AUDIO_SINK@")
volume = util.cli.execute("wpctl get-volume {}".format(self.__id))
v = re.search("\d\.\d+", volume)
m = re.search("MUTED", volume)
self.__level = v.group()
Expand Down
Loading