-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from malverick/brightness
Linux Brightness API
- Loading branch information
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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() |