Skip to content

Instantly share code, notes, and snippets.

@scturtle
Created April 17, 2026 07:24
Show Gist options
  • Select an option

  • Save scturtle/5044e6b003d1a2316a7603eeeeb60d67 to your computer and use it in GitHub Desktop.

Select an option

Save scturtle/5044e6b003d1a2316a7603eeeeb60d67 to your computer and use it in GitHub Desktop.
change background color of gnome shell main panel based on label of input method
(async () => {
const Main = await import('resource:///org/gnome/shell/ui/main.js');
const { default: GLib } = await import('gi://GLib');
const ind = Main.panel.statusArea.keyboard;
const mgr = ind?._inputSourceManager;
if (!mgr) return;
const update = () => {
const text = ind._indicatorLabels[mgr.currentSource?.index]?.get_text();
if (text != null) {
Main.panel.set_style(['A', 'en', 'us', 'EN'].includes(text)
? 'background-color: transparent;'
: 'background-color: royalblue; transition: background-color 0.2s;');
}
};
if (ind._rimeSig) mgr.disconnect(ind._rimeSig);
ind._rimeSig = mgr.connect('current-source-changed', () => {
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => (update(), GLib.SOURCE_REMOVE));
});
globalThis._rimeMonitorStop = () => {
if (ind._rimeSig) mgr.disconnect(ind._rimeSig);
ind._rimeSig = null;
Main.panel.set_style('background-color: transparent;');
delete globalThis._rimeMonitorStop;
};
update();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment