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