We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 202ae4b + ac62754 commit 3a321d9Copy full SHA for 3a321d9
1 file changed
src/modules/battery.cpp
@@ -126,7 +126,14 @@ void waybar::modules::Battery::refreshBatteries() {
126
// Ignore non-system power supplies unless explicitly requested
127
if (!bat_defined && fs::exists(node.path() / "scope")) {
128
std::string scope;
129
- std::ifstream(node.path() / "scope") >> scope;
+ try {
130
+ // for hotplug-in device, access it is always unstable because you may remove the
131
+ // device anytime so just allow failure happen and do nothing
132
+ std::ifstream(node.path() / "scope") >> scope;
133
+ } catch (const std::ifstream::failure& e) {
134
+ scope.clear();
135
+ continue;
136
+ }
137
if (g_ascii_strcasecmp(scope.data(), "device") == 0) {
138
continue;
139
}
0 commit comments