Skip to content

Commit 135499d

Browse files
committed
Added an example that shows how you can view any running program by simply configuring the script.
1 parent cbf1afc commit 135499d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"id": 1,
4+
"type": "compute",
5+
"output": "Executing...Starting automatic taylored block extraction for extensions 'xml' in directory '/tmp/tmp-1-GB6TMxBa8w1u'. Original branch: 'main'\nFound 1 file(s) with specified extensions. Processing...\nProcessing block 1 from /tmp/tmp-1-GB6TMxBa8w1u/runner.xml...\n(1/84) Installing font-opensans (0_git20210927-r1)\n(2/84) Purging icu-data-en (76.1-r0)\n(3/84) Installing icu-data-full (76.1-r0)\n(4/84) Installing mesa-dri-gallium (25.1.3-r1)\n(5/84) Installing eudev-libs (3.2.14-r5)\n(6/84) Installing libmagic (5.46-r2)\n(7/84) Installing file (5.46-r2)\n(8/84) Installing xprop (1.2.8-r0)\n(9/84) Installing xset (1.2.5-r1)\n(10/84) Installing xdg-utils (1.2.1-r1)\n(11/84) Installing libogg (1.3.5-r5)\n(12/84) Installing libflac (1.4.3-r1)\n(13/84) Installing libSvtAv1Enc (2.3.0-r0)\n(14/84) Installing aom-libs (3.12.1-r0)\n(15/84) Installing libva (2.22.0-r1)\n(16/84) Installing libvdpau (1.5-r4)\n(17/84) Installing onevpl-libs (2023.3.1-r2)\n(18/84) Installing ffmpeg-libavutil (6.1.2-r2)\n(19/84) Installing libdav1d (1.5.1-r0)\n(20/84) Installing openexr-libiex (3.3.2-r0)\n(21/84) Installing openexr-libilmthread (3.3.2-r0)\n(22/84) Installing imath (3.1.12-r0)\n(23/84) Installing openexr-libopenexrcore (3.3.2-r0)\n(24/84) Installing openexr-libopenexr (3.3.2-r0)\n(25/84) Installing libhwy (1.0.7-r1)\n(26/84) Installing libjxl (0.10.3-r2)\n(27/84) Installing lame-libs (3.100-r5)\n(28/84) Installing opus (1.5.2-r1)\n(29/84) Installing rav1e-libs (0.7.1-r0)\n(30/84) Installing soxr (0.1.3-r7)\n(31/84) Installing ffmpeg-libswresample (6.1.2-r2)\n(32/84) Installing libtheora (1.1.1-r18)\n(33/84) Installing libvorbis (1.3.7-r2)\n(34/84) Installing libvpx (1.15.0-r0)\n(35/84) Installing libwebpmux (1.5.0-r0)\n(36/84) Installing x264-libs (0.164.3108-r0)\n(37/84) Installing numactl (2.0.18-r0)\n(38/84) Installing x265-libs (3.6-r0)\n(39/84) Installing xvidcore (1.3.7-r2)\n(40/84) Installing ffmpeg-libavcodec (6.1.2-r2)\n(41/84) Installing libbluray (1.3.4-r1)\n(42/84) Installing mpg123-libs (1.32.10-r0)\n(43/84) Installing libopenmpt (0.7.13-r0)\n(44/84) Installing cjson (1.7.18-r1)\n(45/84) Installing mbedtls (3.6.3.1-r0)\n(46/84) Installing librist (0.2.10-r1)\n(47/84) Installing libsrt (1.5.3-r1)\n(48/84) Installing libssh (0.11.1-r0)\n(49/84) Installing libsodium (1.0.20-r0)\n(50/84) Installing libzmq (4.3.5-r2)\n(51/84) Installing ffmpeg-libavformat (6.1.2-r2)\n(52/84) Installing crc32c (1.1.2-r2)\n(53/84) Installing double-conversion (3.3.1-r0)\n(54/84) Installing harfbuzz-subset (11.2.1-r0)\n(55/84) Installing minizip (1.3.1-r0)\n(56/84) Installing nspr (4.36-r0)\n(57/84) Installing nss (3.112-r0)\n(58/84) Installing openh264 (2.6.0-r0)\n(59/84) Installing libcamera-ipa (0.5.1-r0)\n(60/84) Installing libunwind (1.8.1-r0)\n(61/84) Installing libcamera (0.5.1-r0)\n(62/84) Installing serd-libs (0.32.4-r0)\n(63/84) Installing zix-libs (0.6.2-r0)\n(64/84) Installing sord-libs (0.16.18-r0)\n(65/84) Installing sratom (0.6.18-r0)\n(66/84) Installing lilv-libs (0.24.26-r0)\n(67/84) Installing speexdsp (1.2.1-r2)\n(68/84) Installing libuv (1.51.0-r0)\n(69/84) Installing roc-toolkit-libs (0.4.0-r1)\n(70/84) Installing libsndfile (1.2.2-r2)\n(71/84) Installing abseil-cpp-raw-logging-internal (20240722.1-r1)\n(72/84) Installing abseil-cpp-strings-internal (20240722.1-r1)\n(73/84) Installing abseil-cpp-strings (20240722.1-r1)\n(74/84) Installing webrtc-audio-processing-2 (2.1-r0)\n(75/84) Installing pipewire-libs (1.4.5-r0)\n(76/84) Installing libasyncns (0.8-r4)\n(77/84) Installing libltdl (2.5.4-r1)\n(78/84) Installing orc (0.4.40-r1)\n(79/84) Installing tdb-libs (1.4.12-r0)\n(80/84) Installing libpulse (17.0-r5)\n(81/84) Installing simdutf (7.2.1-r0)\n(82/84) Installing libwebpdemux (1.5.0-r0)\n(83/84) Installing libxslt (1.1.43-r3)\n(84/84) Installing chromium (137.0.7151.68-r0)\nExecuting busybox-1.37.0-r18.trigger\nExecuting fontconfig-2.15.0-r3.trigger\nExecuting mkfontscale-1.2.3-r1.trigger\nExecuting gtk-update-icon-cache-3.24.49-r1.trigger\nOK: 1345 MiB in 343 packages\nSuccessfully created /tmp/tmp-1-GB6TMxBa8w1u/.taylored/1.taylored for computed block 1 from /tmp/tmp-1-GB6TMxBa8w1u/runner.xml (using branch diff against 'main')\nFinished processing. Successfully created 1 taylored file(s).\n",
6+
"value": "#!/bin/sh\napk add chromium"
7+
},
8+
{
9+
"id": 0,
10+
"type": "compute",
11+
"output": "Error: Error: DISPLAY environment variable is empty. Is there an Xorg or other X server running? You can try setting 'export DISPLAY=:0' and trying again.\nFailed creating new xdo instance.\nWARNING: Could not find window with class 'Geany'.\n--- Application updated. ---\n",
12+
"value": "#!/bin/sh\nset -e\n\n# --- Configurable Settings ---\n\n# --- OPERATING MODE ---\n# Sets how the script should operate.\n# 'FULL_START': Checks dependencies, cleans up, and starts everything from scratch.\n# 'REFRESH' : Only terminates the current app and starts a new one.\n# 'CLEAN' : Terminates all processes and stops (shutdown).\nOPERATION_MODE=\"REFRESH\"\n\n# --- DEPENDENCY MANAGEMENT ---\n# If 'true', the script will try to install missing dependencies.\n# On Alpine, this requires root privileges (run as the root user).\nAUTO_INSTALL_DEPS=\"true\"\n\n# --- CONNECTION SETTINGS ---\nVNC_PASSWORD=\"p\"\nVNC_PORT=\"2999\"\nWEBSOCKET_PORT=\"6080\"\n\n# --- GRAPHICAL ENVIRONMENT SETTINGS ---\nRESOLUTION=\"1920x1080x24\"\nPID_FILE=\"/tmp/vnc_app.pid\" # File to store the running application's process ID\n\n# --- APPLICATION SETTINGS (CUSTOMIZE) ---\nPROGRAM_TO_RUN=\"chromium-browser --no-sandbox\"\nWINDOW_CLASS=\"Geany\"\nCENTER_WINDOW=\"true\"\n\n\n# --- SCRIPT LOGIC (DO NOT MODIFY BELOW THIS LINE) ---\n\n# Function for a full environment cleanup (uses pkill for Alpine)\ncleanup_all() {\n echo \"--- Full Cleanup: Terminating all VNC environment processes... ---\"\n # pkill -f searches the full command line, which is more reliable.\n pkill -f \"x11vnc -display :0\" || true\n pkill -f \"Xvfb :0\" || true\n pkill -f \"websockify.*localhost:${VNC_PORT}\" || true\n\n if [ -f \"$PID_FILE\" ]; then\n kill $(cat \"$PID_FILE\") || true\n rm -f \"$PID_FILE\"\n fi\n echo \"--- Cleanup complete. ---\"\n}\n\n# Function to install dependencies on Alpine Linux\ninstall_dependencies() {\n if [ \"$AUTO_INSTALL_DEPS\" != \"true\" ]; then\n echo \"--- Dependency check skipped (disabled by configuration). ---\"\n return\n fi\n\n if ! command -v apk >/dev/null; then\n echo \"WARNING: This script is configured for Alpine Linux (apk) but 'apk' was not found.\"\n return\n fi\n\n if [ \"$(id -u)\" -ne 0 ]; then\n echo \"ERROR: To install dependencies on Alpine, please run this script as the 'root' user.\"\n exit 1\n fi\n \n # APK dependencies: procps contains pkill, websockify\n APK_DEPS=\"xvfb x11vnc xdotool procps websockify\"\n PACKAGES_TO_INSTALL=\"\"\n echo \"--- Checking for required APK dependencies... ---\"\n for pkg in $APK_DEPS; do\n if ! apk info -e \"$pkg\" >/dev/null 2>&1; then\n echo \"Missing APK dependency: $pkg\"\n PACKAGES_TO_INSTALL=\"$PACKAGES_TO_INSTALL $pkg\"\n fi\n done\n\n if [ -n \"$PACKAGES_TO_INSTALL\" ]; then\n echo \"Missing APK dependencies found. Updating and installing with 'apk add'...\"\n apk update\n apk add --no-cache $PACKAGES_TO_INSTALL\n else\n echo \"All required APK dependencies are already installed.\"\n fi\n}\n\n# Function to start the application\nstart_and_center_app() {\n echo \"--- Starting application: ${PROGRAM_TO_RUN} ---\"\n nohup env DISPLAY=:0 ${PROGRAM_TO_RUN} &\n echo $! > \"$PID_FILE\"\n if [ \"$CENTER_WINDOW\" = \"true\" ]; then\n echo \"--- Attempting to center the window (Class: ${WINDOW_CLASS}) ---\"\n sleep 3\n WINDOW_ID=$(xdotool search --onlyvisible --class \"${WINDOW_CLASS}\" | head -n 1)\n if [ -n \"$WINDOW_ID\" ]; then\n eval $(xdotool getwindowgeometry --shell $WINDOW_ID)\n SCREEN_WIDTH=$(echo $RESOLUTION | cut -d'x' -f1)\n SCREEN_HEIGHT=$(echo $RESOLUTION | cut -d'x' -f2)\n POS_X=$(( (SCREEN_WIDTH - WIDTH) / 2 ))\n POS_Y=$(( (SCREEN_HEIGHT - HEIGHT) / 2 ))\n xdotool windowmove $WINDOW_ID $POS_X $POS_Y\n echo \"Window (ID: $WINDOW_ID) centered.\"\n else\n echo \"WARNING: Could not find window with class '${WINDOW_CLASS}'.\"\n fi\n fi\n}\n\n# --- HANDLING OPERATING MODES ---\n# The main logic remains the same, but now relies on Alpine-compatible functions.\nif [ \"$OPERATION_MODE\" = \"CLEAN\" ]; then\n echo \"--- OPERATING MODE: CLEAN ---\"\n cleanup_all\n exit 0\n\nelif [ \"$OPERATION_MODE\" = \"REFRESH\" ]; then\n echo \"--- OPERATING MODE: REFRESH ---\"\n if [ -f \"$PID_FILE\" ]; then\n kill $(cat \"$PID_FILE\") || true\n rm -f \"$PID_FILE\"\n fi\n start_and_center_app\n echo \"--- Application updated. ---\"\n exit 0\n\nelif [ \"$OPERATION_MODE\" = \"FULL_START\" ]; then\n echo \"--- OPERATING MODE: FULL_START ---\"\n install_dependencies\n cleanup_all\n trap 'echo; cleanup_all; exit 0' INT TERM\n echo \"--- Starting base services... ---\"\n nohup Xvfb :0 -screen 0 ${RESOLUTION} &\n sleep 1\n nohup x11vnc -display :0 -forever -rfbport ${VNC_PORT} -passwd \"$VNC_PASSWORD\" &\n sleep 1\n nohup websockify --web /usr/share/novnc/ ${WEBSOCKET_PORT} localhost:${VNC_PORT} &\n sleep 1\n echo \"Servers started.\"\n start_and_center_app\n echo\n echo \">>> VNC environment started. <<<\"\nelse\n echo \"ERROR: Invalid OPERATION_MODE. Choose 'FULL_START', 'REFRESH', or 'CLEAN'.\"\n exit 1\nfi"
13+
}
14+
]

0 commit comments

Comments
 (0)