Improve GNOME power profiles detection for non systemd inits

This commit is contained in:
Adnan Hodzic 2021-12-07 08:28:58 +01:00
parent 4c5681b2d8
commit ef8b61c6c8
1 changed files with 58 additions and 51 deletions

View File

@ -21,6 +21,7 @@ def helper_opts():
# detect if gnome power profile service is running
if os.getenv('PKG_MARKER') != "SNAP":
if which("systemctl") is not None:
try:
gnome_power_stats = call(["systemctl", "is-active", "--quiet", "power-profiles-daemon"])
except:
@ -30,6 +31,7 @@ if os.getenv('PKG_MARKER') != "SNAP":
# alert in case gnome power profile service is running
def gnome_power_detect():
if which("systemctl") is not None:
if gnome_power_stats == 0:
print("\n----------------------------------- Warning -----------------------------------\n")
print("Detected running GNOME Power Profiles daemon service!")
@ -42,6 +44,7 @@ def gnome_power_detect():
# automatically disable gnome power profile service in case it's running during install
def gnome_power_detect_install():
if which("systemctl") is not None:
if gnome_power_stats == 0:
print("\n----------------------------------- Warning -----------------------------------\n")
print("Detected running GNOME Power Profiles daemon service!")
@ -68,6 +71,7 @@ def gnome_power_disable_live():
# disable gnome >= 40 power profiles (install)
def gnome_power_svc_disable():
if which("systemctl") is not None:
try:
print("\n* Disabling GNOME power profiles")
call(["systemctl", "stop", "power-profiles-daemon"])
@ -82,6 +86,7 @@ def gnome_power_svc_disable():
# enable gnome >= 40 power profiles (uninstall)
def gnome_power_svc_enable():
if which("systemctl") is not None:
try:
print("\n* Enabling GNOME power profiles")
call(["systemctl", "unmask", "power-profiles-daemon"])
@ -96,6 +101,7 @@ def gnome_power_svc_enable():
# gnome power profiles current status
def gnome_power_svc_status():
if which("systemctl") is not None:
try:
print("* GNOME power profiles status")
call(["systemctl", "status", "power-profiles-daemon"])
@ -161,6 +167,7 @@ def bluetooth_on_notif_snap():
# gnome power removal reminder
def gnome_power_rm_reminder():
if which("systemctl") is not None:
if gnome_power_stats != 0:
print("\n----------------------------------- Warning -----------------------------------\n")
print("Detected GNOME Power Profiles daemon service is stopped!")