openCom-Companion/sbapp/plyer/platforms/linux/orientation.py

28 lines
876 B
Python
Raw Normal View History

2022-09-16 18:07:57 +02:00
import subprocess as sb
2024-06-02 18:31:58 +02:00
from sbapp.plyer.facades import Orientation
2022-09-16 18:07:57 +02:00
class LinuxOrientation(Orientation):
def _set_landscape(self, **kwargs):
self.rotate = 'normal'
self.screen = sb.check_output(
"xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1",
shell=True
)
self.screen = self.screen.decode('utf-8').split('\n')[0]
sb.call(["xrandr", "--output", self.screen, "--rotate", self.rotate])
def _set_portrait(self, **kwargs):
self.rotate = 'left'
self.screen = sb.check_output(
"xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1",
shell=True
)
self.screen = self.screen.decode('utf-8').split('\n')[0]
sb.call(["xrandr", "--output", self.screen, "--rotate", self.rotate])
def instance():
return LinuxOrientation()