Skip to content

Instantly share code, notes, and snippets.

@dmcbane
Last active August 3, 2019 17:09
Show Gist options
  • Save dmcbane/ebac894bb32630345ad4c917e26b82d3 to your computer and use it in GitHub Desktop.
Save dmcbane/ebac894bb32630345ad4c917e26b82d3 to your computer and use it in GitHub Desktop.
PCGen Linux/MacOS start script modifications
#!/bin/sh
set -e
#### on some installations you may need to change /bin/sh above to /bin/bash
# Adding the following lines, makes the pcgen script work from any directory
############################################################################
rreadlink() (
target=$1 fname= targetDir= CDPATH=
{ \unalias command; \unset -f command; } >/dev/null 2>&1
[ -n "$ZSH_VERSION" ] && options[POSIX_BUILTINS]=on
while :; do
[ -L "$target" ] || [ -e "$target" ] || { command printf '%s\n' "ERROR: '$target' does not exist." >&2; return 1; }
command cd "$(command dirname -- "$target")"
fname=$(command basename -- "$target")
[ "$fname" = '/' ] && fname=''
if [ -L "$fname" ]; then
target=$(command ls -l "$fname")
target=${target#* -> }
continue
fi
break
done
targetDir=$(command pwd -P)
if [ "$fname" = '.' ]; then
command printf '%s\n' "${targetDir%/}"
elif [ "$fname" = '..' ]; then
command printf '%s\n' "$(command dirname -- "${targetDir}")"
else
command printf '%s\n' "${targetDir%/}/$fname"
fi
)
SCRIPTDIR=$(dirname -- "$(rreadlink "$0")")
cd ${SCRIPTDIR}
############################################################################
# Adding the folling if, will create a pcgen desktop file if one does not already exist
#######################################################################################
if [ "$OSTYPE" = "linux-gnu" -a ! -f "$HOME/.local/share/applications/pcgen.desktop" ]; then
echo -e "[Desktop Entry]\nType=Application\nEncoding=UTF-8\nName=PCGen\nuomment=PCGen helps you build characters for role-playing games like Pathfinder and D&D\nTerminal=False\nExec=${SCRIPTDIR}/pcgen.sh\nIcon=${SCRIPTDIR}/docs/images/system/pcgen_small_logo.jpg\n" > "$HOME/.local/share/applications/pcgen.desktop"
update-desktop-database
fi
##### <the following is the remainder of the script> ####
available_memory="unknown"
default_min_memory=256
default_max_memory=512
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment