Skip to content

Commit

Permalink
Gracefully handle hamster DBUS disappearing
Browse files Browse the repository at this point in the history
Previously, if this happened the extension would be disabled using the
`disable()` method. However, this caused an error (because disable was
called twice, once for each DBUS service) and gnome-shell would not be
told that the extension was disabled, so the user could not re-enable
it.

With this commit, when the apiProxy disappears, the panel widget is
hidden. When it reappears, the panel widget is shown again.

Note that there are still some rough edges, but this change is mostly
intended to simplify hamster development - you can now restart hamster
after making changes (or to switch between installed and source
versions) and still have the extension work without needing to restart
gnome-shell (which means logging out with wayland).

This commit does not attempt to handle windowsProxy disappearing, since
keeping track of the status of both services can get messy quickly.
Also, now you can restart just the api service, and leave the windows
service to be autostarted when needed if you want (and if autostart
fails, the user will be shown a proper error message).

Also, this does not disable the keybindings, so pressing that while the
DBUS proxy is down will probably still allow opening up the menu (but
that's ok - making any changes will just autostart hamster again, or
show an error message otherwise).
  • Loading branch information
matthijskooijman committed May 1, 2023
1 parent 22ba1e6 commit 0457681
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions extension/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,21 @@ class Controller {

// Callbacks that handle appearing/vanishing dbus services.
function apiProxy_appeared_callback() {
if (this.shouldEnable)
this.panelWidget.show();
}

function apiProxy_vanished_callback() {
/* jshint validthis: true */
global.log(_("hamster-shell-extension: 'hamster-service' not running. Shutting down."));
Main.notify(_("hamster-shell-extension: 'hamster-service' not running. Shutting down."));
this.disable();
this.reportIfError("DBUS proxy disappeared", "Disabling extension until it comes back");
if (this.shouldEnable)
this.panelWidget.hide();
}

function windowsProxy_appeared_callback() {
}

function windowsProxy_vanished_callback() {
/* jshint validthis: true */
global.log(_("hamster-shell-extension: 'hamster-windows-service' not running. Shutting down."));
Main.notify(_("hamster-shell-extension: 'hamster-windows-service' not running. Shutting down."));
this.disable();
}

// Set-up watchers that watch for required dbus services.
Expand Down

0 comments on commit 0457681

Please sign in to comment.