Skip to content

Commit

Permalink
Revert "Dynamic keymap gen with python"
Browse files Browse the repository at this point in the history
This reverts commit e7946b0.
  • Loading branch information
Vishram1123 committed Jun 20, 2024
1 parent d198564 commit 3a0e754
Show file tree
Hide file tree
Showing 4 changed files with 612,857 additions and 17 deletions.
11 changes: 11 additions & 0 deletions genAllKeyMaps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
echo "{" > gjsosk@vishram1123.com/keycodes.json
for i in $(localectl list-x11-keymap-layouts); do
echo $i
python genKeyMap.py "$i" >> gjsosk@vishram1123.com/keycodes.json
for j in $(localectl list-x11-keymap-variants $i 2> /dev/null); do
echo "$i+$j"
python genKeyMap.py "$i+$j" >> gjsosk@vishram1123.com/keycodes.json
done;
done;
tac "gjsosk@vishram1123.com/keycodes.json" | awk -v c="," '!p && sub(c, "") {p=1} 1' | tac > temp.txt && mv temp.txt "gjsosk@vishram1123.com/keycodes.json"
echo "}" >> gjsosk@vishram1123.com/keycodes.json
2 changes: 1 addition & 1 deletion gjsosk@vishram1123.com/genKeyMap.py → genKeyMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,5 @@ def convertKeySymToString(sym):
}
})

print(json.dumps(formattedJson, indent = 4))
print(" ".join(('\n'+str("\"" + "+".join(model) + "\": " + json.dumps(formattedJson, indent = 4) + ",").lstrip()).splitlines(True)))

31 changes: 15 additions & 16 deletions gjsosk@vishram1123.com/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,9 @@ class GjsOskExtension {
this.openBit = this.settings.get_child("indicator");

let refresh = () => {
try {
let [status, out, err, code] = GLib.spawn_command_line_sync("python " + this.path + "/genKeyMap.py " + KeyboardManager.getKeyboardManager().currentLayout.id)
if (err != '') {
throw new Error(err, { cause: "`python " + this.path + "/genKeyMap.py " + KeyboardManager.getKeyboardManager().currentLayout.id + "`" });
} else {
keycodes = JSON.parse(out)
}
} catch (e) {
let message;
if (e.message.includes("xkbcommon")) {
message = "GJS-OSK: XKBCommon Not Found. Please install xkbcommon with the command (as root): `pip install xkbcommon`"
} else {
message = e.cause + " resulted in " + e.message
}
throw new Error (message)
let [ok, contents] = GLib.file_get_contents(Me.path + '/keycodes.json');
if (ok) {
keycodes = JSON.parse(contents)[KeyboardManager.getKeyboardManager().currentLayout.id];
}
if (this.Keyboard)
this.Keyboard.destroy();
Expand Down Expand Up @@ -1362,7 +1350,18 @@ class Keyboard extends Dialog {
}
}, 100);
} catch (err) {
throw new Error("GJS-OSK: An unknown error occured. Please report this bug to the Issues page:\n\n" + err + "\n\nKeys Pressed: " + keys)
let source = new imports.ui.messageTray.SystemNotificationSource();
source.connect('destroy', () => {
source = null;
})
Main.messageTray.add(source);
let notification = new imports.ui.messageTray.Notification(source, "GJS-OSK: An unknown error occured", "Please report this bug to the Issues page:\n\n" + err + "\n\nKeys Pressed: " + keys)
notification.setTransient(false);
notification.setResident(false);
source.showNotification(notification);
notification.connect("activated", () => {
sendCommand("xdg-open https://github.com/Vishram1123/gjs-osk/issues");
});
}
}

Expand Down
Loading

0 comments on commit 3a0e754

Please sign in to comment.