about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/test-xephyr.sh111
-rwxr-xr-xtest/xmonad-ng-xephyr.sh102
2 files changed, 111 insertions, 102 deletions
diff --git a/test/test-xephyr.sh b/test/test-xephyr.sh
new file mode 100755
index 0000000..e28928a
--- /dev/null
+++ b/test/test-xephyr.sh
@@ -0,0 +1,111 @@
+#!/bin/sh -eu
+
+usage () {
+    cat << EOF
+Usage: test-xephyr.sh [options]
+
+    -d NxN  Set the screen size to NxN
+    -h      This message
+    -n NUM  Set the internal DISPLAY to NUM
+    -s NUM  Set the number of screens to NUM
+EOF
+}
+
+ARCH=$(uname -m)
+OS=$(uname -s | tr '[:upper:]' '[:lower:]')
+SCREENS=1
+SCREEN_SIZE="800x600"
+DISPLAY_NUMBER=9
+
+while getopts "d:hs:n:" OPT
+do
+    case "${OPT}" in
+        d)
+            SCREEN_SIZE=$OPTARG
+        ;;
+
+        h)
+            usage && exit
+        ;;
+
+        n)
+            DISPLAY_NUMBER=$OPTARG
+        ;;
+
+        s)
+            SCREENS=$OPTARG
+        ;;
+
+        *)
+            usage && exit 1
+        ;;
+    esac
+done
+
+shift $((OPTIND-1))
+
+if [ ! "$(command -v Xephyr)" ]
+then
+    echo "test-xephyr.sh: Xephyr executable is missing in PATH"
+    exit 1
+fi
+
+if [ -d .stack-work ]
+then
+    echo "test-xephyt.sh: Stack build detected"
+    BIN_PATH=$(stack path --dist-dir)/build/xmonad-ng
+elif [ -d dist ]; then
+    echo "test-xephyr.sh: Cabal build detected"
+    BIN_PATH=$(find dist/ -type f -executable -name xmonad-ng -printf '%h')
+else
+    echo "test-xephyr.sh: You need to build xmonad-ng first, see README for instructions"
+    exit 1
+fi
+
+RAW_BIN="$BIN_PATH/xmonad-ng"
+ARCH_BIN="$BIN_PATH/xmonad-ng-$ARCH-$OS"
+
+cp -p "$RAW_BIN" "$ARCH_BIN"
+
+XMONAD_CONFIG_DIR="$(pwd)/state/config"
+XMONAD_CACHE_DIR="$(pwd)/state/cache"
+XMONAD_DATA_DIR="$(pwd)/state/data"
+export XMONAD_CONFIG_DIR XMONAD_CACHE_DIR XMONAD_DATA_DIR
+
+mkdir -p "$XMONAD_CONFIG_DIR" "$XMONAD_CACHE_DIR" "$XMONAD_DATA_DIR"
+echo "test-xephyr.sh: State files will be stored in $(pwd)/state"
+
+SCREEN_COUNTER=0
+SCREEN_OPTS=""
+X_OFFSET_CURRENT="0"
+X_OFFSET_ADD=$(echo "$SCREEN_SIZE" | cut -dx -f1)
+
+while expr "$SCREEN_COUNTER" "<" "$SCREENS"
+do
+    SCREEN_OPTS="$SCREEN_OPTS -origin ${X_OFFSET_CURRENT},0 -screen ${SCREEN_SIZE}+${X_OFFSET_CURRENT}"
+    SCREEN_COUNTER=$(("$SCREEN_COUNTER" + 1))
+    X_OFFSET_CURRENT=$(("$X_OFFSET_CURRENT" + "$X_OFFSET_ADD"))
+done
+
+(
+    echo "test-xephyr.sh: Launching Xephyr process"
+    # shellcheck disable=SC2086
+    Xephyr $SCREEN_OPTS \
+        +extension RANDR \
+        +xinerama \
+        -ac \
+        -br \
+        -reset \
+        -softCursor \
+        -terminate \
+        -verbosity 10 \
+        ":$DISPLAY_NUMBER" &
+
+    export DISPLAY=":$DISPLAY_NUMBER"
+    echo "test-xephyr.sh: Waiting for windwos to appear..." && sleep 3
+
+    xterm -hold xrandr &
+    xterm &
+
+    $ARCH_BIN
+)
diff --git a/test/xmonad-ng-xephyr.sh b/test/xmonad-ng-xephyr.sh
deleted file mode 100755
index 37e0bab..0000000
--- a/test/xmonad-ng-xephyr.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/sh -eu
-
-usage () {
-    cat << EOF
-Usage: xmonad-ng-xephyr.sh [options]
-
-  -d NxN  Set the screen size to NxN
-  -h      This message
-  -n NUM  Set the internal DISPLAY to NUM
-  -s NUM  Set the number of screens to NUM
-EOF
-}
-
-ARCH=$(uname -m)
-OS=$(uname -s | tr '[:upper:]' '[:lower:]')
-SCREENS=1
-SCREEN_SIZE="800x600"
-DISPLAY_NUMBER=5
-
-while getopts "d:hs:n:" o
-do
-    case "${o}" in
-        d)
-            SCREEN_SIZE=$OPTARG
-        ;;
-
-        h) usage
-            exit
-        ;;
-
-        n)
-            DISPLAY_NUMBER=$OPTARG
-        ;;
-
-        s)
-            SCREENS=$OPTARG
-        ;;
-
-        *)
-            echo
-            usage
-            exit 1
-        ;;
-    esac
-done
-
-shift $((OPTIND-1))
-
-################################################################################
-if [ -d .stack-work ]; then
-  echo "stack build detected"
-  options=""
-  [ "${NIX_PATH:-NO}" = "NO" ] || options="--nix"
-  BIN_PATH=$(stack path $options --dist-dir)/build/xmonad-ng
-elif [ -d dist ]; then
-  echo "cabal build detected"
-  BIN_PATH=$(find dist/ -type f -executable -name xmonad-ng -printf '%h')
-else
-  echo "you need to build xmonad-ng first, see README for instructions"
-  exit 1
-fi
-
-RAW_BIN=$BIN_PATH/xmonad-ng
-ARCH_BIN=$BIN_PATH/xmonad-ng-$ARCH-$OS
-
-################################################################################
-cp -p "$RAW_BIN" "$ARCH_BIN"
-
-################################################################################
-XMONAD_CONFIG_DIR=$(pwd)/state/config
-XMONAD_CACHE_DIR=$(pwd)/state/cache
-XMONAD_DATA_DIR=$(pwd)/state/data
-export XMONAD_CONFIG_DIR XMONAD_CACHE_DIR XMONAD_DATA_DIR
-
-mkdir -p "$XMONAD_CONFIG_DIR" "$XMONAD_CACHE_DIR" "$XMONAD_DATA_DIR"
-echo "xmonad will store state files in $(pwd)/state"
-
-################################################################################
-SCREEN_COUNTER=0
-SCREEN_OPTS=""
-X_OFFSET_CURRENT="0"
-X_OFFSET_ADD=$(echo "$SCREEN_SIZE" | cut -dx -f1)
-
-while expr "$SCREEN_COUNTER" "<" "$SCREENS"; do
-  SCREEN_OPTS="$SCREEN_OPTS -origin ${X_OFFSET_CURRENT},0 -screen ${SCREEN_SIZE}+${X_OFFSET_CURRENT}"
-  SCREEN_COUNTER=$(("$SCREEN_COUNTER" + 1))
-  X_OFFSET_CURRENT=$(("$X_OFFSET_CURRENT" + "$X_OFFSET_ADD"))
-done
-
-(
-  # shellcheck disable=SC2086
-  Xephyr $SCREEN_OPTS +xinerama +extension RANDR \
-         -ac -br -reset -terminate -verbosity 10 \
-         -softCursor ":$DISPLAY_NUMBER" &
-
-  export DISPLAY=":$DISPLAY_NUMBER"
-  echo "Waiting for windows to appear..." && sleep 2
-
-  xterm -hold xrandr &
-  xterm &
-  $ARCH_BIN
-)

Consider giving Nix/NixOS a try! <3