Skip to content
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

Mainview: simpler backlight detection #251

Merged
merged 10 commits into from
May 14, 2024
24 changes: 1 addition & 23 deletions src/MainView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class Power.MainView : Switchboard.SettingsPage {
box.append (battery_box);
}

if (backlight_detect ()) {
if (screen.brightness != -1) {
var als_switch = new Gtk.Switch () {
halign = END
};
Expand Down Expand Up @@ -348,28 +348,6 @@ public class Power.MainView : Switchboard.SettingsPage {
});
}

private static bool backlight_detect () {
var interface_path = File.new_for_path ("/sys/class/backlight/");

try {
var enumerator = interface_path.enumerate_children (
GLib.FileAttribute.STANDARD_NAME,
FileQueryInfoFlags.NONE);
FileInfo backlight;
if ((backlight = enumerator.next_file ()) != null) {
debug ("Detected backlight interface");
return true;
}

enumerator.close ();

} catch (GLib.Error err) {
critical (err.message);
}

return false;
}

private void on_scale_value_changed () {
var val = (int) scale.get_value ();
((DBusProxy)screen).g_properties_changed.disconnect (on_screen_properties_changed);
Expand Down