add extension source and plan

This commit is contained in:
2026-08-05 19:31:59 -04:00
parent 642f9cb39f
commit b2d3c467e2
4 changed files with 167 additions and 0 deletions
@@ -0,0 +1,56 @@
import IBus from 'gi://IBus';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
import {
getInputSourceManager,
INPUT_SOURCE_TYPE_XKB,
INPUT_SOURCE_TYPE_IBUS,
} from 'resource:///org/gnome/shell/ui/status/keyboard.js';
import {getIBusManager} from 'resource:///org/gnome/shell/misc/ibusManager.js';
export default class HangulOverviewLatin extends Extension {
enable() {
this._showingId = Main.overview.connect('showing',
() => this._ensureLatin());
}
disable() {
Main.overview.disconnect(this._showingId);
this._showingId = null;
}
_ensureLatin() {
const ism = getInputSourceManager();
const src = ism.currentSource;
if (src?.type !== INPUT_SOURCE_TYPE_IBUS || !src.id.startsWith('hangul'))
return;
// ibus-hangul's InputMode handler toggles regardless of the state
// argument, so only activate it when currently in Hangul mode.
const prop = this._findProp(src.properties, 'InputMode');
if (prop) {
if (prop.get_state() === IBus.PropState.CHECKED) {
getIBusManager().activateProperty(
prop.get_key(), IBus.PropState.UNCHECKED);
}
return;
}
// No InputMode property: switch to the first xkb source instead
for (const i of Object.keys(ism.inputSources)) {
if (ism.inputSources[i].type === INPUT_SOURCE_TYPE_XKB) {
ism.inputSources[i].activate(true);
return;
}
}
}
_findProp(props, key) {
for (let i = 0, prop; (prop = props?.get(i)); i++) {
if (prop.get_key() === key)
return prop;
}
return null;
}
}
@@ -0,0 +1,7 @@
{
"uuid": "hangul-overview-latin@timothykim.net",
"name": "Hangul Overview Latin",
"description": "Switch ibus-hangul to Latin input when the Activities Overview opens, so search works immediately.",
"shell-version": ["50"],
"url": ""
}