summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile15
-rw-r--r--src/blueshift_idcrtc.c (renamed from src/blueshift_crtc_c.c)0
-rw-r--r--src/monitor.py38
3 files changed, 52 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index d1910b2..48ac92d 100644
--- a/Makefile
+++ b/Makefile
@@ -7,9 +7,11 @@
PREFIX ?= /usr
BIN ?= /bin
LIB ?= /lib
+LIBEXEC ?= /libexec
DATA ?= /share
BINDIR ?= $(PREFIX)$(BIN)
LIBDIR ?= $(PREFIX)$(LIB)
+LIBEXECDIR ?= $(PREFIX)$(LIBEXEC)
DATADIR ?= $(PREFIX)$(DATA)
DOCDIR ?= $(DATADIR)/doc
LICENSEDIR ?= $(DATADIR)/licenses
@@ -30,6 +32,7 @@ LIBS_vidmode = x11 xxf86vm
LIBS = python3 $(foreach B,$(SERVER_BINDINGS),$(LIBS_$(B)))
STD = c99
FLAGS = $$($(PKGCONFIG) --cflags --libs $(LIBS)) -std=$(STD) $(WARN) $(OPTIMISE) -fPIC
+# TODO only link to used libs for each binary
DATAFILES = 2deg 10deg redshift redshift_old
PYFILES = __main__.py colour.py curve.py monitor.py solar.py icc.py
@@ -59,7 +62,8 @@ dvi: blueshift.dvi
ps: blueshift.ps
.PHONY: command
-command: $(foreach C,$(CBINDINGS),bin/$(C)) bin/blueshift
+command: $(foreach C,$(CBINDINGS),bin/$(C)) bin/blueshift_idcrtc bin/blueshift
+# TODO make bin/blueshift_idcrtc optional
.PHONY: shell
shell: bash zsh fish
@@ -87,8 +91,13 @@ obj/%.py: src/%.py
cp $< $@
sed -i '/^DATADIR *= /s#^.*$$#DATADIR = '\''$(DATADIR)/$(PKGNAME)'\''#' $@
sed -i '/^LIBDIR *= /s#^.*$$#LIBDIR = '\''$(LIBDIR)'\''#' $@
+ sed -i '/^LIBEXECDIR *= /s#^.*$$#LIBEXECDIR = '\''$(LIBEXECDIR)'\''#' $@
+bin/blueshift_idcrtc: obj/blueshift_idcrtc.o
+ @mkdir -p bin
+ $(CC) $(FLAGS) -o $@ $^
+
bin/%.so: obj/%.o obj/%_c.o
@mkdir -p bin
$(CC) $(FLAGS) -shared -o $@ $^
@@ -155,6 +164,8 @@ install-command: $(foreach C,$(CBINDINGS),bin/$(C)) bin/blueshift $(foreach D,$(
install -m755 bin/blueshift -- "$(DESTDIR)$(BINDIR)/$(COMMAND)"
install -dm755 -- "$(DESTDIR)$(LIBDIR)"
install -m755 $(foreach C,$(CBINDINGS),bin/$(C)) -- "$(DESTDIR)$(LIBDIR)"
+ install -dm755 -- "$(DESTDIR)$(LIBEXECDIR)"
+ install -m755 bin/blueshift_idcrtc -- "$(DESTDIR)$(LIBEXECDIR)/blueshift_idcrtc"
install -dm755 -- "$(DESTDIR)$(DATADIR)/$(PKGNAME)"
install -m644 -- $(foreach D,$(DATAFILES),res/$(D)) "$(DESTDIR)$(DATADIR)/$(PKGNAME)"
@@ -214,6 +225,8 @@ install-fish: bin/blueshift.fish
uninstall:
-rm -- "$(DESTDIR)$(BINDIR)/$(COMMAND)"
-rm -- $(foreach C,$(CBINDINGS),"$(DESTDIR)$(LIBDIR)/$(C)")
+ -rm -- "$(DESTDIR)$(LIBEXECDIR)/blueshift_idcrtc"
+ -rmdir -- "$(DESTDIR)$(LIBEXECDIR)"
-rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
-rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
-rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
diff --git a/src/blueshift_crtc_c.c b/src/blueshift_idcrtc.c
index d55f6eb..d55f6eb 100644
--- a/src/blueshift_crtc_c.c
+++ b/src/blueshift_idcrtc.c
diff --git a/src/monitor.py b/src/monitor.py
index 7572061..11643d1 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
+from subprocess import Popen, PIPE
from curve import *
@@ -23,6 +24,9 @@ from curve import *
LIBDIR = 'bin'
sys.path.append(LIBDIR)
+# /usr/libexec
+LIBEXECDIR = 'bin'
+
randr_opened = None
vidmode_opened = None
@@ -186,3 +190,37 @@ def print_curves(*crtcs, screen = 0):
print(G_curve)
print(B_curve)
+
+
+def list_monitors():
+ process = Popen([LIBEXECDIR + "/blueshift_idcrtc"], stdout = PIPE)
+ lines = process.communicate()[0].decode('utf-8', 'error').split('\n')
+ lines = [line.strip() for line in lines]
+ screens, screen, output = None, None, None
+ for line in lines:
+ if line.startswith('Screen count: '):
+ screens = [None] * int(line[len('Screen count: '):])
+ elif line.startswith('Screen: '):
+ screen_i = int(line[len('Screen: '):])
+ screen = {}
+ screens[screen_i] = screen
+ elif line.startswith('CRTC count: '):
+ screen['crtc'] = int(line[len('CRTC count: '):])
+ elif line.startswith('Output count: '):
+ screen['output'] = [None] * int(line[len('Output count: '):])
+ elif line.startswith('Output: '):
+ output_i = int(line[len('Output: '):])
+ output = {'name' : None, 'connected' : False, 'width' : None, 'height' : None, 'crtc' : None}
+ screen['output'][output_i] = output
+ elif line.startswith('Name: '):
+ output['name'] = line[len('Name: '):]
+ elif line.startswith('Connection: '):
+ output['connected'] = line[len('Connection: '):] == 'connected'
+ elif line.startswith('Size: '):
+ width, height = [int(x) for x in line[len('Size: '):].split(' ')]
+ output['width'] = width
+ output['height'] = height
+ elif line.startswith('CRTC: '):
+ output['crtc'] = int(line[len('CRTC: '):])
+ return screens
+