surface3-scripts/autorotate/changeautorotatestatus.py

35 lines
1.1 KiB
Python
Raw Normal View History

2015-01-01 11:29:25 +00:00
#!/usr/bin/env python2
2015-01-01 11:15:35 +00:00
import os
from gi.repository import Notify
2015-01-01 13:24:55 +00:00
path = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
2015-01-01 11:15:35 +00:00
def readFile(path): #self.filename
myDatei = open(path, "r")
myList = []
#Liste aus Datei erstellen
for Line in myDatei:
Line = Line.rstrip()
#Line = Line.decode('utf8')
myList.append(Line)
myDatei.close()
return(myList)
def writeFile(path, myList): #self.filename
myDatei = open(path, "w")
#Liste aus Datei erstelle
myDatei.writelines(myList)
myDatei.close()
2015-01-01 13:24:55 +00:00
status = readFile(os.path.join(path, 'status.txt'))
2015-01-01 11:15:35 +00:00
if status[0] == "on":
2015-01-01 13:24:55 +00:00
writeFile(os.path.join(path, 'status.txt'), ["off"])
2015-01-01 11:15:35 +00:00
Notify.init ("Rotation-ON")
RotationOFF=Notify.Notification.new ("Rotation","Screenrotation is now turned OFF","dialog-information")
RotationOFF.show ()
if status[0] == "off":
2015-01-01 13:24:55 +00:00
writeFile(os.path.join(path, 'status.txt'), ["on"])
2015-01-01 11:15:35 +00:00
Notify.init ("Rotation-OFF")
RotationON=Notify.Notification.new ("Rotation","Screenrotation is now turned ON","dialog-information")
RotationON.show ()