-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port 'Power Profile Monitor' demo to Vala (#164)
- Loading branch information
1 parent
3524480
commit 58d04eb
Showing
1 changed file
with
19 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /usr/bin/env -S vala workbench.vala --pkg libadwaita-1 | ||
|
||
public void main () { | ||
var overlay = (Adw.ToastOverlay) workbench.builder.get_object ("overlay"); | ||
var power_profile_monitor = PowerProfileMonitor.dup_default (); | ||
|
||
power_profile_monitor.notify["power-saver-enabled"].connect (() => { | ||
var toast = new Adw.Toast ("power-saver") { | ||
priority = Adw.ToastPriority.HIGH | ||
}; | ||
|
||
if (power_profile_monitor.power_saver_enabled) { | ||
toast.title = "Power Saver Enabled"; | ||
} else { | ||
toast.title = "Power Saver Disabled"; | ||
} | ||
overlay.add_toast (toast); | ||
}); | ||
} |