File: brightness.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 (29 lines) | stat: -rwxr-xr-x 663 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
28
29
'''
Linux Brightness
----------------

'''

from plyer.facades import Brightness
import subprocess
import os


class LinuxBrightness(Brightness):

    def __init__(self):
        if os.system("which xbacklight"):
            msg = ("It looks like 'xbacklight' is not installed. Try "
                   "installing it with your distribution's package manager.")
            raise Exception(msg)

    def _current_level(self):
        cr_level = subprocess.check_output(["xbacklight", "-get"])
        return str(cr_level)

    def _set_level(self, level):
        subprocess.call(["xbacklight", "-set", str(level)])


def instance():
    return LinuxBrightness()