nixos-configs/config/ags/js/bar/notif-button.js

46 lines
1.1 KiB
JavaScript

const { Box, Label } = ags.Widget;
const { subprocess } = ags.Utils;
const deflisten = subprocess;
import { EventBox } from '../common.js';
deflisten(
['bash', '-c', '$AGS_PATH/notif.sh icon'],
(output) => {
NotifButton.child.children[0].label = ' ' + output;
},
);
deflisten(
['bash', '-c', '$AGS_PATH/notif-toggle.sh state'],
(output) => {
print(output)
if (output == 'On') {
NotifButton.toggleClassName('toggle-on', false);
} else {
NotifButton.toggleClassName('toggle-on', true);
}
},
);
export const NotifButton = EventBox({
className: 'toggle-off',
onPrimaryClickRelease: function() {
subprocess(
['bash', '-c', '$AGS_PATH/notif-toggle.sh toggle'],
(output) => {
print(output)
if (output == 'On') {
NotifButton.toggleClassName('toggle-on', true);
} else {
NotifButton.toggleClassName('toggle-on', false);
}
},
);
},
child: Box({
className: 'notif-panel',
vertical: false,
child: Label({
label: "",
}),
}),
});