-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Bug on Ubuntu 19.04 #14
Comments
Thanks. IIUC, Line 229 in 4e44970
|
So how to do that? (PS your thumbnail looks like a swastika!) |
Ok this works: -g_autofree char *filename = g_build_filename (DIRNAME, basename, "online", NULL); |
This works: static
gboolean
is_on_ac_power ()
{
#ifdef __linux__
// Read AC power state from /sys/class/power_supply/AC/online (== 1 on AC).
// Should work in most cases. See: https://bugs.debian.org/473629
const char *DIRNAME = "/sys/class/power_supply/AC";
g_autoptr (GError) err = NULL;
g_autofree char *filename = g_build_filename (DIRNAME, "online", NULL);
g_autofree char *contents = NULL;
g_debug ("Reading '%s'", filename);
if (! g_file_get_contents (filename, &contents, NULL, &err)) {
g_debug ("Cannot read '%s': %s", filename, err->message);
}
if (g_strcmp0 (g_strstrip (contents), "1") == 0)
return TRUE;
#warning "No battery / AC status support for your platform."
#warning "Defaulting to as if 'always on battery' behavior. Patches welcome!"
return FALSE;
#elif defined(__unix__) && defined(BSD) && !defined(__APPLE__)
// On *BSD, run `apm -a` which returns '1' when AC is online
g_autoptr (GError) err = NULL;
g_autofree char *standard_output = NULL;
char *argv[] = {"apm", "-a", NULL};
g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
NULL, NULL, &standard_output, NULL, NULL, &err);
if (err)
g_warning ("Unexpected `apm -a` execution error: %s", err->message);
return standard_output && 0 == g_strcmp0 (g_strstrip (standard_output), "1");
#endif
} |
I'm having a similar error on
|
The status is already reported by `on_check_battery_powered()`. Should be ok for newer kernels and should avoid scaring users. Closes #14
The status is already reported by `on_check_battery_powered()`. Should be ok for newer kernels and should avoid scaring users. Closes #14
On Ubuntu 19.04, I get:
"(xsuspender:15598): GLib-WARNING **: 14:29:02.244: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
The overwriting error message was: Failed to open file ?/sys/class/power_supply/BAT0/online?: No such file or directory"
THere is no
/sys/class/power_supply/BAT0/online
there is however
/sys/class/power_supply/AC/online
The text was updated successfully, but these errors were encountered: