volume_status module: log available devices on default mode
@@ -232,15 +232,9 @@ class Pactl(Audio):
# with the long gross id, find the associated number
if device_id is not None:
- output = self.command_output(
- ["pactl", "list", "short", self.device_type_pl]
- )
- for line in output.splitlines():
- parts = line.split()
- if len(parts) < 2:
- continue
- if parts[1] == device_id:
- return parts[0]
+ for d_number, d_id in self.get_current_devices().items():
+ if d_id == device_id:
+ return d_number
raise RuntimeError(
"Failed to find default {} device. Looked for {}".format(
@@ -248,6 +242,19 @@ class Pactl(Audio):
)
)
+ def get_current_devices(self):
+ current_devices = {}
+ output = self.command_output(["pactl", "list", "short", self.device_type_pl])
+ for line in output.splitlines():
+ parts = line.split()
+ if len(parts) < 2:
+ continue
+ current_devices[parts[0]] = parts[1]
+ self.parent.py3.log(
+ "available {}: {}".format(self.device_type_pl, current_devices)
+ )
+ return current_devices
+
def get_volume(self):
output = self.command_output(["pactl", "list", self.device_type_pl]).strip()
if self.use_default_device:
