Added strict type checking to the project. (#236)

* Implement strict typing (WIP).

* changes

* Finish type checks

* Fix notification icon, matugen settings and update tsconfig.

* OSD Styling updates and added the ability to configure OSD duration.
This commit is contained in:
Jas Singh
2024-09-09 00:44:51 -07:00
committed by GitHub
parent 41dbc3829a
commit bb3b3dfdfb
56 changed files with 468 additions and 240 deletions

View File

@@ -1,27 +1,31 @@
const getIcon = (audioVol, isMuted) => {
const speakerIcons = {
const speakerIcons = {
101: "audio-volume-overamplified-symbolic",
66: "audio-volume-high-symbolic",
34: "audio-volume-medium-symbolic",
1: "audio-volume-low-symbolic",
0: "audio-volume-muted-symbolic",
};
} as const;
const inputIcons = {
const inputIcons = {
101: "microphone-sensitivity-high-symbolic",
66: "microphone-sensitivity-high-symbolic",
34: "microphone-sensitivity-medium-symbolic",
1: "microphone-sensitivity-low-symbolic",
0: "microphone-disabled-symbolic",
};
};
const icon = isMuted
? 0
: [101, 66, 34, 1, 0].find((threshold) => threshold <= audioVol * 100);
type IconVolumes = keyof typeof speakerIcons;
return {
spkr: speakerIcons[icon],
mic: inputIcons[icon],
};
const getIcon = (audioVol: IconVolumes, isMuted: boolean) => {
const thresholds: IconVolumes[] = [101, 66, 34, 1, 0];
const icon = isMuted
? 0
: thresholds.find((threshold) => threshold <= audioVol * 100) || 0;
return {
spkr: speakerIcons[icon],
mic: inputIcons[icon],
};
};
export { getIcon };