Skip to content

[Desklet] New: Simple Battery (simple-battery@suckatcoding.com)#1853

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

[Desklet] New: Simple Battery (simple-battery@suckatcoding.com)#1853
Milchreis wants to merge 6 commits into
linuxmint:masterfrom
Milchreis:master

Conversation

@Milchreis

Copy link
Copy Markdown

Hello Cinnamon Team,

I would like to submit a new desklet called Simple Battery.

It is a minimalist and highly customizable desklet that provides essential power metrics at a glance without cluttering the desktop.

Key Features:

  • Displays a sleek horizontal battery progress bar.
  • Shows exact percentage and time remaining / time until fully charged (using upower).
  • Calculates battery usage (or charged percentage) since the start of the session.
  • Displays system uptime (reading from /proc/uptime).
  • Includes a settings menu to toggle the background and adjust its opacity.
  • Full gettext support for i18n (base language is English, German .po included in the po/ directory).

I have made sure to include all required files (icon.png, screenshot.png, README.md, CHANGELOG.md, etc.) and structured the translations according to the Spices guidelines.

Thank you for your time and for reviewing my submission! Let me know if anything needs to be adjusted.

@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. 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 7 potential issue(s):

⚠️ WARNING

⚠️ sync_spawn_command_line

simple-battery@suckatcoding.com/files/desklet.js:74

let [resBat, outBat] = GLib.spawn_command_line_sync(cmdBat);

Synchronous process spawning blocks the main loop.
Use GLib.spawn_command_line_async() or Gio.Subprocess instead.

simple-battery@suckatcoding.com/files/desklet.js:101

let [resUsage, outUsage] = GLib.spawn_command_line_sync(cmdUsage);

Synchronous process spawning blocks the main loop.
Use GLib.spawn_command_line_async() or Gio.Subprocess instead.

simple-battery@suckatcoding.com/files/desklet.js:117

let [resUptime, outUptime] = GLib.spawn_command_line_sync("cat /proc/uptime");

Synchronous process spawning blocks the main loop.
Use GLib.spawn_command_line_async() or Gio.Subprocess instead.

⚠️ hardcoded_data_dir

simple-battery@suckatcoding.com/files/desklet.js:10

const DESKLET_DIR = GLib.get_home_dir() + "/.local/share/cinnamon/desklets/" + UUID;

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

ℹ️ INFO

ℹ️ shell_string_spawn

simple-battery@suckatcoding.com/files/desklet.js:74

let [resBat, outBat] = GLib.spawn_command_line_sync(cmdBat);

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.

simple-battery@suckatcoding.com/files/desklet.js:101

let [resUsage, outUsage] = GLib.spawn_command_line_sync(cmdUsage);

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.

simple-battery@suckatcoding.com/files/desklet.js:117

let [resUptime, outUptime] = GLib.spawn_command_line_sync("cat /proc/uptime");

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.

@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. 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_get_contents

simple-battery@suckatcoding.com/files/desklet.js:128

let [res, contents] = GLib.file_get_contents(tmpPath);

Synchronous file_get_contents() blocks the main loop.
Use Gio.File.load_contents_async() instead.

simple-battery@suckatcoding.com/files/desklet.js:148

let [resUptime, contentsUptime] = GLib.file_get_contents("/proc/uptime");

Synchronous file_get_contents() blocks the main loop.
Use Gio.File.load_contents_async() instead.

⚠️ sync_file_test

simple-battery@suckatcoding.com/files/desklet.js:127

if (GLib.file_test(tmpPath, GLib.FileTest.EXISTS)) {

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


Automated pattern check.

@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. 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 7 potential issue(s):

⚠️ WARNING

⚠️ sync_spawn_command_line

simple-battery@suckatcoding.com/files/simple-battery@suckatcoding.com/desklet.js:73

let [resBat, outBat] = GLib.spawn_command_line_sync(cmdBat);

Synchronous process spawning blocks the main loop.
Use GLib.spawn_command_line_async() or Gio.Subprocess instead.

simple-battery@suckatcoding.com/files/simple-battery@suckatcoding.com/desklet.js:100

let [resUsage, outUsage] = GLib.spawn_command_line_sync(cmdUsage);

Synchronous process spawning blocks the main loop.
Use GLib.spawn_command_line_async() or Gio.Subprocess instead.

simple-battery@suckatcoding.com/files/simple-battery@suckatcoding.com/desklet.js:116

let [resUptime, outUptime] = GLib.spawn_command_line_sync("cat /proc/uptime");

Synchronous process spawning blocks the main loop.
Use GLib.spawn_command_line_async() or Gio.Subprocess instead.

⚠️ hardcoded_data_dir

simple-battery@suckatcoding.com/files/simple-battery@suckatcoding.com/desklet.js:9

const DESKLET_DIR = GLib.get_home_dir() + "/.local/share/cinnamon/desklets/" + UUID;

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

ℹ️ INFO

ℹ️ shell_string_spawn

simple-battery@suckatcoding.com/files/simple-battery@suckatcoding.com/desklet.js:73

let [resBat, outBat] = GLib.spawn_command_line_sync(cmdBat);

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.

simple-battery@suckatcoding.com/files/simple-battery@suckatcoding.com/desklet.js:100

let [resUsage, outUsage] = GLib.spawn_command_line_sync(cmdUsage);

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.

simple-battery@suckatcoding.com/files/simple-battery@suckatcoding.com/desklet.js:116

let [resUptime, outUptime] = GLib.spawn_command_line_sync("cat /proc/uptime");

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.

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.

1 participant