Debian Codegraph @

plyer/platforms/linux/orientation.py

raw symbols SCIP
1 import subprocess as sb
2 from plyer.facades import Orientation
3
4
5 class LinuxOrientation(Orientation):
6
7 def _set_landscape(self, **kwargs):
8 self.rotate = 'normal'
9 self.screen = sb.check_output(
10 "xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1",
11 shell=True
12 )
13 self.screen = self.screen.decode('utf-8').split('\n')[0]
14 sb.call(["xrandr", "--output", self.screen, "--rotate", self.rotate])
15
16 def _set_portrait(self, **kwargs):
17 self.rotate = 'left'
18 self.screen = sb.check_output(
19 "xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1",
20 shell=True
21 )
22 self.screen = self.screen.decode('utf-8').split('\n')[0]
23 sb.call(["xrandr", "--output", self.screen, "--rotate", self.rotate])
24
25
26 def instance():
27 return LinuxOrientation()