File: orientation.py

package info (click to toggle)
python-plyer 2.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,808 kB
  • sloc: python: 13,395; sh: 217; makefile: 177
file content (27 lines) | stat: -rw-r--r-- 870 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import subprocess as sb
from plyer.facades import Orientation


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()