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

38 lines
853 B
JavaScript
Raw Normal View History

import { App, Widget } from '../../imports.js';
const { Box, Label } = Widget;
import GLib from 'gi://GLib';
const { DateTime } = GLib;
2023-09-05 19:22:54 -04:00
2023-09-11 21:10:00 -04:00
import { EventBox } from '../misc/cursorbox.js';
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',
2023-10-14 13:54:45 -04:00
onPrimaryClickRelease: () => App.toggleWindow('calendar'),
connections: [
[App, (box, windowName, visible) => {
if (windowName == 'calendar') {
box.toggleClassName('toggle-on', visible);
}
}],
],
2023-09-11 21:10:00 -04:00
child: Box({
child: ClockModule({}),
}),
2023-09-05 19:22:54 -04:00
});