#! /bin/sh # fancy-xearth --- wrapper to set xearth parameters in pleasing fashion # Author: Noah Friedman # Created: 1996-03-05 # Public domain # $Id: fancy-xearth,v 1.9 2001/03/18 13:41:53 friedman Exp $ # Commentary: # Code: DISPLAY=${DISPLAY-:0.0} export DISPLAY # Calculate relative offset based on the size of the display. { # The -screen argument should limit the output to the current screen if # there is more than one; if the display does not refer to a specific # screen (e.g. set to ":0", then the default screen should be selected. # To get information about a different screen, set DISPLAY to that screen. xrdb_syms="`xrdb -symbols -screen`" sedfilt='s/-D.*// s/[ ][ ]*/ /g s/^ *//g s/ $//g p q' width=`echo "$xrdb_syms" | sed -ne "/-DWIDTH=/!d;s/.*-DWIDTH=//;$sedfilt"` height=`echo "$xrdb_syms" | sed -ne "/-DHEIGHT=/!d;s/.*-DHEIGHT=//;$sedfilt"` } # Set X cursor to resemble star trek enterprise { cursorfile="/tmp/ent-d.xbm$$" maskfile="/tmp/ent-m.xbm$$" trap 'rm -f "$cursorfile" "$maskfile" 2> /dev/null' 0 1 2 3 15 cat > "$cursorfile" <<'__EOF_CURSORFILE__' #define ent_width 24 #define ent_height 24 #define ent_x_hot 21 #define ent_y_hot 0 static char ent_bits[] = { 0x00, 0x00, 0x38, 0x00, 0x00, 0x24, 0x00, 0xc0, 0x23, 0x00, 0x40, 0x10, 0x00, 0x40, 0x08, 0x00, 0x40, 0x04, 0x00, 0x24, 0x02, 0x00, 0x1a, 0x02, 0x00, 0x11, 0x06, 0x80, 0x70, 0x0a, 0x40, 0x48, 0x10, 0x20, 0x28, 0x10, 0x10, 0x10, 0x08, 0x08, 0x03, 0x04, 0x84, 0x04, 0x02, 0x42, 0x04, 0x01, 0x21, 0x82, 0x00, 0x1f, 0x41, 0x00, 0x80, 0x30, 0x00, 0x00, 0x09, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; __EOF_CURSORFILE__ cat > "$maskfile" <<'__EOF_MASKFILE__' #define ent_width 24 #define ent_height 24 #define ent_x_hot -1 #define ent_y_hot -1 static char ent_bits[] = { 0x00, 0x00, 0x38, 0x00, 0x00, 0x3c, 0x00, 0xc0, 0x3f, 0x00, 0xc0, 0x1f, 0x00, 0xc0, 0x0f, 0x00, 0xc0, 0x07, 0x00, 0xe4, 0x03, 0x00, 0xfe, 0x03, 0x00, 0xff, 0x07, 0x80, 0xff, 0x0f, 0xc0, 0xcf, 0x1f, 0xe0, 0xef, 0x1f, 0xf0, 0xff, 0x0f, 0xf8, 0xff, 0x07, 0xfc, 0xfc, 0x03, 0x7e, 0xfc, 0x01, 0x3f, 0xfe, 0x00, 0x1f, 0x7f, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; __EOF_MASKFILE__ xsetroot -cursor "$cursorfile" "$maskfile" rm -f "$cursorfile" "$maskfile" } { case "$1" in xearth | xplanet ) prog=$1; shift ;; * ) prog=xearth if { xplanetbg -version > /dev/null 2>&1; } 2> /dev/null; then prog=xplanet fi ;; esac } case "$prog" in xplanet ) prog=xplanetbg case "$1" in -once ) prog=xplanet shift ;; esac # Assumes display has a 4:3 aspect ratio xpos=`expr $width / 4` ypos=`expr $height / 3` set fnord \ -proj orthographic \ -radius 12 \ -center $xpos,$ypos \ -sunrel 25,35 \ -starfreq .0015 \ -blend \ -mapdir $HOME/etc/images/xplanet \ ${1+"$@"} shift case "$prog" in xplanet ) $prog ${1+"$@"} ;; * ) $prog -wait 3600 -nice 19 ${1+"$@"} > /dev/null 2>&1 0<&1 & ;; esac ;; xearth ) # Run xearth with computed offset and other parameters. # This should background itself unless this script is called with # `-nofork' on the command line. version=`{ xearth -version 2>&1 \ | sed -n -e '/This is xearth version /{s///p;s/\.$//;p;}' } 2> /dev/null` || exit 1 # Align using galactic axis if available. #case "$version" in # 1.0 ) rot=21 ;; # * ) rot=galactic ;; #esac # Actually, I still prefer the traditional rotation. rot=21 xshift=`expr $width / 4` yshift=`expr $height / 6` xearth -nolabel \ -stars \ -onepix \ -nomarkers \ -night 15 \ -wait 3600 \ -nice 19 \ -mag 0.25 \ -shift -$xshift,-$yshift \ -pos sunrel,24.64,41.3 \ -gamma 1.0 \ -rot $rot \ -proj orthographic \ -bigstars 20 \ -fork \ ${1+"$@"} > /dev/null 2>&1 0<&1 ;; esac # fancy-xearth ends here