pemmican.gui

class pemmican.gui.NotifierApplication[source]

Base class for a GLib GApplication which needs to talk to the freedestkop notification service. An instance of this class can be called as a “main” function, optionally passing in the command line parameters.

As a GApplication with an identifier (see APP_ID), only one instance is typically permitted to run. Additional instances will exit before activation, but will signal the original instance to activate instead. The XDG directories, particularly those related to configuration (XDG_CONFIG_HOME and XDG_CONFIG_DIRS) are expected in the environment.

The application will terminate early with a non-zero exit code if DISPLAY or WAYLAND_DISPLAY are missing from the environment. Finally, if the freedesktop notification service does not show up within 1 minute of the application starting, the application will also terminate with a non-zero exit code.

This is an abstract class; descendents need to implement the run() method.

APP_ID

The application’s identifier, in the typical form of a reverse domain-name. This should be overridden at the class-level in each descendent.

do_activate(user_data)[source]

Application activation. This starts the GLib main loop; any set up which should be performed before entering the main loop should be done here.

The application’s main logic (in the abstract run() method) is ultimately executed as a one-shot idle handler from the GLib main loop, configured here.

abstract run()[source]

This abstract method should be overridden in descendents to provide the main logic of the application.

class pemmican.gui.ResetApplication[source]

Checks the Raspberry Pi 5’s power status and reports, via the freedesktop notification mechanism, if the last reset occurred due to a brownout (undervolt) situation, or if the current power supply failed to negotiate a 5A supply. This script is intended to be run from a systemd user slice as part of the graphical-session.target.

do_check()[source]

This method is the bulk of the pemmican-reset application. It runs the checks on the device-tree nodes and, if notifications are required, queries the notification service’s capabilities to format the notifications accordingly.

do_notification_action(msg_id, action_key)[source]

Callback executed when the user activates an action on one of our pending notifications. This launches the web-browser for the “More information” action, or touches the appropriate file for the “Don’t show again” action.

do_notification_closed(msg_id, reason)[source]

Callback executed when the user dismisses a notification by any mechanism (explicit close, timeout, action activation, etc). As a oneshot application, which can only ever show one notification, we just quit if it’s closed.

run()[source]

This abstract method should be overridden in descendents to provide the main logic of the application.

class pemmican.gui.MonitorApplication[source]

Monitors the Raspberry Pi 5’s power supply for reports of undervolt (deficient power supply), or overcurrent (excessive draw by USB peripherals). Issues are reported via the freedesktop notification mechanism. This script is intended to be run from a systemd user slice as part of the graphical-session.target.

do_hwmon_device(observer, device)[source]

Callback registered for hardware monitoring events. This performs further filtering to determine if this is actually an undervolt event, and dispatches a notification if it is.

do_notification_action(msg_id, action_key)[source]

Callback executed when the user activates an action on one of our pending notifications. This launches the web-browser for the “More information” action, or touches the appropriate file for the “Don’t show again” action.

do_notification_closed(msg_id, reason)[source]

Callback executed when the user dismisses a notification by any mechanism (explicit close, timeout, action activation, etc).

do_usb_device(observer, device)[source]

Callback registered for USB device events. This method performs further filtering to determine if this is actually an overcurrent event, and dispatches a notification if it is.

notify(key, msg, *, replaces_id=0)[source]

This method is called by the monitoring callbacks (do_usb_device() and do_hwmon_device()) to format and dispatch a notification according to the capabilities of the system’s notification mechanism.

run()[source]

This abstract method should be overridden in descendents to provide the main logic of the application.