diff options
| author | srdusr <trevorgray@srdusr.com> | 2025-08-30 19:22:59 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2025-08-30 19:22:59 +0200 |
| commit | 19120d4f9761c67d99ed1ce3da6084b83f5a49c9 (patch) | |
| tree | f234cad1bdad88114a63c9702144da487024967a /.config/xob/manage-microphone | |
| parent | 5928998af5404ae2be84c6cecc10ebf84bd3f3ed (diff) | |
| download | dotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.tar.gz dotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.zip | |
Linux-specific dotfiles
Diffstat (limited to '.config/xob/manage-microphone')
| -rwxr-xr-x | .config/xob/manage-microphone | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/.config/xob/manage-microphone b/.config/xob/manage-microphone deleted file mode 100755 index 3bf5972..0000000 --- a/.config/xob/manage-microphone +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 - -import sys - -from pulsectl import Pulse, PulseLoopStop - - -def callback(ev): - if ev.index == source_index: - raise PulseLoopStop - - -def current_status(source): - return round(source.volume.value_flat * 100), source.mute == 1 - - -def get_default_source_idx(): - default_source_name = pulse.server_info().default_source_name - try: - source_index = next(index for index, source in sources.items() - if source.name == default_source_name) - return source_index - except StopIteration: - raise StopIteration("No default source was found.") - - -try: - with Pulse() as pulse: - sources = {s.index: s for s in pulse.source_list()} - - if len(sys.argv) > 1: - # Source index from command line argument if provided - source_index = int(sys.argv[1]) - if source_index not in sources: - raise KeyError( - f"Source index {source_index} not found in list of sources." - ) - else: - # Automatic determination of default source otherwise - source_index = get_default_source_idx() - - pulse.event_mask_set('source') - pulse.event_callback_set(callback) - last_value, last_mute = current_status(sources[source_index]) - - while True: - pulse.event_listen() - sources = {s.index: s for s in pulse.source_list()} - value, mute = current_status(sources[source_index]) - if value != last_value or mute != last_mute: - print(str(value) + ('!' if mute else '')) - last_value, last_mute = value, mute - sys.stdout.flush() - -except Exception as e: - print(f"ERROR: {e}", file=sys.stderr) |
