Robin Laing posted on Wed, 6 Aug 2025 22:19:08 -0600 as excerpted:

> I will have to look at the cache and config files.  Not sure about your
> comment about "wrappers."

Wrapper scripts:  Scripts (usually shellscripts but could be perl/python/
whatever too if you're more comfortable with them than shell scripting) 
that "wrap" a packaged or self-built executable, used to do some site-
local pre-setup before running the real executable.

In this case that pre-setup would be setting/exporting the PAN_HOME 
environmental variable, allowing you to run multiple pan instances, say 
one for text and one for binaries, or one for small-binaries like 
individual pictures or single mp3 songs, with another for larger binaries 
like full ISO images, full movies or TV episodes, full albums, etc.  That 
allows the instances to have separate configs, including cache size/
expiration, etc.

Often wrapper scripts will be named the same as their target binary and 
simply appear first in the path, so launching them by name will find the 
wrapper and launch it first, with the wrapper doing its setup before 
actually launching its target binary.  (Do note that the *.desktop format 
that GUI launchers typically use, however, specifies absolute not relative 
paths, meaning these will typically bypass the shell's path mechanism and 
launch their absolutely specified target directly.  To launch wrappers 
from GUI launchers, therefore, one generally has to edit the *.desktop 
files to point to the wrapper instead of the target binary.  This can be 
enough of a pain that often, people will simply use the shell, either 
directly or via their open dialog, to launch the wrappers, instead of 
using the GUI launcher method.)

In this case, however, you'd presumably have multiple wrappers, named say 
pan.text and pan.binary (to use my setup as an example), and would 
therefore launch them by specific name instead of using the generic target 
name of pan and relying on path order to get the wrapper instead of the 
binary target.  (In my case I actually have a single pan shell-script, 
which defaults to the text instance, with symlinks named pan.binary or 
whatever, combined with logic in the wrapper to set the PAN_HOME var based 
on the name of whatever symlink was used to launch it, along with the 
mentioned default to pan.text if the pan script itself is launched.)

I actually do additional setup in my wrapper as well, but I might as well 
post it.  FWIW ~/bin appears in my user's path before the system paths, 
and:

$$ ls -l bin/pan*
-rwx------ 1 x    users 1448 Mar 31 23:43 bin/pan
-rwx------ 1 x    users 5410 Jun 30  2014 bin/pan-attach
-rwx------ 1 x    users 5292 Jun 30  2014 bin/pan-attach-kd
lrwxrwxrwx 1 root root     3 Oct 26  2018 bin/pan.bin -> pan
-rwxr----- 1 x    users 8998 Sep 25  2020 bin/panelhider
lrwxrwxrwx 1 root root     3 Oct 26  2018 bin/pan.test -> pan
lrwxrwxrwx 1 root root     3 Oct 26  2018 bin/pan.text -> pan

(Pan-attach* and panelhider are unrelated, and as can be seen below, there 
are a number of previously useful but now #-commented bits in my pan 
shell-script as well.  FWIW I set PANDIR to the directory containing all 
the instance subdirs in my .bashrc, then as seen use it to set the 
PAN_HOME variable pan actually uses in my wrapper.)

$$ cat bin/pan
#!/bin/bash

me=${0##*/}

# sanity-check how I was called
[[ $me =~ pan.* ]] || {
echo 'ERROR: Must be called as pan[.<type>]'
exit 1
}

# Bug-workaround: if pan reset column sizes...
patch_header_columns() {
local line patch
cd "$PAN_HOME"
for patch in "$PANDIR"/patches/*.patch; do
patch="--silent --force --input=$patch preferences.xml"
patch --dry-run $patch >/dev/null &&
patch $patch
done
}

# Pan likes to lose its customized hotkeys
reset_accels() {
cd "$PANDIR"
cp globals/accels.txt.sorted.jed globals/accels.txt
}

# default type is text
[[ $me = pan ]] && me=pan.text
mytype=${me##*.}

# defaulting to wayland without this, but...
#export GDK_BACKEND=x11

# mask executable
#umask 0137

# each instance has a dedicated partition
# if it's not mounted, error out
trap '' SIGHUP
unset SESSION_MANAGER
direrr='must be a valid read/write/enterable dir.'

[[ -d $PANDIR && -r $PANDIR && -w $PANDIR && -x $PANDIR ]] || {
echo ERROR: \$PANDIR $direrr
exit 10
}
[[ -d $PANDIR/scraps && -r $PANDIR/scraps && -w $PANDIR/scraps && -x 
$PANDIR/scraps ]] || {
echo ERROR: $PANDIR/scraps $direrr
exit 12
}
export PAN_HOME=$PANDIR/$mytype
pancache=$PAN_HOME/article-cache
[[ -d  $pancache && -r $pancache && -w $pancache && -x $pancache ]] || {
echo ERROR: $pancache $direrr
exit 14
}
reset_accels
patch_header_columns
cd "$PANDIR/scraps"
exec /bin/pan "$@"
#exec strace /bin/pan "$@" 2>strace.log         # strace.log in $PANDIR/
scraps


-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


_______________________________________________
Pan-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/pan-users

Reply via email to