tools/mcde-shot.sh learns MCDE_SHOT_PALETTE (a palette from dt/palettes: its first colour is the background, the text is black) and MCDE_SHOT_FULL (dtsession starts the whole desktop). A holder client keeps the X server from resetting the resource database and the font path when xrdb and xset exit; the palette and share/fonts are in place before the first client starts, so dtwm, the bar and the program take them. The four desktop pictures are taken again with the bar (clock, sound, bluetooth, global menu, M menu), the front panel and the desktop icons, each in another palette: dtwm-4dwm-font.png IRIX, pointer-irix-xcursor.png Charcoal, pointer-solaris-cursors.png Desert, desktop-root-menu.png Default.
198 lines
7.5 KiB
Bash
Executable File
198 lines
7.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
#
|
|
# mcde-shot.sh -- run an MCDE program on a virtual screen and take a screenshot
|
|
#
|
|
# usage: tools/mcde-shot.sh OUT.png SECONDS PROGRAM [ARG ...]
|
|
#
|
|
# For work on MCDE on the build host: runs PROGRAM (a name in
|
|
# build/mcde-root/dt/bin, or a path) from the development installation that
|
|
# `make mcde-linux MCDE_DIRS=install' made, on a private Xvfb display, waits
|
|
# SECONDS, saves the whole screen as OUT.png and stops everything it started.
|
|
# ttsession (ToolTalk) and dtwm are started first: dtfile and others need them.
|
|
# The program's output goes to OUT.png.log.
|
|
|
|
set -u
|
|
|
|
[ $# -ge 3 ] || { echo "usage: ${0##*/} OUT.png SECONDS PROGRAM [ARG ...]" >&2; exit 2; }
|
|
OUT=$1 WAIT=$2
|
|
shift 2
|
|
|
|
TOP=$(cd "$(dirname "$0")/.." && pwd)
|
|
R=$TOP/build/mcde-root
|
|
[ -x "$R/dt/bin/dtfile" ] || { echo "no $R: make mcde-linux MCDE_DIRS=install" >&2; exit 1; }
|
|
|
|
prog=$1
|
|
shift
|
|
case $prog in
|
|
*/*) ;;
|
|
*) prog=$R/dt/bin/$prog ;;
|
|
esac
|
|
|
|
DISP=:91
|
|
Xvfb $DISP -screen 0 1024x768x24 -nolisten tcp > /dev/null 2>&1 &
|
|
xpid=$!
|
|
sleep 2
|
|
|
|
# a home of its own, new each run: CDE programs read and write ~/.dt, and the
|
|
# real one belongs to the desktop of whoever runs this (2026-11-09: a test with
|
|
# the real HOME rewrote ~/.dt/Trash/.trashinfo)
|
|
H=$TOP/build/mcde-shots/home
|
|
# MCDE_SHOT_KEEP_HOME: keep what the last run left (a test of what the
|
|
# desktop remembers: icon places, ~/.dt/desktop.conf)
|
|
if [ "${MCDE_SHOT_KEEP_HOME:-0}" != 1 ]; then
|
|
rm -rf "$H"
|
|
fi
|
|
mkdir -p "$H"
|
|
DISPLAY=$DISP
|
|
HOME=$H
|
|
PATH=$R/dt/bin:$PATH
|
|
LD_LIBRARY_PATH=$R/dt/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
|
# what dtsession would set: the app-defaults of this installation
|
|
XFILESEARCHPATH=$R/dt/app-defaults/%L/%N:$R/dt/app-defaults/C/%N
|
|
# what DtEnvControl would add: the data types (icons, actions of a file)
|
|
DTDATABASESEARCHPATH=$R/dt/appconfig/types/%L,$R/dt/appconfig/types/C
|
|
# the screen savers dtsession offers (programs/dtlogin/config/Xsession.src)
|
|
DTSCREENSAVERLIST="StartDtscreenSwarm StartDtscreenQix StartDtscreenFlame \
|
|
StartDtscreenHop StartDtscreenImage StartDtscreenLife StartDtscreenRotor \
|
|
StartDtscreenPyro StartDtscreenWorm StartDtscreenBlank"
|
|
# the ToolTalk types (ptypes) of this installation: ttsession starts the
|
|
# handlers of messages (DtAction "Trash", ...) from them and finds them in
|
|
# $HOME/.tt, /etc/tt or /usr/dt/appconfig/tttypes -- none of which exists
|
|
# here; TTPATH names the directory (ttsession(1); lib/tt/slib/mp_typedb.C
|
|
# tt_path(): a directory in TTPATH gets "/types.xdr" appended; t0206)
|
|
TTPATH=$R/dt/appconfig/tttypes
|
|
export DISPLAY HOME PATH LD_LIBRARY_PATH XFILESEARCHPATH DTDATABASESEARCHPATH DTSCREENSAVERLIST TTPATH
|
|
|
|
# MCDE_SHOT_SETUP: a command run in the fresh home before the program starts
|
|
# (make a folder of pictures to look at); MCDE_SHOT_EXTRA: a program of the
|
|
# session started beside the main one (dtbar, so that the global menu is
|
|
# there); MCDE_SHOT_ACTIONS: commands run before the picture, with DISPLAY
|
|
# and HOME of the session ("xdotool mousemove 205 212 click 1; xdotool key
|
|
# space"); keys with a modifier or F-keys through tools/mcde-xkey.sh, not
|
|
# `xdotool key' (it adds Alt on this keymap, see that script)
|
|
#
|
|
# MCDE_SHOT_FULL=1: the whole desktop -- dtsession starts the window manager,
|
|
# the bar, the front panel, the desktop icons, the sound daemon and the
|
|
# launcher (sessionetc.d) instead of ttsession+dtwm. MCDE_SHOT_PALETTE=NAME
|
|
# (or NAME.dp): the palette of the picture, from dt/palettes; its first line
|
|
# is the background and the text is black. The palette goes into the server's
|
|
# resources before the clients start, so it works in both modes; a picture
|
|
# without dtbar (MCDE_SHOT_EXTRA=dtbar) has no bar.
|
|
if [ -n "${MCDE_SHOT_SETUP:-}" ]; then
|
|
(cd "$H" && eval "$MCDE_SHOT_SETUP") || exit 1
|
|
fi
|
|
|
|
# an empty environment: the session this runs in may be a CDE of its own,
|
|
# whose DT*, XMICON* and SESSION_* variables would point the program at that
|
|
# installation (2026-11-09: dtfile read /usr/mdt/appconfig/types). A function,
|
|
# not a string: DTSCREENSAVERLIST has spaces in it.
|
|
Session() {
|
|
env -i DISPLAY=$DISPLAY HOME=$HOME PATH=$PATH LANG=${MCDE_LANG:-C.UTF-8} \
|
|
LD_LIBRARY_PATH=$LD_LIBRARY_PATH XFILESEARCHPATH=$XFILESEARCHPATH \
|
|
TTPATH=$TTPATH \
|
|
DTDATABASESEARCHPATH=$DTDATABASESEARCHPATH \
|
|
DTSCREENSAVERLIST="$DTSCREENSAVERLIST" \
|
|
MCDE_THUMB_DEBUG="${MCDE_THUMB_DEBUG:-}" \
|
|
MCDE_DESK_DEBUG="${MCDE_DESK_DEBUG:-}" \
|
|
MCDE_DESK_TEST_MOUNTS="${MCDE_DESK_TEST_MOUNTS:-}" \
|
|
MCDE_DESK_TEST_DESKTOP="${MCDE_DESK_TEST_DESKTOP:-}" \
|
|
MCDE_DESK_TEST_DISKS="${MCDE_DESK_TEST_DISKS:-}" \
|
|
MCDE_SOUND_THEME="${MCDE_SOUND_THEME:-}" \
|
|
MCDE_PARENTAL_DEBUG="${MCDE_PARENTAL_DEBUG:-}" \
|
|
MCDE_DEFAULTS_DEBUG="${MCDE_DEFAULTS_DEBUG:-}" "$@"
|
|
}
|
|
# the palette of the picture: a palette file is eight RGB lines; the first is
|
|
# the background of the colour set (dtsession's colour server writes it into
|
|
# the server resources, SrvPalette.c writeXrdbColors) and the text is black.
|
|
# One picture per palette, so the directory shows the range of the desktop.
|
|
pal=
|
|
if [ -n "${MCDE_SHOT_PALETTE:-}" ]; then
|
|
pal=${MCDE_SHOT_PALETTE}
|
|
case $pal in
|
|
*.dp) ;;
|
|
*) pal=$pal.dp ;;
|
|
esac
|
|
fi
|
|
|
|
tpid= wpid= spid= holdpid=
|
|
# the palette and the core X fonts go into the server before the first client
|
|
# of the session starts: a holder keeps the server from resetting the
|
|
# resource database and the font path when xrdb and xset exit
|
|
if command -v xprop > /dev/null 2>&1; then
|
|
xprop -root -spy > /dev/null 2>&1 &
|
|
holdpid=$!
|
|
if [ -n "$pal" ]; then
|
|
dppal=$R/dt/palettes/$pal
|
|
[ -f "$dppal" ] || dppal=$pal
|
|
if [ -f "$dppal" ]; then
|
|
bg=$(sed -n 1p "$dppal")
|
|
# the text colour of the palette's colour set is not its
|
|
# second line (that is a shadow); the server picks a
|
|
# readable foreground -- black on these light backgrounds
|
|
printf '*background: %s\n*foreground: #000000000000\n' \
|
|
"$bg" | xrdb -merge
|
|
fi
|
|
fi
|
|
# the core X fonts of the installation: a session gets them from
|
|
# dtlogin's fontPathTail (config/Xconfig). The -dt-interface aliases
|
|
# are not added: their Lucida targets are not part of this host, and
|
|
# the fallback fontset draws the bar's labels in CJK glyphs.
|
|
if [ -d "$R/dt/share/fonts" ]; then
|
|
xset fp+ "$R/dt/share/fonts" > /dev/null 2>&1
|
|
xset fp rehash > /dev/null 2>&1
|
|
fi
|
|
fi
|
|
|
|
if [ "${MCDE_SHOT_FULL:-0}" = 1 ]; then
|
|
# the whole desktop: dtsession starts the window manager, the bar, the
|
|
# front panel, the desktop icons, the sound daemon and the launcher
|
|
# (sessionetc.d)
|
|
Session dtsession >> "$OUT.log" 2>&1 &
|
|
spid=$!
|
|
sleep 6
|
|
# a fresh home opens the help volume and a file manager window; the
|
|
# picture is of the desktop
|
|
if command -v xdotool > /dev/null 2>&1; then
|
|
for name in "Help Viewer" "File Manager"; do
|
|
xdotool search --name "$name" windowclose > /dev/null 2>&1
|
|
done
|
|
fi
|
|
sleep 1
|
|
else
|
|
Session ttsession -s > "$OUT.log" 2>&1 &
|
|
tpid=$!
|
|
sleep 1
|
|
# the window manager: dtfile waits for its workspace list (Desktop.c,
|
|
# BuildDesktopLinks), and the frames belong in the picture
|
|
Session dtwm >> "$OUT.log" 2>&1 &
|
|
wpid=$!
|
|
sleep 2
|
|
fi
|
|
[ -n "$holdpid" ] && kill "$holdpid" 2> /dev/null
|
|
holdpid=
|
|
Session "$prog" "$@" >> "$OUT.log" 2>&1 &
|
|
ppid=$!
|
|
epids=
|
|
if [ -n "${MCDE_SHOT_EXTRA:-}" ]; then
|
|
Session sh -c "$MCDE_SHOT_EXTRA" >> "$OUT.log" 2>&1 &
|
|
epids=$!
|
|
fi
|
|
sleep "$WAIT"
|
|
|
|
if [ -n "${MCDE_SHOT_ACTIONS:-}" ]; then
|
|
sleep 1
|
|
(cd "$H" && eval "$MCDE_SHOT_ACTIONS")
|
|
sleep 2
|
|
fi
|
|
|
|
import -window root "$OUT"
|
|
rc=$?
|
|
|
|
kill "$ppid" $epids $wpid $tpid $spid $holdpid 2> /dev/null
|
|
sleep 1
|
|
kill "$xpid" 2> /dev/null
|
|
wait 2> /dev/null
|
|
echo "mcde-shot: $OUT (import exit=$rc)"
|
|
exit $rc
|