Commit 36e0772b authored by onny's avatar onny
Browse files

add code

import subprocess
import re
class Screen:
def __init__(self, name, state=None): = name
self._state = state
def state(self):
return self._state
def state(self, value):
if self._state != None and value:['wlr-randr', '--output',, '--on'])
else:['wlr-randr', '--output',, '--off'])
self._state = value
class wlScreens:
def __init__(self):
self.screens = []
result =['wlr-randr'], stdout=subprocess.PIPE)
result = result.stdout.decode('utf-8')
re_search_pat = r'([A-Z]+-\d) '
match = re.findall(re_search_pat, result)
for screenName in match:
screen = Screen(screenName)
re_search_pat = r'Enabled: ([a-z]+)'
match = re.findall(re_search_pat, result)
for num, state in enumerate(match):
screen = self.screens[num]
if (state == "yes"):
screen.state = True
screen.state = False
def toggleModes(self):
if (len(self.screens) == 2):
if (self.screens[0].state == True and self.screens[1].state == True):
self.screens[0].state = False
elif (self.screens[0].state == False and self.screens[1].state == True):
self.screens[1].state = False
self.screens[0].state = True
elif (self.screens[0].state == True and self.screens[1].state == False):
self.screens[1].state = True
if (len(self.screens) == 1):
if (self.screens[0].state == True):
self.screens[0].state = False
self.screens[0].state = True
def __len__(self):
return len(self.screens)
def __str__(self):
return str(self.screens)
def __getitem__(self, key):
return self.screens[key]
screens = wlScreens()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment