Skip to content

Conversation

@contemno
Copy link

@contemno contemno commented Nov 27, 2025

Add volume and mute controls

This PR adds support for controlling monitor audio volume and mute state.

Changes

New VCP Codes

  • Added sound_volume (0x62) - continuous value for audio volume control
  • Added display_audio_mute_mode (0x8D) - non-continuous value for mute state

New API

  • Added AudioMuteMode enum with on and off states
  • Added Monitor.get_volume() / Monitor.set_volume() methods
  • Added Monitor.get_audio_mute_mode() / Monitor.set_audio_mute_mode() methods

CLI Changes

New command-line arguments:

  • --get-volume - Get the volume of the first monitor
  • --set-volume <value> - Set the volume of all monitors (0-100)
  • --get-audio-mute-mode - Get the audio mute mode of the first monitor
  • --set-audio-mute-mode <on|off> - Set the audio mute mode of all monitors

Testing

  • Added unit tests for volume get/set operations
  • Added unit tests for audio mute mode get/set with various input types
  • Added CLI tests for all new arguments

Usage Examples

from monitorcontrol import get_monitors

for monitor in get_monitors():
  with monitor:
    try:
      # Volume control
      monitor.set_volume(75)
      print(f"Current volume: {monitor.get_volume()}")
    except:
      print("Volume control unsupported by monitor")
    try:            
      # Mute control
      monitor.set_audio_mute_mode("on")
      print(f"Mute state: {monitor.get_audio_mute_mode()}")
    except:
      print("Mute control unsupported by monitor")
# CLI usage
python -m monitorcontrol --set-volume 50
python -m monitorcontrol --get-volume
python -m monitorcontrol --set-audio-mute-mode on
python -m monitorcontrol --get-audio-mute-mode

@contemno contemno closed this Nov 27, 2025
@contemno contemno reopened this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant