Added the hyprsunset module (requires hyprland v0.45.0) (#485)
* add sunset module * Implement hyprsunset module. * Update themes * Undo vivids * Fix vivids
This commit is contained in:
33
customModules/hyprsunset/helpers.ts
Normal file
33
customModules/hyprsunset/helpers.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import options from 'options';
|
||||
|
||||
import { Variable as TVariable } from 'types/variable';
|
||||
|
||||
const { temperature } = options.bar.customModules.hyprsunset;
|
||||
|
||||
export const isActiveCommand = `bash -c "pgrep -x "hyprsunset" > /dev/null && echo "yes" || echo "no""`;
|
||||
|
||||
export const isActive = Variable(false);
|
||||
|
||||
export const toggleSunset = (isActive: TVariable<boolean>): void => {
|
||||
Utils.execAsync(isActiveCommand).then((res) => {
|
||||
if (res === 'no') {
|
||||
Utils.execAsync(`bash -c "nohup hyprsunset -t ${temperature.value} > /dev/null 2>&1 &"`).then(() => {
|
||||
Utils.execAsync(isActiveCommand).then((res) => {
|
||||
isActive.value = res === 'yes';
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Utils.execAsync(`bash -c "pkill hyprsunset "`).then(() => {
|
||||
Utils.execAsync(isActiveCommand).then((res) => {
|
||||
isActive.value = res === 'yes';
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const checkSunsetStatus = (): undefined => {
|
||||
Utils.execAsync(isActiveCommand).then((res) => {
|
||||
isActive.value = res === 'yes';
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user