Created
April 12, 2012 13:33
-
-
Save AyumuKasuga/2367241 to your computer and use it in GitHub Desktop.
backlight up/down on samsung R428
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
class backlight(): | |
def __init__(self, cmd): | |
self.path = "echo '%s' > /sys/class/backlight/samsung/brightness" | |
self.limit_down, self.limit_up = 1, 7 | |
self.current = int(os.popen("cat /sys/class/backlight/samsung/brightness").read().strip()) | |
self.cmd = cmd.strip() | |
self.setbacklight() | |
def setbacklight(self): | |
if self.cmd == 'up': | |
new_value = self.current + 1 | |
if new_value <= self.limit_up: | |
os.popen(self.path % new_value).read() | |
print 'up to level: ' + str(new_value) | |
self.current = new_value | |
elif self.cmd == 'down': | |
new_value = self.current - 1 | |
if new_value >= self.limit_down: | |
os.popen(self.path % new_value) | |
print 'down to level: ' + str(new_value) | |
self.current = new_value | |
try: | |
cmd = sys.argv[1] | |
backlight(cmd) | |
except IndexError: | |
print '''use: 'backlight up' or 'backlight down' ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment