plugfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

dualOBS (1192B)


      1 #!/bin/bash
      2 # Nick Farrow 2019
      3 
      4 VERTICAL=true
      5 
      6 # Whenever out mouse is past XSPLIT in the X-direction,
      7 # A hotkey is sent to OBS to change scenes
      8 XSPLIT=1080
      9 
     10 # Hotkeys for left and right scenes
     11 LEFT='F7'
     12 RIGHT='F8'
     13 
     14 PAST=$RIGHT
     15 
     16 
     17 while getopts "vp:" opt; do
     18 	case ${opt} in
     19 		v )
     20 			VERTICAL=true
     21 			XSPLIT=1080
     22 			
     23 			TMPSTORE=$LEFT
     24 			LEFT=$RIGHT
     25 			RIGHT=$TMPSTORE
     26 		;;
     27 		p )
     28 			XSPLIT=$OPTARG
     29 		;;
     30 		\? )
     31 			echo "Invalid option" 1>&2
     32 			exit 1
     33 		;;
     34 		: )
     35 			echo "Invalid option, $OPTARG requires an argument" 1>&2
     36 			exit 1
     37 		;;
     38 	esac
     39 done
     40 
     41 printf "\n\n\n Starting OBS:"
     42 
     43 obs | while :
     44 	do
     45 		if [ "$VERTICAL" = false ] ; then
     46 			XCOORD=$(xdotool getmouselocation | cut -d : -f 2 | cut -d ' ' -f 1)
     47 		else
     48 			XCOORD=$(xdotool getmouselocation | cut -d : -f 3 | cut -d ' ' -f 1)
     49 		fi
     50 
     51 		if [ "$XCOORD" -lt "$XSPLIT" ] && [ "$PAST" == "$RIGHT" ]; then
     52 			WINDOWID=$(xdotool search --name OBS | tail -1)
     53 			xdotool key --window $WINDOWID $LEFT
     54 			PAST=$LEFT
     55 			echo "CHANGE LEFT"
     56 
     57 		elif [ "$XCOORD" -gt "$XSPLIT" ] && [ "$PAST" == "$LEFT" ]; then
     58 			WINDOWID=$(xdotool search --name OBS | tail -1)
     59 			xdotool key --window $WINDOWID $RIGHT
     60 			PAST=$RIGHT
     61 			echo "CHANGE RIGHT"
     62 		fi
     63 	done