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

32 lines
839 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';
2023-12-18 18:00:30 -05:00
const { DateTime } = imports.gi.GLib;
2023-09-05 19:22:54 -04:00
import CursorBox from '../../misc/cursorbox.js';
2023-09-11 21:10:00 -04:00
export default () => CursorBox({
class_name: 'toggle-off',
on_primary_click_release: () => App.toggleWindow('calendar'),
setup: (self) => {
self.hook(App, (_, windowName, visible) => {
if (windowName === 'calendar') {
self.toggleClassName('toggle-on', visible);
}
});
},
2023-12-18 18:00:30 -05:00
child: Label({ class_name: 'clock' })
.poll(1000, (self) => {
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
});