~speguero/systemd-autohibernated

802d56dedfb3cd175ac00869cc63bea9c7372da3 — Steven Peguero 10 months ago e5a8184
Change header comment in program
1 files changed, 26 insertions(+), 18 deletions(-)

M systemd-autohibernated
M systemd-autohibernated => systemd-autohibernated +26 -18
@@ 4,12 4,14 @@
SYSTEMD-AUTOHIBERNATED
----------------------

Hibernates a machine when AC power is nonexistent and available battery
power is scarcely low.

Surprisingly, systemd does not provide a crucial feature to perform what
this custom script accomplishes, like `apmd -Z 5` in OpenBSD.

This software enables automatic hibernating for systemd-based Linux     
systems when the following conditions are met:                          
                                                                        
1. An AC power source is not available.                                 
2. Battery life availability is discharged to 5%.

Unfortunately, systemd does not provide such a feature natively, unlike
OpenBSD's `apmd -Z 5`.
'''

def main(batt_percent_to_hibernate):


@@ 69,7 71,9 @@ def main(batt_percent_to_hibernate):

def get_ac_stat():

	# Determines whether or not A/C power is connected.
	'''
	Determines whether or not A/C power is connected.
	'''

	import platform



@@ 102,16 106,18 @@ def get_ac_stat():

def get_batt_percent():

	# Determines percentage of battery life or total
	# sum of life between all present batteries.
	# 
	# NOTICE: In the event when a supported platform
	#         is detected and `batt_percent` does not
	#         feature an expected integer, a value of
	#         -1 will be provided in place of the `False`
	#         booloan, as 0 and `False` are identical
	#         in Python. With a battery life percentage
	#         of 0%, misreporting will otherwise occur.
	'''
	Determines percentage of battery life or total
	sum of life between all present batteries.
	
	NOTICE: In the event when a supported platform
	        is detected and `batt_percent` does not
	        feature an expected integer, a value of
	        -1 will be provided in place of the `False`
	        booloan, as 0 and `False` are identical
	        in Python. With a battery life percentage
	        of 0%, misreporting will otherwise occur.
	'''

	import platform
	import glob


@@ 153,7 159,9 @@ def get_batt_percent():

def get_batt_stat():

	# Determines whether one or more batteries are present.
	'''
	Determines whether one or more batteries are present.
	'''

	import glob
	import platform