Refactor Polling Mechanism: Implement Class-Based Poller with Start/Stop Control (#528)

* custom module updates to class based.

* Finish poller logic.

* Use composition for pollers

* Rename poller

* Handle recorder polling.

* Fix quotes in bash command

* Remove logs
This commit is contained in:
Jas Singh
2024-11-23 03:55:00 -08:00
committed by GitHub
parent c10c9d0e93
commit a4f5fb5917
26 changed files with 460 additions and 169 deletions

View File

@@ -1,4 +1,5 @@
const hyprland = await Service.import('hyprland');
import { BashPoller } from 'lib/poller/BashPoller';
import { Attribute, BoxWidget, Child } from 'lib/types/widget';
import options from 'options';
import { Variable as VarType } from 'types/variable';
@@ -9,18 +10,26 @@ import Label from 'types/widgets/label';
const { left, right } = options.menus.dashboard.shortcuts;
const Shortcuts = (): BoxWidget => {
const isRecording = Variable(false, {
poll: [
1000,
`${App.configDir}/services/screen_record.sh status`,
(out): boolean => {
if (out === 'recording') {
return true;
}
return false;
},
],
});
const pollingInterval = Variable(1000);
const isRecording = Variable(false);
const handleRecorder = (commandOutput: string): boolean => {
if (commandOutput === 'recording') {
return true;
}
return false;
};
const recordingPoller = new BashPoller<boolean, []>(
isRecording,
[],
pollingInterval.bind('value'),
`${App.configDir}/services/screen_record.sh status`,
handleRecorder,
);
recordingPoller.initialize();
const handleClick = (action: string, tOut: number = 250): void => {
App.closeWindow('dashboardmenu');