Skip to content

Instantly share code, notes, and snippets.

@KreerC
Created April 27, 2019 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KreerC/d8208c9d81ca937013117ba4080be50c to your computer and use it in GitHub Desktop.
Save KreerC/d8208c9d81ca937013117ba4080be50c to your computer and use it in GitHub Desktop.
Use text to speech to announce the focused window in i3wm
import i3ipc
import pyttsx3
i3 = i3ipc.Connection()
tts = pyttsx3.init()
def on_window_focus(i3, e):
focused = i3.get_tree().find_focused()
# Verbose output
# tts.say((focused.workspace().num, focused.name))
# Less verbose, just announce application name
tts.say((focused.workspace().num, focused.window_class))
tts.setProperty("rate", 350)
tts.runAndWait()
i3.on("window::focus", on_window_focus)
i3.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment