Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added mute/microphone disabled to mode indicator #1466

Merged
merged 5 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 15 additions & 1 deletion plugin/mode_indicator/mode_indicator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from talon import Module, app, registry, scope, settings, skia, ui
from talon import Module, actions, app, cron, registry, scope, settings, skia, ui
from talon.canvas import Canvas
from talon.screen import Screen
from talon.skia.canvas import Canvas as SkiaCanvas
Expand All @@ -7,6 +7,7 @@

canvas: Canvas = None
current_mode = ""
current_microphone = ""
mod = Module()

mod.setting(
Expand Down Expand Up @@ -40,6 +41,7 @@
type=float,
desc="Mode indicator gradient brightness in percentages(0-1). 0=darkest, 1=brightest",
)
mod.setting("mode_indicator_color_mute", type=str)
mod.setting("mode_indicator_color_sleep", type=str)
mod.setting("mode_indicator_color_dictation", type=str)
mod.setting("mode_indicator_color_mixed", type=str)
Expand All @@ -53,6 +55,7 @@
"user.mode_indicator_y",
"user.mode_indicator_color_alpha",
"user.mode_indicator_color_gradient",
"user.mode_indicator_color_mute",
"user.mode_indicator_color_sleep",
"user.mode_indicator_color_dictation",
"user.mode_indicator_color_mixed",
Expand All @@ -62,6 +65,8 @@


def get_mode_color() -> str:
if current_microphone == "None":
return settings.get("user.mode_indicator_color_mute")
if current_mode == "sleep":
return settings.get("user.mode_indicator_color_sleep")
elif current_mode == "dictation":
Expand Down Expand Up @@ -180,10 +185,19 @@ def on_update_settings(updated_settings: set[str]):
update_indicator()


def poll_microphone():
global current_microphone
AndreasArvidsson marked this conversation as resolved.
Show resolved Hide resolved
microphone = actions.sound.active_microphone()
if current_microphone != microphone:
current_microphone = microphone
update_indicator()


def on_ready():
registry.register("update_contexts", on_update_contexts)
registry.register("update_settings", on_update_settings)
ui.register("screen_change", lambda _: update_indicator)
cron.interval("500ms", poll_microphone)


app.register("ready", on_ready)
2 changes: 2 additions & 0 deletions plugin/mode_indicator/mode_indicator.talon
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ settings():
user.mode_indicator_color_alpha = 0.75
# Grey gradient
user.mode_indicator_color_gradient = 0.5
# Black color for mute (Microphone is disabled/None)
AndreasArvidsson marked this conversation as resolved.
Show resolved Hide resolved
user.mode_indicator_color_mute = "000000"
# Grey color for sleep mode
user.mode_indicator_color_sleep = "808080"
# Gold color for dictation mode
Expand Down