Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new enhanced features #113

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion [email protected]/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("<small><i>" + GLib.markup_escape_text(file.get_basename(), -1) + " ...</i></small>");
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions [email protected]/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const BOXES = {
function parseFilename(filename) {
let settings = {
updateOnOpen: false,
updateOnClose: true,
updateInterval: null,
position: 0,
box: "right"
Expand All @@ -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);
Expand Down