summaryrefslogtreecommitdiffstats
path: root/src/monitor.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-16 19:19:36 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-16 19:19:36 +0100
commita7ab7860a57cdd41944355a400f62581f8b19d03 (patch)
tree532e3e68540102655e16f212386ff1fcf3440e31 /src/monitor.py
parentc binding (diff)
downloadblueshift-a7ab7860a57cdd41944355a400f62581f8b19d03.tar.gz
blueshift-a7ab7860a57cdd41944355a400f62581f8b19d03.tar.bz2
blueshift-a7ab7860a57cdd41944355a400f62581f8b19d03.tar.xz
use randr
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/monitor.py')
-rw-r--r--src/monitor.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/monitor.py b/src/monitor.py
index 37f6b00..b8f5cff 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -15,6 +15,15 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import sys
+
+# /usr/lib
+LIBDIR = 'bin'
+sys.path.append(LIBDIR)
+
+from blueshift_randr import *
+randr_opened = False
+
def translate_to_integers():
'''
@@ -31,17 +40,31 @@ def translate_to_integers():
return (R_curve, G_curve, B_curve)
+def close_c_bindings():
+ global randr_opened
+ if randr_opened:
+ randr_close()
+
+
def randr(*crtcs):
'''
Applies colour curves using the X11 extension randr
@param *crtcs The CRT controllers to use, all are used if none are specified
'''
+ global randr_opened
crtcs = sum([1 << i for i in list(crtcs)])
if crtcs == 0:
crtcs = -1;
(R_curve, G_curve, B_curve) = translate_to_integers()
+ if not randr_opened:
+ if randr_open(0) == 0: ## TODO support specifying screen
+ randr_opened = True
+ else:
+ sys.exit(1)
+ if not randr_apply(crtcs, R_curve, G_curve, B_curve) == 0:
+ sys.exit(1)
def print_curves(*crtcs):