Skip to content

Commit

Permalink
Mainview: simpler backlight detection (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed May 14, 2024
1 parent 30c5767 commit 036eeac
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions src/MainView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class Power.MainView : Switchboard.SettingsPage {

box.append (devices_box);

if (backlight_detect ()) {
if (screen.brightness != -1) {
var als_switch = new Gtk.Switch () {
halign = END
};
Expand Down Expand Up @@ -354,28 +354,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

0 comments on commit 036eeac

Please sign in to comment.