Skip to content

battery-guardian@beatlink: init to 1.0 - #1044

Open
BeatLink wants to merge 6 commits into
linuxmint:masterfrom
BeatLink:master
Open

battery-guardian@beatlink: init to 1.0#1044
BeatLink wants to merge 6 commits into
linuxmint:masterfrom
BeatLink:master

Conversation

@BeatLink

Copy link
Copy Markdown
Contributor

Battery Guardian is a robust power-management applet for the Cinnamon Desktop Environment. It acts as a final safety net for your work, ensuring you never lose data due to an unexpected battery death.

Unlike standard system notifications that are easily missed, Battery Guardian provides a clear, persistent countdown when your battery reaches a critical level, giving you ample time to save your progress or plug in your charger.

Inspired by https://github.com/orgs/linuxmint/discussions/1432#discussioncomment-16022522

@github-actions

Copy link
Copy Markdown

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 3 potential issue(s):

⚠️ sync_file_query_exists

battery-guardian@beatlink/files/battery-guardian@beatlink/extension.js:36

let exists = isFile ? Gio.File.new_for_path(path).query_exists(null) : false

query_exists() is a synchronous call that can block on slow/network filesystems.
Prefer attempting the operation and handling a Gio.IOErrorEnum.NOT_FOUND error instead.

battery-guardian@beatlink/files/battery-guardian@beatlink/extension.js:202

if (Gio.File.new_for_path(actualPath).query_exists(null)) {

query_exists() is a synchronous call that can block on slow/network filesystems.
Prefer attempting the operation and handling a Gio.IOErrorEnum.NOT_FOUND error instead.

ℹ️ shell_string_spawn

battery-guardian@beatlink/files/battery-guardian@beatlink/extension.js:263

if (!this._testMode) Util.spawnCommandLine(SystemCommands[this._action])

Prefer argument vector spawn functions over shell command strings.
This is especially important when arguments include untrusted input (user data,
filenames, settings values, etc.) as shell strings are vulnerable to injection.
Static command strings are generally fine, but argv is always safer.
Use Util.spawn(["cmd", "arg1", "arg2"]) or Util.trySpawn() instead.


Automated pattern check.

@mtwebster

Copy link
Copy Markdown
Member

Cinnamon already provides low-battery warning, critical warning and shutdown for low battery. Why is this needed?

@BeatLink

Copy link
Copy Markdown
Contributor Author
  1. Its uncancelled, and works over full screen applications.
  2. It provides audio cues
  3. It gives an exact time to failure

The existing setup gives notifications primarily based on battery levels. Even if the user sets up their applet to show the time remaining, its an estimated time rather than definitively. Once the battery reaches the critical level, the system will immediately execute the configured shutdown option with the user having no idea when.

This extension gives an exact time to failure, letting the user know exactly how much time the computer has before shutting down, allowing them to save work and do what they need to do, either by grabbing a charger or saving their work.

In a discussion, i suggested that this feature be baked into the core cinnamon codebase but that was rejected. This is the alternative.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Most findings
are advisory and do not automatically disqualify a pull request.

This check is not perfect and will not replace a normal review.


Found 3 potential issue(s):

⚠️ WARNING

⚠️ sync_file_query_exists

battery-guardian@beatlink/files/battery-guardian@beatlink/extension.js:63

if (isFile && !Gio.File.new_for_path(path).query_exists(null)) {

query_exists() is a synchronous call that can block on slow/network filesystems.
Prefer attempting the operation and handling a Gio.IOErrorEnum.NOT_FOUND error instead.

battery-guardian@beatlink/files/battery-guardian@beatlink/extension.js:241

if (Gio.File.new_for_path(actualPath).query_exists(null)) {

query_exists() is a synchronous call that can block on slow/network filesystems.
Prefer attempting the operation and handling a Gio.IOErrorEnum.NOT_FOUND error instead.

⚠️ hardcoded_data_dir

battery-guardian@beatlink/files/battery-guardian@beatlink/extension.js:16

Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale")

Avoid hardcoding .local/share in paths. Use GLib.get_user_data_dir() instead,
which respects the XDG_DATA_HOME environment variable.


Automated pattern check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants