nixos-configs/config/ags/js/bar/osk-toggle.js

42 lines
937 B
JavaScript
Raw Normal View History

2023-09-04 22:47:12 -04:00
const { Box, Label } = ags.Widget;
const { subprocess, exec } = ags.Utils;
const deflisten = subprocess;
2023-09-04 22:27:34 -04:00
2023-09-11 19:57:21 -04:00
import { EventBox } from '../misc/cursorbox.js';
2023-09-04 22:47:12 -04:00
deflisten(
['bash', '-c', '$AGS_PATH/osk-toggle.sh getState'],
2023-09-04 22:27:34 -04:00
(output) => {
if (output == 'Running') {
OskToggle.toggleClassName('toggle-on', true);
} else {
OskToggle.toggleClassName('toggle-on', false);
}
},
);
export const OskToggle = EventBox({
className: 'toggle-off',
onPrimaryClickRelease: function() {
2023-09-04 22:47:12 -04:00
subprocess(
['bash', '-c', '$AGS_PATH/osk-toggle.sh toggle'],
2023-09-04 22:27:34 -04:00
(output) => {
if (output == 'Running') {
OskToggle.toggleClassName('toggle-on', false);
} else {
OskToggle.toggleClassName('toggle-on', true);
}
},
);
},
2023-09-04 22:47:12 -04:00
child: Box({
2023-09-04 22:27:34 -04:00
className: 'osk-toggle',
vertical: false,
children: [
2023-09-04 22:47:12 -04:00
Label({
2023-09-04 22:27:34 -04:00
label: " 󰌌 ",
}),
],
}),
});