Skip to content

feat: Optional display microphone name text in mode indicator #1890

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

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
646b2f4
feat: Optional display microphone name text in mode indicator
trillium May 28, 2025
38ace23
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 28, 2025
95623d0
fix: Remove duplicate line
trillium Jun 6, 2025
14d64da
fix: Create mod setting, update setting name for mode_indicator_show_…
trillium Jun 6, 2025
89dc782
Merge remote-tracking branch 'origin/microphone_text_in_mode_indicato…
trillium Jun 6, 2025
c434e05
refactor: Draw circle and text in single callback
trillium Jun 6, 2025
b17c08e
refactor: Remove on_draw_text callback
trillium Jun 6, 2025
f406d2c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 6, 2025
c4164bf
refactor: Change on_draw x,y point to use rect.center
trillium Jun 6, 2025
a74c8e6
Update plugin/mode_indicator/mode_indicator.py
trillium Jun 7, 2025
b0f8c2a
refactor: Update color code in mode_indicator.talon
trillium Jun 7, 2025
b007aea
refactor: Move draw_text functionality into on_draw
trillium Jun 7, 2025
d413247
refactor: Remove redundant function draw_text
trillium Jun 7, 2025
f40a8f4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2025
c8ad7c0
fix: Update comment `mic` -> `microphone`
trillium Jun 7, 2025
6b6f7a5
fix: Use Point2d type on (x, y) coords
trillium Jun 7, 2025
2ad6581
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2025
91688d3
refactor: Move color_text into get_colors()
trillium Jun 7, 2025
dabcb7b
refactor: Move text color to get_colors()
trillium Jun 7, 2025
89cfbff
Merge branch 'microphone_text_in_mode_indicator' into HEAD
trillium Jun 7, 2025
4fb5f32
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2025
29b7a12
fix: Add Point2d import statement
trillium Jun 7, 2025
232e60d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2025
19bb259
refactor: Combine import statements
trillium Jun 7, 2025
f41f14e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2025
caee523
refactor: Change mode_indicator_show_mic_name -> mode_indicator_show_…
trillium Jun 7, 2025
f984dda
fix: Remove unnecessary f-string wrapper
trillium Jun 7, 2025
7efc97c
refactor: Use chached microphone var for text
trillium Jun 7, 2025
ef488b5
Merge branch 'main' into microphone_text_in_mode_indicator
nriley Jun 28, 2025
ca82ea0
Merge branch 'main' into microphone_text_in_mode_indicator
nriley Jul 13, 2025
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
32 changes: 28 additions & 4 deletions plugin/mode_indicator/mode_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from talon.screen import Screen
from talon.skia.canvas import Canvas as SkiaCanvas
from talon.skia.imagefilter import ImageFilter
from talon.ui import Rect
from talon.ui import Point2d, Rect

canvas: Canvas = None
current_mode = ""
Expand All @@ -16,6 +16,12 @@
default=False,
desc="If true the mode indicator is shown",
)
mod.setting(
"mode_indicator_show_microphone_name",
type=bool,
default=False,
desc="Show first two letters of microphone name if true",
)
mod.setting(
"mode_indicator_size",
type=float,
Expand All @@ -41,6 +47,7 @@
type=float,
desc="Mode indicator gradient brightness in percentages(0-1). 0=darkest, 1=brightest",
)
mod.setting("mode_indicator_color_text", type=str)
mod.setting("mode_indicator_color_mute", type=str)
mod.setting("mode_indicator_color_sleep", type=str)
mod.setting("mode_indicator_color_dictation", type=str)
Expand Down Expand Up @@ -97,16 +104,17 @@ def get_colors():
color_mode = get_mode_color()
color_gradient = get_gradient_color(color_mode)
color_alpha = get_alpha_color()
return f"{color_mode}{color_alpha}", f"{color_gradient}"
color_text = settings.get("user.mode_indicator_color_text")
return f"{color_mode}{color_alpha}", color_gradient, color_text


def on_draw(c: SkiaCanvas):
color_mode, color_gradient = get_colors()
color_mode, color_gradient, color_text = get_colors()
x, y = c.rect.center.x, c.rect.center.y
radius = c.rect.height / 2 - 2

c.paint.shader = skia.Shader.radial_gradient(
(x, y), radius, [color_mode, color_gradient]
Point2d(x, y), radius, [color_mode, color_gradient]
)

c.paint.imagefilter = ImageFilter.drop_shadow(1, 1, 1, 1, color_gradient)
Expand All @@ -115,6 +123,22 @@ def on_draw(c: SkiaCanvas):
c.paint.color = color_mode
c.draw_circle(x, y, radius)

if settings.get("user.mode_indicator_show_microphone_name"):
# Remove c.paint.shader gradient before drawing again
c.paint.shader = skia.Shader.radial_gradient(
Point2d(x, y), radius, [color_text, color_text]
)

text = current_microphone[:2]
c.paint.style = c.paint.Style.FILL
c.paint.color = color_text
text_rect = c.paint.measure_text(text)[1]
c.draw_text(
text,
x - text_rect.center.x,
y - text_rect.center.y,
)


def move_indicator():
screen: Screen = ui.main_screen()
Expand Down
4 changes: 4 additions & 0 deletions plugin/mode_indicator/mode_indicator.talon
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
settings():
# Don't show mode indicator by default
user.mode_indicator_show = false
# Set to true to show the first 2 letters of the microphone name inside the mode indicator
user.mode_indicator_show_microphone_name = false
# 30pixels diameter
user.mode_indicator_size = 30
# Center horizontally. (0=left, 0.5=center, 1=right)
Expand All @@ -11,6 +13,8 @@ settings():
user.mode_indicator_color_alpha = 0.75
# Grey gradient
user.mode_indicator_color_gradient = 0.5
# White color for optional text overlay on mode indicator
user.mode_indicator_color_text = "eeeeee"
# Black color for when the microphone is muted (set to "None")
user.mode_indicator_color_mute = "000000"
# Grey color for sleep mode
Expand Down