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

42 lines
965 B
JavaScript
Raw Normal View History

2023-09-05 19:22:54 -04:00
const { Box, Label } = ags.Widget;
const { execAsync } = ags.Utils;
2023-09-11 21:10:00 -04:00
const { openWindow, closeWindow } = 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';
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
var calendarState = false;
export const Clock = EventBox({
2023-09-05 19:22:54 -04:00
className: 'toggle-off',
2023-09-11 21:10:00 -04:00
onPrimaryClickRelease: () => {
if (calendarState) {
Clock.toggleClassName('toggle-on', false);
closeWindow('calendar');
calendarState = false;
}
else {
Clock.toggleClassName('toggle-on', true);
openWindow('calendar');
calendarState = true;
}
},
child: Box({
child: ClockModule({}),
}),
2023-09-05 19:22:54 -04:00
});