feat(ags brightness): allow bind to caps lock

This commit is contained in:
matt1432 2023-11-27 20:57:07 -05:00
parent 523b886843
commit 158758b4ab

View file

@ -12,12 +12,15 @@ class Brightness extends Service {
screen: ['float'],
kbd: ['float'],
caps: ['int'],
}, {
'caps-icon': ['string', 'rw'],
});
}
#kbd = 0;
#screen = 0;
#caps = 0;
#capsIcon = 'caps-lock-symbolic';
get kbd() {
return this.#kbd;
@ -31,6 +34,10 @@ class Brightness extends Service {
return this.#caps;
}
get capsIcon() {
return this.#capsIcon;
}
set kbd(value) {
this.#kbd = value;
// TODO
@ -69,7 +76,12 @@ class Brightness extends Service {
fetchCapsState() {
execAsync(`brightnessctl -d ${CAPS} g`)
.then((out) => {
this.#caps = out;
this.#caps = Number(out);
this.#capsIcon = this.#caps ?
'caps-lock-symbolic' :
'capslock-disabled-symbolic';
this.notify('caps-icon');
this.emit('caps', this.#caps);
})
.catch(logError);