Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/edit_text_file/edit_text_file_list.talon-list
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abbreviations: settings/abbreviations.csv
file extensions: settings/file_extensions.csv
symbols: settings/symbols.csv
words to replace: settings/words_to_replace.csv
microphones to exclude: settings/microphones_to_exclude
contacts json: private/contacts.json
contacts csv: private/contacts.csv

Expand Down
30 changes: 30 additions & 0 deletions core/user_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,36 @@ def on_update(f):
return decorator


def track_line_separated_values(
filename: str,
default: list[str],
private: bool = False,
):
path = compute_file_path(filename, private)

# output default if path not defined
if not path.is_file():
with open(path, "w") as f:
f.writelines(l + "\n" for l in default)

# called decorated function when the path changes
# passing it the lines of the file
def decorator(fn):
@resource.watch(str(path))
def on_update(f):
# read the lines removing trailing new line characters
data = [l.rstrip("\n\r") for l in f.readlines()]
fn(data)

return on_update

return decorator


def compute_file_path(filename, is_private):
return (PRIVATE_DIR / filename) if is_private else (SETTINGS_DIR / filename)


def warn_about_error(message: str):
actions.app.notify(message)
print(message)
15 changes: 13 additions & 2 deletions plugin/microphone_selection/microphone_selection.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
from talon import Context, Module, actions, cron, imgui

from ...core.user_settings import track_line_separated_values

mod = Module()
ctx = Context()


EXCLUDE_MICROPHONES = {
DEFAULT_EXCLUDE_MICROPHONES = [
"Microsoft Teams Audio Device",
"WebexMediaAudioDevice",
"ZoomAudioDevice",
}
]

EXCLUDE_MICROPHONES = set()


@track_line_separated_values("microphones_to_exclude", DEFAULT_EXCLUDE_MICROPHONES)
def on_microphones_to_exclude_update(microphone_names):
global EXCLUDE_MICROPHONES
EXCLUDE_MICROPHONES = {name for name in microphone_names if name.strip()}


microphone_device_list = []
update_microphone_cron_job = None
Expand Down