First draft
This is just a scattering of notes and proofs of concepts.
This commit is contained in:
commit
c27e72bcfa
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.log
|
||||||
|
*.out
|
3
Dockerfile
Normal file
3
Dockerfile
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
FROM alpine
|
||||||
|
RUN apk add xvfb xdotool xfce4 ffmpeg chromium
|
||||||
|
RUN rm -rf /var/cache/apk/*
|
41
do.bash
Executable file
41
do.bash
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
#
|
||||||
|
# This is AWESOME.
|
||||||
|
#
|
||||||
|
# Original code by: Chris F.A. Johnson
|
||||||
|
#
|
||||||
|
ESC="" ## A literal escape character
|
||||||
|
but_row=1
|
||||||
|
|
||||||
|
clear
|
||||||
|
mv=1000 ## mv=1000 for press and release reporting; mv=9 for press only
|
||||||
|
|
||||||
|
_STTY=$(stty -g) ## Save current terminal setup
|
||||||
|
stty -echo -icanon ## Turn off line buffering
|
||||||
|
printf "${ESC}[?${mv}h " ## Turn on mouse reporting
|
||||||
|
printf "${ESC}[?25l" ## Turn off cursor
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
x=$(dd bs=1 count=6 2>/dev/null) ## Read six characters
|
||||||
|
|
||||||
|
m1=${x#???} ## Remove the first 3 characters
|
||||||
|
m2=${x#????} ## Remove the first 4 characters
|
||||||
|
m3=${x#?????} ## Remove the first 5 characters
|
||||||
|
|
||||||
|
## Convert to characters to decimal values
|
||||||
|
eval "$(printf "mb=%d mx=%d my=%d" "'$m1" "'$m2" "'$m3")"
|
||||||
|
|
||||||
|
## Values > 127 are signed
|
||||||
|
[ $mx -lt 0 ] && MOUSEX=$(( 223 + $mx )) || MOUSEX=$(( $mx - 32 ))
|
||||||
|
[ $my -lt 0 ] && MOUSEY=$(( 223 + $my )) || MOUSEY=$(( $my - 32 ))
|
||||||
|
|
||||||
|
## Button pressed is in first 2 bits; use bitwise AND
|
||||||
|
BUTTON=$(( ($mb & 3) + 1 ))
|
||||||
|
echo $MOUSEX $MOUSEY $BUTTON > mouse.out
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
printf "${ESC}[?${mv}l" ## Turn off mouse reporting
|
||||||
|
stty "$_STTY" ## Restore terminal settings
|
||||||
|
printf "${ESC}[?12l${ESC}[?25h" ## Turn cursor back on
|
||||||
|
printf "\n${ESC}[0J\n" ## Clear from cursor to bottom of screen
|
21
forward_mouse.rb
Normal file
21
forward_mouse.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
require 'curses'
|
||||||
|
include Curses
|
||||||
|
|
||||||
|
# These 2 allow mouse input
|
||||||
|
noecho # Prevent input being echoed to the screen
|
||||||
|
stdscr.keypad(true) # Not sure what this does exactly, but mouse input doesn't work without it
|
||||||
|
|
||||||
|
# Block whilst waiting for input
|
||||||
|
stdscr.timeout = -1
|
||||||
|
|
||||||
|
mousemask(ALL_MOUSE_EVENTS)
|
||||||
|
|
||||||
|
loop do
|
||||||
|
case getch
|
||||||
|
when KEY_MOUSE
|
||||||
|
m = getmouse
|
||||||
|
File.open('/home/tombh/Workspace/lowbandwidth/mouse.out', 'w') do |file|
|
||||||
|
file.write("#{m.x}, #{m.y}, #{m.z}, #{m.bstate}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
7
run.bash
Executable file
7
run.bash
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
ffmpeg -f x11grab -s 3200x1600 -r 12 -i :0.0 -vcodec mpeg2video -f mpegts udp://127.0.0.1:1234 >> ffmpeg.log 2>&1 &
|
||||||
|
sleep 1
|
||||||
|
# (/home/tombh/.rbenv/versions/2.3.0/bin/ruby ./forward_mouse.rb <&3 &) 3<&0
|
||||||
|
(./do.bash <&3 &) 3<&0
|
||||||
|
hiptext -width 95 -font /usr/share/fonts/TTF/DejaVuSansMono.ttf 'udp://127.0.0.1:1234' 2> hiptext.log
|
||||||
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
Loading…
Reference in a new issue