Skip to content

Commit

Permalink
Don't enable unlock-dialog session mode by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-shmyrev committed Apr 18, 2023
1 parent 75ce8df commit 5c6f598
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ Features:
* Configurable keyboard size (landscape/portrait)
* Statusbar indicator to toggle keyboard
* Works in Gnome password modals
* Works on Gnome's login screen (see [README](https://github.com/nick-shmyrev/improved-osk-gnome-ext/blob/master/README.md#as-a-system-wide-extension) for instructions)
* Works on Lock screen (see [README](https://github.com/nick-shmyrev/improved-osk-gnome-ext/blob/master/README.md#using-improved-osk-on-gnomes-lock-screen) for instructions) for instructions)
* Works on Gnome's Login screen (see [README](https://github.com/nick-shmyrev/improved-osk-gnome-ext/blob/master/README.md#as-a-system-wide-extension) for instructions)

Currently, the following layouts have extended keys: CH+FR, CH, DE, ES, FR, IT, RU, UA, US.
Currently, the following layouts have extended keys: CH+FR, CH, DE, HU, ES, FR, IT, RU, UA, US.

![Screenshot](screenshots/1.png)

Expand Down Expand Up @@ -54,10 +55,10 @@ git clone https://github.com/nick-shmyrev/improved-osk-gnome-ext.git
```

3. Add `"gdm"` to `session-modes` array in `metadata.json` file. The result should look something like this:
```json
```js
{
// rest of the metadata.json properties...
"session-modes": ["gdm", "user", "unlock-dialog"]
"session-modes": ["user", "gdm"]
}
```
4. Run `/package-extension.sh` script to package extension
Expand All @@ -69,6 +70,23 @@ If extension is installed, but the keyboards doesn't show up on login screen, ta

## FAQ

### Using Improved OSK on Gnome's lock screen.
This extension can also be used when screen is locked.

***Warning***: for this extension to work on lock screen, it needs `unlock-dialog` session mode to be enabled,
however Gnome Shell Extension [review guidelines](https://gjs.guide/extensions/review-guidelines/review-guidelines.html#session-modes)
do not allow extensions to connect to keyboard signals in `unlock-dialog` session mode.
For this reason, this extension is shipped with `unlock-dialog` session mode disabled by default.
Enable it at your own risk.

If you still want to enable it, simply add `unlock-dialog` value to `session-modes` array in `metadata.json` file. The result should look something like this:
```js
{
// rest of the metadata.json properties...
"session-modes": ["user", "gdm", "unlock-dialog"]
}
```

### My language layout doesn't have the additional keys.
If the layout you're using does not have the extended keys, let me know, and I'll add them.
Or, feel free to modify it yourself (see [/src/data/osk-layouts](https://github.com/nick-shmyrev/improved-osk-gnome-ext/tree/master/src/data/osk-layouts) dir) and make a PR.
Expand Down
28 changes: 14 additions & 14 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,33 +120,25 @@ function override_addRowKeys(keys, layout) {
} else if (key.action === 'emoji') {
this._toggleEmoji();
} else if (key.action === 'modifier') {
// === Override starts here ===

// Pass the whole key object to allow switching layers on "Shift" press
this._toggleModifier(key);

// === Override ends here ===
} else if (key.action === 'delete') {
this._toggleDelete(true);
this._toggleDelete(false);
} else if (!this._longPressed && key.action === 'levelSwitch') {
this._setActiveLayer(key.level);
// === Override starts here ===

// Ensure numbers layer latches
const isNumbersLayer = key.level === 2;
this._setLatched(isNumbersLayer);

// === Override ends here ===
}

this._longPressed = false;
});
}

// === Override starts here ===
if (key.iconName === 'keyboard-shift-symbolic') layout.shiftKeys.push(button);
// === Override ends here ===

if (key.action === 'delete') {
button.connect('long-press',
Expand Down Expand Up @@ -230,7 +222,11 @@ function enable_overrides() {
Keyboard.Keyboard.prototype["_addRowKeys"] = override_addRowKeys;
Keyboard.KeyboardManager.prototype["_lastDeviceIsTouchscreen"] =
override_lastDeviceIsTouchScreen;
Keyboard.KeyboardController.prototype["getCurrentGroup"] =

// Overriding a method on instantiated Keyboard object instead of a class definition
// as a workaround for built-in OSK breaking in unlock-dialog session mode
// See https://github.com/nick-shmyrev/improved-osk-gnome-ext/pull/36#pullrequestreview-1333498902 for details
Main.keyboard._keyboard._keyboardController["getCurrentGroup"] =
override_getCurrentGroup;

// Unregister original osk layouts resource file
Expand All @@ -247,7 +243,11 @@ function disable_overrides() {
Keyboard.Keyboard.prototype["_addRowKeys"] = backup_addRowKeys;
Keyboard.KeyboardManager.prototype["_lastDeviceIsTouchscreen"] =
backup_lastDeviceIsTouchScreen;
Keyboard.KeyboardController.prototype["getCurrentGroup"] =

// Restoring a method on instantiated Keyboard object instead of a class definition
// as a workaround for built-in OSK breaking in unlock-dialog session mode
// See https://github.com/nick-shmyrev/improved-osk-gnome-ext/pull/36#pullrequestreview-1333498902 for details
Main.keyboard._keyboard._keyboardController["getCurrentGroup"] =
backup_getCurrentGroup;

// Unregister modified osk layouts resource file
Expand Down Expand Up @@ -298,8 +298,11 @@ function init() {
backup_lastDeviceIsTouchScreen =
Keyboard.KeyboardManager._lastDeviceIsTouchscreen;

// Backing up a method of an instantiated Keyboard object instead of KeyboardController class method
// as a workaround for built-in OSK breaking in unlock-dialog session mode
// See https://github.com/nick-shmyrev/improved-osk-gnome-ext/pull/36#pullrequestreview-1333498902 for details
backup_getCurrentGroup =
Keyboard.KeyboardController.getCurrentGroup;
Main.keyboard._keyboard._keyboardController["getCurrentGroup"];

currentSeat = Clutter.get_default_backend().get_default_seat();
backup_touchMode = currentSeat.get_touch_mode;
Expand Down Expand Up @@ -358,9 +361,6 @@ function enable() {
}

function disable() {
// `unlock-dialog` session-mode is required to allow this extension
// to run in Gnome's screensaver login dialog

Main.layoutManager.removeChrome(Main.layoutManager.keyboardBox);

currentSeat.get_touch_mode = backup_touchMode;
Expand Down
4 changes: 2 additions & 2 deletions src/metadata.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"description": "Makes Gnome's OnScreen Keyboard more usable.\n\nFeatures:\n* Includes additional buttons: Arrow keys, Esc, Tab, Ctrl, Alt, F1-12\n* Supports key combinations like `Ctrl + C`, `Alt + Tab`, `Ctrl + Shift + C`, etc.\n* Configurable keyboard size (landscape/portrait)\n* Statusbar indicator to toggle keyboard\n* Works in Gnome password modals\n* Works on Gnome's login screen (see README for instructions)\n\nThis extension is a fork of https://extensions.gnome.org/extension/3330/improved-onscreen-keyboard/ by SebastianLuebke.",
"description": "Makes Gnome's OnScreen Keyboard more usable.\n\nFeatures:\n* Includes additional buttons: Arrow keys, Esc, Tab, Ctrl, Alt, F1-12\n* Supports key combinations like `Ctrl + C`, `Alt + Tab`, `Ctrl + Shift + C`, etc.\n* Configurable keyboard size (landscape/portrait)\n* Statusbar indicator to toggle keyboard\n* Works in Gnome password modals\n* Works on Lock screen (see README for instructions)\n* Works on Gnome's login screen (see README for instructions)\n\nThis extension is a fork of https://extensions.gnome.org/extension/3330/improved-onscreen-keyboard/ by SebastianLuebke.",
"name": "Improved OSK",
"shell-version": [
"43"
],
"url": "https://github.com/nick-shmyrev/improved-osk-gnome-ext",
"uuid": "[email protected]",
"version": 13,
"session-modes": ["user", "unlock-dialog"]
"session-modes": ["user"]
}

0 comments on commit 5c6f598

Please sign in to comment.