Skip to content

amixer parser - no db output breaks parser #644

@scharc

Description

@scharc

My amixer output does not provide a db field which breaks the parser:

amixer 
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 55039 [84%] [on]
  Front Right: Playback 54383 [83%] [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 24672 [38%] [on]
  Front Right: Capture 24672 [38%] [on]

Question: Do we need the db field at all if we have the percentage?

I fixed this by adding a check if the db field is there:

                if channel_data[0] == "":
                    continue
                if "db" in channel_data[3]:
                    db_value = channel_data[3].strip("[]")
                    status = channel_data[4].strip("[]")
                else:
                    db_value = "0.0db"
                    status = channel_data[3].strip("[]")
                playback_value = channel_data[1]
                percentage = channel_data[2].strip(

and then removed the db field in the _process function

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions