-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e749246
commit 70245c5
Showing
7 changed files
with
136 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,17 +19,11 @@ | |
* Authored by: torikulhabib <[email protected]> | ||
*/ | ||
|
||
[DBus (name = "org.gnome.SettingsDaemon.Power.Screen")] | ||
private interface BrightnessSettings : GLib.Object { | ||
public abstract int brightness {owned get; set; } | ||
} | ||
namespace Niki { | ||
public class CameraFlash : Gtk.Window { | ||
private uint fade_timeout = 0; | ||
private uint flash_timeout = 0; | ||
private int start_brighnest; | ||
public signal bool capture_now (); | ||
private BrightnessSettings? brightness_settings; | ||
|
||
construct { | ||
var headerbar = new Gtk.HeaderBar (); | ||
|
@@ -39,22 +33,13 @@ namespace Niki { | |
headerbar.get_style_context ().add_class ("default-decoration"); | ||
set_titlebar (headerbar); | ||
headerbar.hide (); | ||
try { | ||
brightness_settings = Bus.get_proxy_sync (BusType.SESSION, "org.gnome.SettingsDaemon.Power", | ||
"/org/gnome/SettingsDaemon/Power", DBusProxyFlags.GET_INVALIDATED_PROPERTIES); | ||
} catch (IOError e) { | ||
warning (e.message); | ||
} | ||
} | ||
|
||
private bool flash_opacity_fade () { | ||
opacity *= 0.5; | ||
if (opacity <= 0.1) { | ||
set_keep_above (false); | ||
destroy (); | ||
if (lid_detect ()) { | ||
brightness_settings.brightness = start_brighnest; | ||
} | ||
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = NikiApp.settings.get_boolean ("dark-style"); | ||
fade_timeout = 0; | ||
return Source.REMOVE; | ||
|
@@ -97,31 +82,7 @@ namespace Niki { | |
get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); | ||
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = false; | ||
show_all (); | ||
if (lid_detect ()) { | ||
start_brighnest = brightness_settings.brightness; | ||
} | ||
Idle.add (bright_now); | ||
flash_timeout = Timeout.add (400, flash_start_fade); | ||
} | ||
private static bool lid_detect () { | ||
var interface_path = File.new_for_path ("/proc/acpi/button/lid/"); | ||
try { | ||
var enumerator = interface_path.enumerate_children ( GLib.FileAttribute.STANDARD_NAME, FileQueryInfoFlags.NONE); | ||
FileInfo lid; | ||
if ((lid = enumerator.next_file ()) != null) { | ||
return true; | ||
} | ||
enumerator.close (); | ||
} catch (GLib.Error err) { | ||
critical ("%s", err.message); | ||
} | ||
return false; | ||
} | ||
private bool bright_now () { | ||
if (lid_detect ()) { | ||
brightness_settings.brightness = 80; | ||
} | ||
return Source.REMOVE; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.