#!/usr/bin/env python3 """Stub for PipeWire's wpctl: the default sink's volume and mute, kept in the state file. Output format as wpctl prints it: "Volume: 0.40" plus " [MUTED]".""" import sys sys.path.insert(0, '/usr/local/lib/fakeframe') import fakeframe_state as fs # noqa: E402 args = sys.argv[1:] fs.log('wpctl', args=args) if len(args) == 2 and args[0] == 'get-volume': v = fs.read()['volume'] print(f"Volume: {v['level']:.2f}" + (' [MUTED]' if v['muted'] else '')) elif len(args) == 3 and args[0] == 'set-volume': with fs.update() as s: s['volume']['level'] = max(0.0, min(1.5, float(args[2]))) elif len(args) == 3 and args[0] == 'set-mute': with fs.update() as s: s['volume']['muted'] = args[2] == 'toggle' and not s['volume']['muted'] or args[2] == '1' else: sys.exit(f'wpctl stub: unsupported {args}')