allow setting sink ID in pipewire module
This commit is contained in:
parent
9b4944c53f
commit
ee796f6589
1 changed files with 6 additions and 8 deletions
|
@ -29,6 +29,8 @@ class Module(core.module.Module):
|
||||||
/ 100.0
|
/ 100.0
|
||||||
) # divide by 100 because wpctl represents 100% volume as 1.00, 50% as 0.50, etc
|
) # 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 = [
|
events = [
|
||||||
{
|
{
|
||||||
"type": "mute",
|
"type": "mute",
|
||||||
|
@ -51,20 +53,16 @@ class Module(core.module.Module):
|
||||||
core.input.register(self, button=event["button"], cmd=event["action"])
|
core.input.register(self, button=event["button"], cmd=event["action"])
|
||||||
|
|
||||||
def toggle(self, event):
|
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):
|
def increase_volume(self, event):
|
||||||
util.cli.execute(
|
util.cli.execute(
|
||||||
"wpctl set-volume --limit 1.0 @DEFAULT_AUDIO_SINK@ {}+".format(
|
"wpctl set-volume --limit 1.0 {} {}+".format(self.__change, self.__id)
|
||||||
self.__change
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def decrease_volume(self, event):
|
def decrease_volume(self, event):
|
||||||
util.cli.execute(
|
util.cli.execute(
|
||||||
"wpctl set-volume --limit 1.0 @DEFAULT_AUDIO_SINK@ {}-".format(
|
"wpctl set-volume --limit 1.0 {} {}-".format(self.__change, self.__id)
|
||||||
self.__change
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def volume(self, widget):
|
def volume(self, widget):
|
||||||
|
@ -75,7 +73,7 @@ class Module(core.module.Module):
|
||||||
def update(self):
|
def update(self):
|
||||||
try:
|
try:
|
||||||
# `wpctl get-volume` will return a string like "Volume: n.nn" or "Volume: n.nn [MUTED]"
|
# `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)
|
v = re.search("\d\.\d+", volume)
|
||||||
m = re.search("MUTED", volume)
|
m = re.search("MUTED", volume)
|
||||||
self.__level = v.group()
|
self.__level = v.group()
|
||||||
|
|
Loading…
Reference in a new issue