feat(ags): add wip keyboard layout widget

This commit is contained in:
matt1432 2023-10-13 17:01:02 -04:00
parent cec3f73b4d
commit 708f9fff49
2 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,30 @@
import { Hyprland, Utils, Widget } from '../../imports.js';
const { Label, Box, Icon } = Widget;
const DEFAULT_KB = "at-translated-set-2-keyboard";
export default Box({
className: 'toggle-off',
children: [
Icon({
icon: 'input-keyboard-symbolic',
style: 'margin-right: 4px;',
}),
Label({
connections: [[Hyprland, (self, _n, layout) => {
if (!layout) {
let obj = Utils.exec('hyprctl devices -j')
let keyboards = JSON.parse(obj)['keyboards'];
let kb = keyboards.find(val => val.name === DEFAULT_KB);
layout = kb['active_keymap'];
self.label = layout;
}
else {
self.label = layout;
}
}, 'keyboard-layout']],
}),
],
});

View file

@ -14,6 +14,7 @@ import { BatteryIndicator } from './battery.js';
import { Brightness } from './brightness.js';
import { AudioIndicator } from './audio.js';
import { Revealer } from './fullscreen.js';
//import KeyboardLayout from './keyboard-layout.js';
export const Bar = Window({
@ -68,6 +69,10 @@ export const Bar = Window({
Separator(12),
//KeyboardLayout,
//Separator(12),
Clock,
Separator(12),