nixos-configs/devices/wim/config/ags/js/bar/buttons/clock.js

40 lines
930 B
JavaScript
Raw Normal View History

import App from 'resource:///com/github/Aylur/ags/app.js';
import { Label } from 'resource:///com/github/Aylur/ags/widget.js';
import GLib from 'gi://GLib';
const { DateTime } = GLib;
2023-09-05 19:22:54 -04:00
2023-11-16 00:48:50 -05:00
import EventBox from '../../misc/cursorbox.js';
2023-09-11 21:10:00 -04:00
const ClockModule = () => Label({
className: 'clock',
setup: (self) => {
self.poll(1000, () => {
const time = DateTime.new_now_local();
self.label = time.format('%a. ') +
time.get_day_of_month() +
time.format(' %b. %H:%M');
});
},
});
2023-09-05 19:22:54 -04:00
export default () => EventBox({
className: 'toggle-off',
onPrimaryClickRelease: () => App.toggleWindow('calendar'),
setup: (self) => {
self.hook(App, (_, windowName, visible) => {
if (windowName === 'calendar') {
self.toggleClassName('toggle-on', visible);
}
});
},
child: ClockModule(),
2023-09-05 19:22:54 -04:00
});