diff --git a/README.md b/README.md index fb06d67..3236120 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ then * the dropdown menu button is placed in the panel at `POSITION`, and * the plugin is re-run and its output re-rendered every `INTERVAL`, and -* if `INTERVAL` is followed by `+`, the plugin is additionally re-run each time the dropdown menu is opened. +* if `INTERVAL` is followed by `+`, the plugin is additionally re-run each time the dropdown menu is opened. if `INTERVAL` is followed by `-`, the plugin is only run when the dropdown menu is opened. `POSITION` may be omitted entirely (in which case the button is placed before all other buttons on the right-hand side of the panel) while `INTERVAL` can be left empty. For example, a script named `plugin.10s.sh` is updated every 10 seconds, the button belonging to `plugin.1c..sh` is positioned just right of the GNOME Shell clock, and `plugin.l.1m.sh` is displayed left of the "Activities" button and updated every minute. diff --git a/argos@pew.worldwidemann.com/button.js b/argos@pew.worldwidemann.com/button.js index cd7bec2..72f5b19 100644 --- a/argos@pew.worldwidemann.com/button.js +++ b/argos@pew.worldwidemann.com/button.js @@ -30,6 +30,7 @@ var ArgosButton = new Lang.Class({ this._file = file; this._updateInterval = settings.updateInterval; + this._updateOnClose = settings.updateOnClose; this._lineView = new ArgosLineView(); this._lineView.setMarkup("" + GLib.markup_escape_text(file.get_basename(), -1) + " ..."); @@ -94,7 +95,7 @@ var ArgosButton = new Lang.Class({ this._processOutput(standardOutput.split("\n")); - if (this._updateInterval !== null) { + if (this._updateInterval !== null && (this.menu.isOpen || (!this.menu.isOpen && this._updateOnClose))) { this._updateTimeout = Mainloop.timeout_add_seconds(this._updateInterval, Lang.bind(this, function() { this._updateTimeout = null; this._update(); diff --git a/argos@pew.worldwidemann.com/utilities.js b/argos@pew.worldwidemann.com/utilities.js index 5cb795f..ba8310e 100644 --- a/argos@pew.worldwidemann.com/utilities.js +++ b/argos@pew.worldwidemann.com/utilities.js @@ -24,6 +24,7 @@ const BOXES = { function parseFilename(filename) { let settings = { updateOnOpen: false, + updateOnClose: true, updateInterval: null, position: 0, box: "right" @@ -39,6 +40,12 @@ function parseFilename(filename) { updatePart = updatePart.substring(0, updatePart.length - 1); } + if (updatePart !== null && updatePart.endsWith("-")) { + settings.updateOnClose = false; + settings.updateOnOpen = true; + updatePart = updatePart.substring(0, updatePart.length - 1); + } + if (updatePart !== null && updatePart.length >= 2) { // Attempt to parse BitBar refresh time string let number = updatePart.substring(0, updatePart.length - 1);