add rudimentary tools to add/remove the current session to ignorefile

This commit is contained in:
chrys 2018-03-13 23:43:22 +01:00
parent 9b8b985052
commit 551c699a9f
2 changed files with 52 additions and 0 deletions

26
tools/addScreenToIgnoreList.py Executable file
View File

@ -0,0 +1,26 @@
#!/bin/python
import os
def addScreenToIgnoreList(ignoreFileName = '/tmp/fenrirSuspend', screen = '1', useCurrentScreen = True):
if useCurrentScreen:
tty = open('/sys/devices/virtual/tty/tty0/active','r')
screen = str(tty.read()[3:-1])
ignoreScreens = []
ignoreScreensStr = ''
if ignoreFileName != '':
if os.access(ignoreFileName, os.R_OK):
with open(ignoreFileName, 'r') as fp:
try:
ignoreScreens = fp.read().split(',')#.replace('\n','').split(',')
except Exception as e:
print(e)
if not screen in ignoreScreens:
ignoreScreens.extend(screen)
ignoreScreensStr = ','.join(ignoreScreens)
with open(ignoreFileName, 'w') as fp:
fp.write(ignoreScreensStr)
if __name__ == "__main__":
addScreenToIgnoreList()

View File

@ -0,0 +1,26 @@
#!/bin/python
import os
def addScreenToIgnoreList(ignoreFileName = '/tmp/fenrirSuspend', screen = '1', useCurrentScreen = True):
if useCurrentScreen:
tty = open('/sys/devices/virtual/tty/tty0/active','r')
screen = str(tty.read()[3:-1])
ignoreScreens = []
ignoreScreensStr = ''
if ignoreFileName != '':
if os.access(ignoreFileName, os.R_OK):
with open(ignoreFileName, 'r') as fp:
try:
ignoreScreens = fp.read().split(',')#.replace('\n','').split(',')
except Exception as e:
print(e)
if screen in ignoreScreens:
ignoreScreens.remove(screen)
ignoreScreensStr = ','.join(ignoreScreens)
with open(ignoreFileName, 'w') as fp:
fp.write(ignoreScreensStr)
if __name__ == "__main__":
addScreenToIgnoreList()