Skip to content

Commit

Permalink
Merge pull request #346 from malverick/brightness
Browse files Browse the repository at this point in the history
Linux Brightness API
  • Loading branch information
akshayaurora committed Aug 29, 2017
2 parents f765104 + 28eef42 commit 27a30d4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Flash X X
Wifi X X X
Temperature X
Spatial Orientation X
Brightness X
Brightness X X X
================================== ======= === ======= ==== =====

Support
Expand Down
2 changes: 1 addition & 1 deletion examples/brightness/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
min: 0
max: 100
value: root.get_current_brightness()
on_touch_up: root.set_brightness(slider.value)
on_value: root.set_brightness(slider.value)
Label:
text: 'Current brightness = ' + str(slider.value)
''')
Expand Down
29 changes: 29 additions & 0 deletions plyer/platforms/linux/brightness.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'''
Linux Brightness
----------------
'''

from plyer.facades import Brightness
import subprocess
import os


class LinuxBrightness(Brightness):

def __init__(self):
if os.system("which xbacklight"):
raise Exception(
"It seems that 'xbacklight' is not installed. \
Install it using 'sudo apt-get install xbacklight'.")

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

0 comments on commit 27a30d4

Please sign in to comment.