Skip to content

Commit

Permalink
Use a script to start x11iraf apps
Browse files Browse the repository at this point in the history
The script was taken from NOIRLabs distribution and heavily adjusted
  • Loading branch information
olebole committed Mar 21, 2024
1 parent 05d9db1 commit 2046795
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ x11iraf.pkg: core.pkg
$(MAKE) -C $(BUILDDIR)/x11iraf

mkdir -p $(INSTDIR)/x11/XGTerm.app/Contents/MacOS
mkdir -p $(INSTDIR)/x11/XGTerm.app/Contents/Resources/bin
mkdir -p $(INSTDIR)/x11/XGTerm.app/Contents/Resources/man
mkdir -p $(INSTDIR)/x11/XGTerm.app/Contents/Resources/terminfo
install -m755 $(BUILDDIR)/x11iraf/xgterm/xgterm \
$(INSTDIR)/x11/XGTerm.app/Contents/MacOS
$(INSTDIR)/x11/XGTerm.app/Contents/Resources/bin
install -m755 apps/XGTerm $(INSTDIR)/x11/XGTerm.app/Contents/MacOS
install apps/xgterm.plist $(INSTDIR)/x11/XGTerm.app/Contents/Info.plist
iconutil --convert icns --output $(INSTDIR)/x11/XGTerm.app/Contents/Resources/XGTerm.icns apps/XGTerm.iconset/
install $(BUILDDIR)/x11iraf/xgterm/xgterm.man \
Expand All @@ -82,9 +84,11 @@ x11iraf.pkg: core.pkg
codesign -s - -i community.iraf.xgterm $(INSTDIR)/x11/XGTerm.app

mkdir -p $(INSTDIR)/x11/XImtool.app/Contents/MacOS
mkdir -p $(INSTDIR)/x11/XImtool.app/Contents/Resources/bin
mkdir -p $(INSTDIR)/x11/XImtool.app/Contents/Resources/man
install -m755 apps/XImtool $(INSTDIR)/x11/XImtool.app/Contents/MacOS
install -m755 $(BUILDDIR)/x11iraf/ximtool/ximtool \
$(INSTDIR)/x11/XImtool.app/Contents/MacOS
$(INSTDIR)/x11/XImtool.app/Contents/Resources/bin
install -m755 $(BUILDDIR)/x11iraf/ximtool/clients/ism_wcspix.e \
$(INSTDIR)/x11/XImtool.app/Contents/Resources
install apps/ximtool.plist $(INSTDIR)/x11/XImtool.app/Contents/Info.plist
Expand Down
36 changes: 36 additions & 0 deletions apps/XGTerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
#
# XGTerm.app start script
#
# Based on a script that is
# Copyright(c) 2023 Association of Universities for Research in Astronomy Inc.

set -e

SCRIPT_DIR=$(dirname -- "${0}")
CONTENT_DIR=$(dirname -- "${SCRIPT_DIR}")
RESOURCES_DIR=$(dirname -- "${SCRIPT_DIR}")/Resources
APP_DIR=$(dirname -- "${CONTENT_DIR}")
APP_NAME=$(echo $(basename -- "$APP_DIR") | sed 's/\.app$//')

# First check whether XQuartz is already running, If not, start it.
xpid=`ps -efw | egrep -e "startx" | egrep -v grep | awk '{printf("%s",$2)}'| wc -c`
if [ $xpid == 0 ]; then
if test -d /Applications/Utilities/XQuartz.app; then
# XQuartz application directory.
open -a XQuartz
elif test -f /opt/X11/bin/Xquartz; then
# Homebrew installation directory.
/opt/X11/bin/Xquartz
else
# Throw a popup that X11 couldn't be found.
osascript -e "display dialog \"ERROR: XQuartz required but not found. Please install before running ${APP_NAME}\""
exit 1
fi
sleep 2 # Wait for it to start.
fi

cd "${HOME}"
export TERMINFO=${RESOURCES_DIR}/terminfo
export DISPLAY=:0
${RESOURCES_DIR}/bin/xgterm -title "${APP_NAME}" -ls &
35 changes: 35 additions & 0 deletions apps/XImtool
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh
#
# XImtool.app start script
#
# Based on a script that is
# Copyright(c) 2023 Association of Universities for Research in Astronomy Inc.

set -e

SCRIPT_DIR=$(dirname -- "${0}")
CONTENT_DIR=$(dirname -- "${SCRIPT_DIR}")
RESOURCES_DIR=$(dirname -- "${SCRIPT_DIR}")/Resources
APP_DIR=$(dirname -- "${CONTENT_DIR}")
APP_NAME=$(echo $(basename -- "$APP_DIR") | sed 's/\.app$//')

# First check whether XQuartz is already running, If not, start it.
xpid=`ps -efw | egrep -e "startx" | egrep -v grep | awk '{printf("%s",$2)}'| wc -c`
if [ $xpid == 0 ]; then
if test -d /Applications/Utilities/XQuartz.app; then
# XQuartz application directory.
open -a XQuartz
elif test -f /opt/X11/bin/Xquartz; then
# Homebrew installation directory.
/opt/X11/bin/Xquartz
else
# Throw a popup that X11 couldn't be found.
osascript -e "display dialog \"ERROR: XQuartz required but not found. Please install before running ${APP_NAME}\""
exit 1
fi
sleep 2 # Wait for it to start.
fi

cd "${HOME}"
export DISPLAY=:0
${RESOURCES_DIR}/bin/ximtool &
2 changes: 1 addition & 1 deletion apps/xgterm.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<key>CFBundleIconFile</key>
<string>XGTerm.icns</string>
<key>CFBundleExecutable</key>
<string>xgterm</string>
<string>XGTerm</string>
<key>LSEnvironment</key>
<dict>
<key>LC_CTYPE</key>
Expand Down
2 changes: 1 addition & 1 deletion apps/ximtool.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<key>CFBundleIconFile</key>
<string>XImtool.icns</string>
<key>CFBundleExecutable</key>
<string>ximtool</string>
<string>XImtool</string>
<key>LSEnvironment</key>
<dict>
<key>LC_CTYPE</key>
Expand Down

0 comments on commit 2046795

Please sign in to comment.