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

43 lines
1 KiB
JavaScript
Raw Normal View History

2023-09-05 19:22:54 -04:00
const { Box, Label } = ags.Widget;
const { toggleWindow, openWindow } = ags.App;
2023-09-05 19:22:54 -04:00
const { DateTime } = imports.gi.GLib;
2023-09-11 21:10:00 -04:00
import { EventBox } from '../misc/cursorbox.js';
import { closeAll } from '../misc/closer.js';
2023-09-11 21:10:00 -04:00
2023-09-05 19:22:54 -04:00
const ClockModule = ({
interval = 1000,
...params
2023-09-05 19:22:54 -04:00
}) => Label({
...params,
2023-09-05 19:22:54 -04:00
className: 'clock',
2023-09-05 19:57:34 -04:00
connections: [
[interval, label => {
var time = DateTime.new_now_local();
label.label = time.format('%a. ') + time.get_day_of_month() + time.format(' %b. %H:%M');
}],
],
2023-09-05 19:22:54 -04:00
});
2023-09-11 21:10:00 -04:00
export const Clock = EventBox({
2023-09-05 19:22:54 -04:00
className: 'toggle-off',
onPrimaryClickRelease: () => toggleWindow('calendar'),
connections: [
[ags.App, (box, windowName, visible) => {
if (windowName == 'calendar') {
if (visible) {
Clock.toggleClassName('toggle-on', true);
openWindow('closer');
}
else {
Clock.toggleClassName('toggle-on', false);
closeAll();
}
}
}],
],
2023-09-11 21:10:00 -04:00
child: Box({
child: ClockModule({}),
}),
2023-09-05 19:22:54 -04:00
});