nixos-configs/devices/wim/config/ags/js/on-screen-keyboard/main.js

34 lines
833 B
JavaScript
Raw Normal View History

import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import Gesture from './gesture.js';
import Keyboard from './keyboard.js';
import PopupWindow from '../misc/popup.js';
// ydotool stuff
execAsync('ydotoold').catch(print);
function releaseAllKeys() {
const keycodes = Array.from(Array(249).keys());
2023-11-19 16:25:01 -05:00
execAsync([
'ydotool', 'key',
...keycodes.map(keycode => `${keycode}:0`),
]).catch(print);
}
// Window
2023-11-19 16:25:01 -05:00
export default () => {
const window = PopupWindow({
name: 'osk',
anchor: ['left', 'bottom', 'right'],
onClose: releaseAllKeys,
closeOnUnfocus: 'none',
connections: [[Tablet, self => {
self.visible = Tablet.oskState;
}, 'osk-toggled']],
});
window.setChild(Keyboard(window));
return Gesture(window);
};