Implemented strict linting standards and prettier formatting config. (#248)

* Implemented strict linting standards and prettier formatting config.

* More linter fixes and type updates.

* More linter updates and type fixes

* Remove noisy comments

* Linter and type updates

* Linter, formatting and type updates.

* Linter updates

* Type updates

* Type updates

* fixed all linter errors

* Fixed all linting, formatting and type issues.

* Resolve merge conflicts.
This commit is contained in:
Jas Singh
2024-09-14 16:20:05 -07:00
committed by GitHub
parent ff13e3dd3c
commit 2c72cc66d8
222 changed files with 13141 additions and 8433 deletions

View File

@@ -1,44 +1,89 @@
import { OSDOrientation } from "lib/types/options";
import brightness from "services/Brightness"
import options from "options"
const audio = await Service.import("audio")
import { OSDOrientation } from 'lib/types/options';
import brightness from 'services/Brightness';
import options from 'options';
import Box from 'types/widgets/box';
import { Attribute, Child } from 'lib/types/widget';
const audio = await Service.import('audio');
export const OSDBar = (ort: OSDOrientation) => {
export const OSDBar = (ort: OSDOrientation): Box<Child, Attribute> => {
return Widget.Box({
class_name: "osd-bar-container",
class_name: 'osd-bar-container',
children: [
Widget.LevelBar({
class_name: "osd-bar",
vertical: ort === "vertical",
inverted: ort === "vertical",
bar_mode: "continuous",
setup: self => {
self.hook(brightness, () => {
self.class_names = self.class_names.filter(c => c !== "overflow");
self.value = brightness.screen;
}, "notify::screen")
self.hook(brightness, () => {
self.class_names = self.class_names.filter(c => c !== "overflow");
self.value = brightness.kbd;
}, "notify::kbd")
self.hook(audio.microphone, () => {
self.toggleClassName("overflow", audio.microphone.volume > 1)
self.value = audio.microphone.volume <= 1 ? audio.microphone.volume : audio.microphone.volume - 1;
}, "notify::volume")
self.hook(audio.microphone, () => {
self.toggleClassName("overflow", audio.microphone.volume > 1 && (!options.theme.osd.muted_zero.value || audio.microphone.is_muted === false));
self.value = (options.theme.osd.muted_zero.value && audio.microphone.is_muted !== false) ? 0 : audio.microphone.volume <= 1 ? audio.microphone.volume : audio.microphone.volume - 1;
}, "notify::is-muted")
self.hook(audio.speaker, () => {
self.toggleClassName("overflow", audio.speaker.volume > 1)
self.value = audio.speaker.volume <= 1 ? audio.speaker.volume : audio.speaker.volume - 1;
}, "notify::volume")
self.hook(audio.speaker, () => {
self.toggleClassName("overflow", audio.speaker.volume > 1 && (!options.theme.osd.muted_zero.value || audio.speaker.is_muted === false));
self.value = options.theme.osd.muted_zero.value && audio.speaker.is_muted !== false ? 0 : audio.speaker.volume <= 1 ? audio.speaker.volume : audio.speaker.volume - 1;
}, "notify::is-muted")
}
})
]
class_name: 'osd-bar',
vertical: ort === 'vertical',
inverted: ort === 'vertical',
bar_mode: 'continuous',
setup: (self) => {
self.hook(
brightness,
() => {
self.class_names = self.class_names.filter((c) => c !== 'overflow');
self.value = brightness.screen;
},
'notify::screen',
);
self.hook(
brightness,
() => {
self.class_names = self.class_names.filter((c) => c !== 'overflow');
self.value = brightness.kbd;
},
'notify::kbd',
);
self.hook(
audio.microphone,
() => {
self.toggleClassName('overflow', audio.microphone.volume > 1);
self.value =
audio.microphone.volume <= 1 ? audio.microphone.volume : audio.microphone.volume - 1;
},
'notify::volume',
);
self.hook(
audio.microphone,
() => {
self.toggleClassName(
'overflow',
audio.microphone.volume > 1 &&
(!options.theme.osd.muted_zero.value || audio.microphone.is_muted === false),
);
self.value =
options.theme.osd.muted_zero.value && audio.microphone.is_muted !== false
? 0
: audio.microphone.volume <= 1
? audio.microphone.volume
: audio.microphone.volume - 1;
},
'notify::is-muted',
);
self.hook(
audio.speaker,
() => {
self.toggleClassName('overflow', audio.speaker.volume > 1);
self.value = audio.speaker.volume <= 1 ? audio.speaker.volume : audio.speaker.volume - 1;
},
'notify::volume',
);
self.hook(
audio.speaker,
() => {
self.toggleClassName(
'overflow',
audio.speaker.volume > 1 &&
(!options.theme.osd.muted_zero.value || audio.speaker.is_muted === false),
);
self.value =
options.theme.osd.muted_zero.value && audio.speaker.is_muted !== false
? 0
: audio.speaker.volume <= 1
? audio.speaker.volume
: audio.speaker.volume - 1;
},
'notify::is-muted',
);
},
}),
],
});
}
};

View File

@@ -1,36 +1,62 @@
import brightness from "services/Brightness"
const audio = await Service.import("audio")
import { Attribute, Child } from 'lib/types/widget';
import brightness from 'services/Brightness';
import Box from 'types/widgets/box';
const audio = await Service.import('audio');
export const OSDIcon = () => {
export const OSDIcon = (): Box<Child, Attribute> => {
return Widget.Box({
class_name: "osd-icon-container",
class_name: 'osd-icon-container',
hexpand: true,
child: Widget.Label({
class_name: "osd-icon txt-icon",
class_name: 'osd-icon txt-icon',
hexpand: true,
vexpand: true,
hpack: "center",
vpack: "center",
setup: self => {
self.hook(brightness, () => {
self.label = "󱍖";
}, "notify::screen")
self.hook(brightness, () => {
self.label = "󰥻";
}, "notify::kbd")
self.hook(audio.microphone, () => {
self.label = audio.microphone.is_muted ? "󰍭" : "󰍬";
}, "notify::volume")
self.hook(audio.microphone, () => {
self.label = audio.microphone.is_muted ? "󰍭" : "󰍬";
}, "notify::is-muted")
self.hook(audio.speaker, () => {
self.label = audio.speaker.is_muted ? "󰝟" : "󰕾";
}, "notify::volume")
self.hook(audio.speaker, () => {
self.label = audio.speaker.is_muted ? "󰝟" : "󰕾";
}, "notify::is-muted")
}
})
hpack: 'center',
vpack: 'center',
setup: (self) => {
self.hook(
brightness,
() => {
self.label = '󱍖';
},
'notify::screen',
);
self.hook(
brightness,
() => {
self.label = '󰥻';
},
'notify::kbd',
);
self.hook(
audio.microphone,
() => {
self.label = audio.microphone.is_muted ? '󰍭' : '󰍬';
},
'notify::volume',
);
self.hook(
audio.microphone,
() => {
self.label = audio.microphone.is_muted ? '󰍭' : '󰍬';
},
'notify::is-muted',
);
self.hook(
audio.speaker,
() => {
self.label = audio.speaker.is_muted ? '󰝟' : '󰕾';
},
'notify::volume',
);
self.hook(
audio.speaker,
() => {
self.label = audio.speaker.is_muted ? '󰝟' : '󰕾';
},
'notify::is-muted',
);
},
}),
});
}
};

View File

@@ -1,132 +1,199 @@
import options from "options";
import brightness from "services/Brightness"
import { OSDLabel } from "./label/index";
import { OSDBar } from "./bar/index";
import { OSDIcon } from "./icon/index";
import { getPosition } from "lib/utils";
const hyprland = await Service.import("hyprland");
const audio = await Service.import("audio")
import options from 'options';
import brightness from 'services/Brightness';
import { OSDLabel } from './label/index';
import { OSDBar } from './bar/index';
import { OSDIcon } from './icon/index';
import { getPosition } from 'lib/utils';
import { Attribute, Child } from 'lib/types/widget';
import { Revealer } from 'resource:///com/github/Aylur/ags/widgets/revealer.js';
import { Window } from 'resource:///com/github/Aylur/ags/widgets/window.js';
const hyprland = await Service.import('hyprland');
const audio = await Service.import('audio');
const {
enable,
duration,
orientation,
location,
active_monitor,
monitor
} = options.theme.osd;
const { enable, duration, orientation, location, active_monitor, monitor } = options.theme.osd;
const curMonitor = Variable(monitor.value);
hyprland.active.connect("changed", () => {
hyprland.active.connect('changed', () => {
curMonitor.value = hyprland.active.monitor.id;
})
});
let count = 0
const handleReveal = (self: any, property: string) => {
if (!enable.value) {
let count = 0;
const handleRevealRevealer = (self: Revealer<Child, Attribute>, property: 'reveal_child' | 'visible'): void => {
if (!enable.value || property !== 'reveal_child') {
return;
}
self[property] = true
count++
self.reveal_child = true;
count++;
Utils.timeout(duration.value, () => {
count--
count--;
if (count === 0)
self[property] = false
})
}
if (count === 0) {
self.reveal_child = false;
}
});
};
const renderOSD = () => {
const handleRevealWindow = (self: Window<Child, Attribute>, property: 'reveal_child' | 'visible'): void => {
if (!enable.value || property !== 'visible') {
return;
}
self.visible = true;
count++;
Utils.timeout(duration.value, () => {
count--;
if (count === 0) {
self.visible = false;
}
});
};
const handleReveal = (
self: Revealer<Child, Attribute> | Window<Child, Attribute>,
property: 'reveal_child' | 'visible',
): void => {
if (self instanceof Revealer) {
handleRevealRevealer(self, property);
} else if (self instanceof Window) {
handleRevealWindow(self, property);
}
};
const renderOSD = (): Revealer<Child, Attribute> => {
return Widget.Revealer({
transition: "crossfade",
transition: 'crossfade',
reveal_child: false,
setup: self => {
self.hook(brightness, () => {
handleReveal(self, "reveal_child");
}, "notify::screen")
self.hook(brightness, () => {
handleReveal(self, "reveal_child");
}, "notify::kbd")
self.hook(audio.microphone, () => {
handleReveal(self, "reveal_child");
}, "notify::volume")
self.hook(audio.microphone, () => {
handleReveal(self, "reveal_child");
}, "notify::is-muted")
self.hook(audio.speaker, () => {
handleReveal(self, "reveal_child");
}, "notify::volume")
self.hook(audio.speaker, () => {
handleReveal(self, "reveal_child");
}, "notify::is-muted")
setup: (self) => {
self.hook(
brightness,
() => {
handleReveal(self, 'reveal_child');
},
'notify::screen',
);
self.hook(
brightness,
() => {
handleReveal(self, 'reveal_child');
},
'notify::kbd',
);
self.hook(
audio.microphone,
() => {
handleReveal(self, 'reveal_child');
},
'notify::volume',
);
self.hook(
audio.microphone,
() => {
handleReveal(self, 'reveal_child');
},
'notify::is-muted',
);
self.hook(
audio.speaker,
() => {
handleReveal(self, 'reveal_child');
},
'notify::volume',
);
self.hook(
audio.speaker,
() => {
handleReveal(self, 'reveal_child');
},
'notify::is-muted',
);
},
child: Widget.Box({
class_name: "osd-container",
vertical: orientation.bind("value").as(ort => ort === "vertical"),
children: orientation.bind("value").as(ort => {
if (ort === "vertical") {
return [
OSDLabel(),
OSDBar(ort),
OSDIcon()
]
class_name: 'osd-container',
vertical: orientation.bind('value').as((ort) => ort === 'vertical'),
children: orientation.bind('value').as((ort) => {
if (ort === 'vertical') {
return [OSDLabel(), OSDBar(ort), OSDIcon()];
}
return [
OSDIcon(),
OSDBar(ort),
OSDLabel(),
]
})
})
})
}
export default () => Widget.Window({
monitor: Utils.merge([
curMonitor.bind("value"),
monitor.bind("value"),
active_monitor.bind("value")], (curMon, mon, activeMonitor) => {
if (activeMonitor === true) {
return curMon;
}
return mon;
return [OSDIcon(), OSDBar(ort), OSDLabel()];
}),
}),
name: `indicator`,
class_name: "indicator",
layer: options.tear.bind("value").as(tear => tear ? "top" : "overlay"),
anchor: location.bind("value").as(v => getPosition(v)),
click_through: true,
child: Widget.Box({
css: "padding: 1px;",
expand: true,
child: renderOSD(),
}),
setup: self => {
self.hook(enable, () => {
handleReveal(self, "visible");
})
self.hook(brightness, () => {
handleReveal(self, "visible");
}, "notify::screen")
self.hook(brightness, () => {
handleReveal(self, "visible");
}, "notify::kbd")
self.hook(audio.microphone, () => {
handleReveal(self, "visible");
}, "notify::volume")
self.hook(audio.microphone, () => {
handleReveal(self, "visible");
}, "notify::is-muted")
self.hook(audio.speaker, () => {
handleReveal(self, "visible");
}, "notify::volume")
self.hook(audio.speaker, () => {
handleReveal(self, "visible");
}, "notify::is-muted")
},
})
});
};
export default (): Window<Child, Attribute> =>
Widget.Window({
monitor: Utils.merge(
[curMonitor.bind('value'), monitor.bind('value'), active_monitor.bind('value')],
(curMon, mon, activeMonitor) => {
if (activeMonitor === true) {
return curMon;
}
return mon;
},
),
name: `indicator`,
class_name: 'indicator',
layer: options.tear.bind('value').as((tear) => (tear ? 'top' : 'overlay')),
anchor: location.bind('value').as((v) => getPosition(v)),
click_through: true,
child: Widget.Box({
css: 'padding: 1px;',
expand: true,
child: renderOSD(),
}),
setup: (self) => {
self.hook(enable, () => {
handleReveal(self, 'visible');
});
self.hook(
brightness,
() => {
handleReveal(self, 'visible');
},
'notify::screen',
);
self.hook(
brightness,
() => {
handleReveal(self, 'visible');
},
'notify::kbd',
);
self.hook(
audio.microphone,
() => {
handleReveal(self, 'visible');
},
'notify::volume',
);
self.hook(
audio.microphone,
() => {
handleReveal(self, 'visible');
},
'notify::is-muted',
);
self.hook(
audio.speaker,
() => {
handleReveal(self, 'visible');
},
'notify::volume',
);
self.hook(
audio.speaker,
() => {
handleReveal(self, 'visible');
},
'notify::is-muted',
);
},
});

View File

@@ -1,44 +1,86 @@
import brightness from "services/Brightness"
import options from "options"
const audio = await Service.import("audio")
import brightness from 'services/Brightness';
import options from 'options';
import Box from 'types/widgets/box';
import { Attribute, Child } from 'lib/types/widget';
const audio = await Service.import('audio');
export const OSDLabel = () => {
export const OSDLabel = (): Box<Child, Attribute> => {
return Widget.Box({
class_name: "osd-label-container",
class_name: 'osd-label-container',
hexpand: true,
vexpand: true,
child: Widget.Label({
class_name: "osd-label",
class_name: 'osd-label',
hexpand: true,
vexpand: true,
hpack: "center",
vpack: "center",
setup: self => {
self.hook(brightness, () => {
self.class_names = self.class_names.filter(c => c !== "overflow");
self.label = `${Math.round(brightness.screen * 100)}`;
}, "notify::screen")
self.hook(brightness, () => {
self.class_names = self.class_names.filter(c => c !== "overflow");
self.label = `${Math.round(brightness.kbd * 100)}`;
}, "notify::kbd")
self.hook(audio.microphone, () => {
self.toggleClassName("overflow", audio.microphone.volume > 1)
self.label = `${Math.round(audio.microphone.volume * 100)}`;
}, "notify::volume")
self.hook(audio.microphone, () => {
self.toggleClassName("overflow", audio.microphone.volume > 1 && (!options.theme.osd.muted_zero.value || audio.microphone.is_muted === false));
self.label = `${options.theme.osd.muted_zero.value && audio.microphone.is_muted !== false ? 0 : Math.round(audio.microphone.volume * 100)}`;
}, "notify::is-muted")
self.hook(audio.speaker, () => {
self.toggleClassName("overflow", audio.speaker.volume > 1)
self.label = `${Math.round(audio.speaker.volume * 100)}`;
}, "notify::volume")
self.hook(audio.speaker, () => {
self.toggleClassName("overflow", audio.speaker.volume > 1 && (!options.theme.osd.muted_zero.value || audio.speaker.is_muted === false));
self.label = `${options.theme.osd.muted_zero.value && audio.speaker.is_muted !== false ? 0 : Math.round(audio.speaker.volume * 100)}`;
}, "notify::is-muted")
}
})
hpack: 'center',
vpack: 'center',
setup: (self) => {
self.hook(
brightness,
() => {
self.class_names = self.class_names.filter((c) => c !== 'overflow');
self.label = `${Math.round(brightness.screen * 100)}`;
},
'notify::screen',
);
self.hook(
brightness,
() => {
self.class_names = self.class_names.filter((c) => c !== 'overflow');
self.label = `${Math.round(brightness.kbd * 100)}`;
},
'notify::kbd',
);
self.hook(
audio.microphone,
() => {
self.toggleClassName('overflow', audio.microphone.volume > 1);
self.label = `${Math.round(audio.microphone.volume * 100)}`;
},
'notify::volume',
);
self.hook(
audio.microphone,
() => {
self.toggleClassName(
'overflow',
audio.microphone.volume > 1 &&
(!options.theme.osd.muted_zero.value || audio.microphone.is_muted === false),
);
const inputVolume =
options.theme.osd.muted_zero.value && audio.microphone.is_muted !== false
? 0
: Math.round(audio.microphone.volume * 100);
self.label = `${inputVolume}`;
},
'notify::is-muted',
);
self.hook(
audio.speaker,
() => {
self.toggleClassName('overflow', audio.speaker.volume > 1);
self.label = `${Math.round(audio.speaker.volume * 100)}`;
},
'notify::volume',
);
self.hook(
audio.speaker,
() => {
self.toggleClassName(
'overflow',
audio.speaker.volume > 1 &&
(!options.theme.osd.muted_zero.value || audio.speaker.is_muted === false),
);
const speakerVolume =
options.theme.osd.muted_zero.value && audio.speaker.is_muted !== false
? 0
: Math.round(audio.speaker.volume * 100);
self.label = `${speakerVolume}`;
},
'notify::is-muted',
);
},
}),
});
}
};