aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-10-09 10:46:49 +0200
committerMattias Andrée <maandree@operamail.com>2012-10-09 10:46:49 +0200
commit1eddd57061e85b3e6e30105d01d37878e82190aa (patch)
tree13ddaeae8483b656ddcabb805e5eb983001868cf
parentbeginning (diff)
downloadadjbacklight-1eddd57061e85b3e6e30105d01d37878e82190aa.tar.gz
adjbacklight-1eddd57061e85b3e6e30105d01d37878e82190aa.tar.bz2
adjbacklight-1eddd57061e85b3e6e30105d01d37878e82190aa.tar.xz
turn on and off icanon + get terminal width + get maximum and current brightness
Diffstat (limited to '')
-rwxr-xr-xadjbacklight.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/adjbacklight.py b/adjbacklight.py
index 5e28396..0d07f46 100755
--- a/adjbacklight.py
+++ b/adjbacklight.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import os
+import sys
from subprocess import Popen, PIPE
@@ -14,14 +15,23 @@ def print(text = '', end = '\n'):
-
'''
This is the mane class of the program
'''
class Adjbacklight():
-
-#Popen(compressCommand(ext).split(' '), stdout=fileout, stdin=filein).communicate()
-#(out, err) = Popen(['env', 'python', '--version'], stdout=PIPE, stderr=PIPE).communicate()
+ def __init__(self):
+ Popen('stty -icanon'.split(' ')).wait()
+ try:
+ dir = '/sys/class/backlight/intel_backlight/'
+ (size, dummy) = Popen('stty size'.split(' '), stdout=PIPE, stderr=PIPE).communicate()
+ width = int(size.decode('UTF-8').replace('\n', '').split(' ')[1])
+ with open(dir + 'brightness', 'r') as file:
+ current = int(file.readline().replace('\n', ''))
+ with open(dir + 'max_brightness', 'r') as file:
+ max = int(file.readline().replace('\n', ''))
+
+ finally:
+ Popen('stty icanon'.split(' ')).wait()
'''