[4]: https://github.com/roadmanfong/LunarCalendar
- - [node-cron][5] (by @ncb000gt)
+ - [node-cron (cron)][5] (by @ncb000gt)
npm package: https://www.npmjs.com/package/cron
[5]: https://github.com/ncb000gt/node-cron
+
+ - [node-dbus (dbus-native)][6] (by @sidorares)
+
+ npm package: https://www.npmjs.com/package/dbus-native
+
+ [6]: https://github.com/sidorares/node-dbus
## Usage
var AppIndicator3 = GNode.importNS('AppIndicator3');
var CronJob = require('cron').CronJob;
var LunarCalendar = require('lunar-calendar-zh');
+var DBus = require('dbus-native');
/* setup indicator object */
GNode.startLoop();
});
update_indicator();
+
+/* Detect resume from suspend and update date/time */
+var bus = DBus.systemBus();
+var service = bus.getService('org.freedesktop.login1');
+service.getInterface(
+ '/org/freedesktop/login1',
+ 'org.freedesktop.login1.Manager',
+ function(err, nm) {
+ nm.addListener('PrepareForSleep', function(arg) {
+ // PrepareForSleep returns false when resuming from suspend
+ if(!arg) {
+ job.stop(); // force cronjob to recalculate time
+ job.start();
+ update_indicator();
+ }
+ });
+ }
+);
+
Gtk.main();