Comments (5)
Thanks. IIUC, err
should be reset to NULL
in each while
loop iteration before this line:
Line 229 in 4e44970
from xsuspender.
So how to do that?
(PS your thumbnail looks like a swastika!)
from xsuspender.
Ok this works:
-const char *DIRNAME = "/sys/class/power_supply";
+const char *DIRNAME = "/sys/class/power_supply/AC";
-g_autofree char *filename = g_build_filename (DIRNAME, basename, "online", NULL);
+g_autofree char *filename = g_build_filename (DIRNAME, "online", NULL);
from xsuspender.
This works:
(only check sys/class/power_supply/AC/online)
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
}
from xsuspender.
I'm having a similar error on 19.10
. When running xsuspender in debug mode, I'm seeing this log over and over:
Reading '/sys/class/power_supply/AC/online'
Reading '/sys/class/power_supply/BAT0/online'
Cannot read '/sys/class/power_supply/BAT0/online': Failed to open file ?/sys/class/power_supply/BAT0/online?: No such file or directory
from xsuspender.
Related Issues (20)
- ERROR: xsuspender.c:138:xsus_window_suspend: assertion failed: (! xsus_entry_find_for_window_rule (window, rule, suspended_entries)) HOT 4
- GLib-CRITICAL **: g_main_loop_quit: assertion 'g_atomic_int_get (&loop->ref_count) > 0' failed
- Will xsuspender work with xwayland layers? HOT 1
- Create AUR Pkg HOT 6
- Link fails with gcc 10 HOT 2
- Ubuntu official repository HOT 4
- Setting max CPU consumption HOT 3
- libwnck not found in OpenSuSE Leap 15.2 HOT 2
- Mouse battery messing it up? HOT 1
- Better config examples HOT 1
- Add default configuration for more apps
- bug in the docs
- AUR package does not update automatically HOT 2
- Update dependecies for libwnck
- debian release signature invalid HOT 4
- xsuspender confused by additional entry in `/sys/class/power_supply` HOT 2
- apt update: E: The repository 'http://download.opensuse.org/repositories/home:/kernc:/xsuspender/xUbuntu_22.04 Release' no longer has a Release file. HOT 2
- downclock_on_battery=0 🤔 HOT 1
- uninstalling borked my apt and nala on Kubuntu 22.04 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xsuspender.