nixos-configs/config/ags/js/bar/heart.js

34 lines
721 B
JavaScript
Raw Normal View History

2023-09-04 22:44:00 -04:00
const { Box, Label } = ags.Widget;
const { subprocess, exec } = ags.Utils;
const deflisten = subprocess;
2023-09-04 22:27:34 -04:00
import { EventBox } from '../common.js';
2023-09-04 22:44:00 -04:00
deflisten(
2023-09-04 22:27:34 -04:00
['bash', '-c', 'tail -f /home/matt/.config/.heart'],
(output) => {
Heart.child.children[0].label = ' ' + output;
if (output == '󰣐') {
Heart.toggleClassName('toggle-on', true);
} else {
Heart.toggleClassName('toggle-on', false);
}
},
);
export const Heart = EventBox({
className: 'toggle-off',
halign: 'center',
2023-09-04 22:44:00 -04:00
onPrimaryClickRelease: () => {
exec("bash -c '$AGS_PATH/heart.sh toggle'");
2023-09-04 22:27:34 -04:00
},
2023-09-04 22:44:00 -04:00
child: Box({
2023-09-04 22:27:34 -04:00
className: 'heart-toggle',
vertical: false,
2023-09-04 22:44:00 -04:00
child: Label({
2023-09-04 22:27:34 -04:00
label: '',
}),
}),
});