From 99a8cf5b9b842d74021dee32cf1a4d495c152560 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Sat, 12 May 2018 14:54:51 +0200 Subject: [PATCH] Quick and dirty virtual xserver forwarded to ledpanel, enjoy --- launch-led | 29 +++++++++++++++++++++++++++++ send.py | 21 +++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 launch-led create mode 100644 send.py diff --git a/launch-led b/launch-led new file mode 100755 index 0000000..23f3ce7 --- /dev/null +++ b/launch-led @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Usage: PULSE_SERVER=sound.waw.hackerspace.pl ./launch-led projectM-pulseaudio +# + +trap 'pkill -P $$' SIGINT + +Xephyr -br -ac -noreset -screen 128x128 :1 & + +export DISPLAY=:1 + +(while true; do + gst-launch-1.0 -q ximagesrc use-damage=0 show-pointer=false endx=128 endy=128 ! queue ! videoconvert ! videorate ! video/x-raw,format=RGB,width=128,height=128 ! fdsink | python send.py 10.8.1.26 128 128 + sleep 0.5 +done) & + +# ...resize current window to screen size +(#while true; do + sleep 2 + xdotool search --onlyvisible . windowmove 0 0 windowsize 129 129 + sleep 10 + xdotool search --onlyvisible . windowmove 0 0 windowsize 129 129 +#done +) & +sleep 1 + +$* + +pkill -P $$ diff --git a/send.py b/send.py new file mode 100644 index 0000000..1dcc37e --- /dev/null +++ b/send.py @@ -0,0 +1,21 @@ +import sys +import struct +import socket + +if __name__ == "__main__": + target = sys.argv[1] + width = int(sys.argv[2]) + height = int(sys.argv[3]) + + size = width*height*3 + + prefix = struct.pack( + '!BBHBB', 0x9c, 0xda, size, 0, 1) + + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + + while True: + buf = prefix + sys.stdin.read(size) + '\x36' + if len(buf) == 7: + exit(1) + sock.sendto(buf, (target, 65506))