View Single Post
Old 01-23-2020, 12:36 PM   #2
handyguy
Connoisseur
handyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to behold
 
handyguy's Avatar
 
Posts: 72
Karma: 11789
Join Date: Dec 2019
Device: PW4
code snippet

Code:
# test.py
import datetime
import os
import subprocess
import sys
import time
from time import sleep
def display_digit4(x):
    os.system('echo 0 | fbink -i {}.png -g x=762 -q'.format(x))
try:
    subprocess.Popen(['lipc-set-prop', 'com.lab126.cmd', 'wirelessEnable', '0'], stdout=subprocess.PIPE)
    sp = subprocess.Popen(['gasgauge-info', '-s'], stdout=subprocess.PIPE)
    bat, _ = sp.communicate()
    bat = int(bat)
    font = '/mnt/us/clock/bahnschrift.ttf'
    command = 'fbink -t regular={},px=35,top=1410,format "BATTERY= {}"  -mec'.format(font,bat)
    os.system(command)
    subprocess.Popen(['lipc-set-prop', 'com.lab126.powerd', 'preventScreenSaver', '1'], stdout=subprocess.PIPE)
    while True:
        now = datetime.datetime.now()
        digit4 = now.minute % 10
#       display_digit4(digit4)
        sleep(1)
        command = "rtcwake -d /dev/rtc1 -m mem -s 59"
        subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)

except KeyboardInterrupt:
	print ("kb interrupt")
finally:
    subprocess.Popen(['lipc-set-prop', 'com.lab126.cmd', 'wirelessEnable', '1'], stdout=subprocess.PIPE)

Last edited by handyguy; 01-23-2020 at 12:43 PM.
handyguy is offline   Reply With Quote