summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-02-24 07:11:30 +0100
committerMattias Andrée <maandree@operamail.com>2014-02-24 07:11:30 +0100
commit1123e48fc4cd9a7894e48117981415b76c2ed991 (patch)
tree284c3872c42875def8bc6adf0facfc775ebff1e4 /src
parentm + doc (diff)
downloadblueshift-1123e48fc4cd9a7894e48117981415b76c2ed991.tar.gz
blueshift-1123e48fc4cd9a7894e48117981415b76c2ed991.tar.bz2
blueshift-1123e48fc4cd9a7894e48117981415b76c2ed991.tar.xz
prototype list_monitors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/blueshift_idcrtc.c (renamed from src/blueshift_crtc_c.c)0
-rw-r--r--src/monitor.py38
2 files changed, 38 insertions, 0 deletions
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
+