feat: idle inhibit (#502)
Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
29
customModules/hypridle/helpers.ts
Normal file
29
customModules/hypridle/helpers.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Variable as TVariable } from 'types/variable';
|
||||
|
||||
export const isActiveCommand = `bash -c "pgrep -x "hypridle" > /dev/null && echo "yes" || echo "no""`;
|
||||
|
||||
export const isActive = Variable(false);
|
||||
|
||||
export const toggleIdle = (isActive: TVariable<boolean>): void => {
|
||||
Utils.execAsync(isActiveCommand).then((res) => {
|
||||
if (res === 'no') {
|
||||
Utils.execAsync(`bash -c "nohup hypridle > /dev/null 2>&1 &"`).then(() => {
|
||||
Utils.execAsync(isActiveCommand).then((res) => {
|
||||
isActive.value = res === 'yes';
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Utils.execAsync(`bash -c "pkill hypridle "`).then(() => {
|
||||
Utils.execAsync(isActiveCommand).then((res) => {
|
||||
isActive.value = res === 'yes';
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const checkIdleStatus = (): undefined => {
|
||||
Utils.execAsync(isActiveCommand).then((res) => {
|
||||
isActive.value = res === 'yes';
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user