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:
@@ -1,6 +1,6 @@
|
||||
import { Variable as TVariable } from 'types/variable';
|
||||
|
||||
export const isActiveCommand = `bash -c "pgrep -x "hypridle" > /dev/null && echo "yes" || echo "no""`;
|
||||
export const isActiveCommand = `bash -c "pgrep -x 'hypridle' &>/dev/null && echo 'yes' || echo 'no'"`;
|
||||
|
||||
export const isActive = Variable(false);
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import { inputHandler, throttleInput } from 'customModules/utils';
|
||||
import Button from 'types/widgets/button';
|
||||
import { Attribute, Child } from 'lib/types/widget';
|
||||
import { BarBoxChild } from 'lib/types/bar';
|
||||
import { pollVariable } from 'customModules/PollVar';
|
||||
import { checkIdleStatus, isActive, toggleIdle } from './helpers';
|
||||
import { FunctionPoller } from 'lib/poller/FunctionPoller';
|
||||
|
||||
const { label, pollingInterval, onIcon, offIcon, onLabel, offLabel, rightClick, middleClick, scrollUp, scrollDown } =
|
||||
options.bar.customModules.hypridle;
|
||||
@@ -15,7 +15,14 @@ const dummyVar = Variable(undefined);
|
||||
|
||||
checkIdleStatus();
|
||||
|
||||
pollVariable(dummyVar, [], pollingInterval.bind('value'), checkIdleStatus);
|
||||
const idleStatusPoller = new FunctionPoller<undefined, []>(
|
||||
dummyVar,
|
||||
[],
|
||||
pollingInterval.bind('value'),
|
||||
checkIdleStatus,
|
||||
);
|
||||
|
||||
idleStatusPoller.initialize('hypridle');
|
||||
|
||||
const throttledToggleIdle = throttleInput(() => toggleIdle(isActive), 1000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user