#!/bin/bash

# Remove this check at your own risk.
if ! getent hosts collabnet.local; then
	echo -e "This isn't CollabVM anymore. Wake up.\n" >&2
	exit 1
fi

echo -ne "\e[33;1mWarning!\e[0m This will turn your device \e[1mflipping insane\e[0m.\nDo you wish to continue? [y/N] " >&2
read -n1 confirm
echo
case "$confirm" in
	y|Y);;
	*)
		echo 'Fair enough.' >&2
		exit;;
esac

exec &!

cd "$HOME"

sudo pacman --noconfirm --needed -S gifsicle xorg-xrandr

curl -O https://nat.envs.sh/flipping-insane.gif

sudo chvt 3
sudo Xorg :3 vt3 -nolisten tcp -nocursor -keeptty &
export DISPLAY=:3

sleep 5

gifview --animate --geometry 400x380+0+0 --new-window root --title 'this is flipping insane' flipping-insane.gif &

sudo xrandr --newmode flipping-insane 5.75 400 416 448 496 380 383 393 396 -hsync +vsync
sudo xrandr --addmode Virtual-1 flipping-insane
sudo xrandr --output Virtual-1 --mode flipping-insane
