From eab3b67c3d46d2a7bb761f85276d8b388600ed6d Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Sat, 27 Nov 2021 13:30:53 -0800 Subject: [PATCH] bin: add xaos-render script --- .local/bin/xaos-render.sh | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 .local/bin/xaos-render.sh diff --git a/.local/bin/xaos-render.sh b/.local/bin/xaos-render.sh new file mode 100755 index 0000000..77171c4 --- /dev/null +++ b/.local/bin/xaos-render.sh @@ -0,0 +1,41 @@ +#!/bin/bash +## +# This will render an image of a fractal in XaoS +## +# Assumptions made: +# 1. XaoS is in the foreground when you run the script (launch it from a hotkey or like this `$ script.sh true`) +# 2. XaoS is fullscreen +## +# Dependencies: ydotool +## +# Usage: xaos-render.sh [press alt tab (true or false)] [save path] [x_resolution] [y_resolution] +# defaults to 4k +## + SAVE_PATH="${2:-/home/blake/Pictures/fractiles/xaos-render-$RANDOM-}" # needs to be absolute +X_RESOLUTION="${3:-3840}" +Y_RESOLUTION="${4:-2160}" + +# must be run as root for ydotool to work +if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi +ydotoold & +sleep 0.2 +YDOTOOLD_PID=$! + +"${1:-false}" && ydotool key alt+tab && sleep 0.1 +# ydotool mousemove --absolute 0 0 +ydotool key --key-delay 4 alt+s +ydotool key --key-delay 4 8 +# ydotool click --buttons left +# ydotool key --key-delay 4 d{o,o}{w,w}{n,n} enter +# sleep 0.1 + +ydotool key ctrl+a +ydotool type "$SAVE_PATH" +ydotool key tab tab +ydotool type "$X_RESOLUTION" +ydotool key tab +ydotool type "$Y_RESOLUTION" +ydotool key enter + +kill -SIGTERM $YDOTOOLD_PID +