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

40 lines
889 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
import EventBox from '../misc/cursorbox.js';
2023-09-11 21:10:00 -04:00
2023-09-05 19:22:54 -04:00
const ClockModule = ({
interval = 1000,
...props
2023-09-05 19:22:54 -04:00
}) => Label({
...props,
2023-09-05 19:22:54 -04:00
className: 'clock',
2023-09-05 19:57:34 -04:00
connections: [
[interval, self => {
2023-09-05 19:57:34 -04:00
var time = DateTime.new_now_local();
self.label = time.format('%a. ') +
time.get_day_of_month() +
time.format(' %b. %H:%M');
2023-09-05 19:57:34 -04:00
}],
],
2023-09-05 19:22:54 -04:00
});
export default () => 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, (self, windowName, visible) => {
if (windowName == 'calendar') {
self.toggleClassName('toggle-on', visible);
}
}],
],
2023-09-11 21:10:00 -04:00
child: Box({
child: ClockModule({}),
}),
2023-09-05 19:22:54 -04:00
});