You are not logged in.
I have this weird idea for a hardware project, I'm a bilingual user that requires constant usage of two keyboard layouts which I switch between often.
However, the active keyboard layout widget on the GNOME top bar is way too subtle, especially on a large screen where it requires lots of eye movement to focus on.
My thought is to build a simple hardware device, say Arduino-based (but really any board will work here) that will light an RGB LED somewhere around my screen with a different color according to the active keyboard layout.
The hardware part is a no-brainer, but what I'm missing is how to write a script/process that can hook into GNOME keyboard layout changes and send out a signal over serial port to the hardware board to toggle the LED color.
Any ideas on how to do that? As a fallback, if there's no hook/callback I can use, I can periodically poll or make an API call, but would rather have a more performant solution.
The best I got so far is this:
$ gsettings get org.gnome.desktop.input-sources sources
[('xkb', 'us'), ('xkb', 'il')]
but even that doesn't really show me the active layout.
Last edited by yuvadm (2020-12-18 21:22:07)
Offline
If works properly, "org.gnome.desktop.input-sources.mru-sources" (most-recently-used sources) looks like what you want, and can be monitored by
$ gsettings monitor org.gnome.desktop.input-sources mru-sources
. But it's not reliable as far as I see; sometimes updation stops probably because of IBus status flag. Instead, polling
$ gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'imports.ui.status.keyboard.getInputSourceManager().currentSource.id'
directly might be better though it's dirty.
Offline
After gnome 41, `org.gnome.Shell.Eval` cannot work in default safe mode. You can:
- Use https://github.com/linushdot/unsafe-mode-menu to enable unsafe mode
- Use https://github.com/lyokha/g3kb-switch to get input method directly
An adherent of hacker culture and open source.
Offline