summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/__main__.py4
-rw-r--r--src/blueshift_randr.pyx (renamed from src/_blueshift_randr.pyx)0
-rw-r--r--src/monitor.py23
3 files changed, 26 insertions, 1 deletions
diff --git a/src/__main__.py b/src/__main__.py
index 400c675..f8db7a2 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -150,7 +150,6 @@ if config_file is not None:
code = code.decode('utf8', 'error') + '\n'
code = compile(code, file, 'exec')
exec(code, globals)
- break
else:
print('No configuration file found')
sys.exit(1)
@@ -168,6 +167,7 @@ if periodically is not None:
running = False
start_over()
monitor_controller()
+ close_c_bindings()
sys.exit(0)
running = False
signal.signal(signal.SIGTERM, signal_SIGTERM)
@@ -205,3 +205,5 @@ if periodically is not None:
start_over()
monitor_controller()
+close_c_bindings()
+
diff --git a/src/_blueshift_randr.pyx b/src/blueshift_randr.pyx
index e022714..e022714 100644
--- a/src/_blueshift_randr.pyx
+++ b/src/blueshift_randr.pyx
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):