Skip to content

Commit

Permalink
check S3 state warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed May 25, 2024
1 parent e8408a3 commit 6380fc9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 10 deletions.
43 changes: 40 additions & 3 deletions data/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,43 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="ui_box_warning_deep">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">8</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">dialog-warning-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Your device does not support S3 state sleep.</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="ui_box_warning_virtual">
<property name="visible">True</property>
Expand Down Expand Up @@ -594,7 +631,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -631,7 +668,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -668,7 +705,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
</object>
Expand Down
18 changes: 11 additions & 7 deletions src/client/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,17 @@ def update(self,data):
acpi = not (str(data["info"]["acpi-supported"]).lower() == "true")
oem = (str(data["info"]["oem"]).lower() == "true")
vm = is_virtual_machine()
pm = not is_laptop()
self.o("ui_box_warning_virtual").set_visible(vm)
self.o("ui_box_warning_laptop").set_visible(pm)
self.o("ui_button_warning").set_visible(oem or acpi or vm or pm)
self.o("ui_box_warning_acpi").set_visible(acpi)
self.o("ui_box_warning_oem").set_visible(oem)
self.o("ui_box_warning_bad").set_visible(not pm)
laptop = is_laptop()
deep = is_support_deep()
issue = oem or acpi or vm or not laptop or not deep
self.o("ui_button_warning").set_visible(issue)
if issue:
self.o("ui_box_warning_virtual").set_visible(vm)
self.o("ui_box_warning_laptop").set_visible(not laptop)
self.o("ui_box_warning_acpi").set_visible(acpi)
self.o("ui_box_warning_oem").set_visible(oem)
self.o("ui_box_warning_bad").set_visible(oem or acpi)
self.o("ui_box_warning_deep").set_visible(deep)
for d in data["battery"].keys():
health = data["battery"][d]["health"]
if int(health) < 31:
Expand Down
3 changes: 3 additions & 0 deletions src/common/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def is_laptop():
return False


def is_support_deep():
return "deep" in readfile("/sys/power/mem_sleep")

def which(command):
for dir in os.environ["PATH"].split(":"):
if os.path.isfile("{}/{}".format(dir,command)):
Expand Down
1 change: 1 addition & 0 deletions src/service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def main(data):
udata["info"]["type"] = get_device_type()
udata["info"]["live"] = is_live()
udata["info"]["oem"] = is_oem_available()
udata["info"]["deep"] = is_support_deep()
if "show" in data:
udata["show"] = data["show"]
udata["backlight"] = {}
Expand Down

0 comments on commit 6380fc9

Please sign in to comment.