colorlight-blaster/launch-led

45 lines
1.3 KiB
Plaintext
Executable File

#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash python3 xdotool gst_all_1.gstreamer gst_all_1.gst-plugins-good gst_all_1.gst-plugins-base
#
# Usage: PULSE_SERVER=sound.waw.hackerspace.pl ./launch-led projectM-pulseaudio
#
set -e -o pipefail
if [[ $# -lt 1 ]]; then
echo "usage: $0 [command] ..." >&2
exit 1
fi
# sadness - ensure sudo is kept authenticated to be used in subshell below...
sudo id
trap 'pkill -P $$' SIGINT
DISP_ID=10
NATIVE_RES=${XEPHYR_RES:-512}
Xephyr -br -ac -noreset -screen ${NATIVE_RES}x${NATIVE_RES} :$DISP_ID &
while [[ ! -e /tmp/.X11-unix/X$DISP_ID ]]; do echo ...; sleep 0.1; done
ls -lah /tmp/.X11-unix
export DISPLAY=:$DISP_ID
(while true; do
gst-launch-1.0 -q ximagesrc use-damage=0 show-pointer=false endx=${NATIVE_RES} endy=${NATIVE_RES} ! queue ! videoconvert ! videorate ! videoscale ! video/x-raw,format=BGR,width=128,height=128 ! fdsink | sudo python colorlight.py
sleep 0.5
done) &
# ...resize current window to screen size
# TODO: use some proper window manager
(
sleep 2
xdotool search --onlyvisible . windowmove 0 0 windowsize $((NATIVE_RES + 1)) $((NATIVE_RES + 1))
sleep 10
xdotool search --onlyvisible . windowmove 0 0 windowsize $((NATIVE_RES + 1)) $((NATIVE_RES + 1))
) &
"$@"
pkill -P $$