testing ags

This commit is contained in:
cnst
2024-07-15 14:39:56 +02:00
parent 91e09c461b
commit 2f32e46601
55 changed files with 2218 additions and 22 deletions

View File

@@ -0,0 +1,65 @@
import { Audio, Icons, Service, Utils } from "../imports.js";
import { audioIcon, micIcon } from "../utils/audio.js";
import Brightness from "./brightness.js";
class Indicator extends Service {
static {
Service.register(this, {
popup: ["jsobject", "boolean"],
});
}
#delay = 1500;
#count = 0;
popup(value, label, icon, showProgress = true) {
const props = {
value,
label,
icon,
showProgress,
};
this.emit("popup", props, true);
this.#count++;
Utils.timeout(this.#delay, () => {
this.#count--;
if (this.#count === 0) {
this.emit("popup", props, false);
}
});
}
bluetooth(addr) {
this.popup(0, getBluetoothDevice(addr), Icons.bluetooth.active, false);
}
speaker() {
this.popup(
Audio.speaker?.volume ?? 0,
Audio.speaker?.description ?? "",
audioIcon(),
);
}
mic() {
this.popup(
Audio.microphone?.volume || 0,
Audio.microphone?.description || "",
micIcon(),
);
}
display() {
// brightness is async, so lets wait a bit
Utils.timeout(10, () =>
this.popup(Brightness.screenValue, "Brightness", Icons.brightness),
);
}
connect(event = "popup", callback) {
return super.connect(event, callback);
}
}
export default new Indicator();