#!/bin/bash
#
# This is not the original gnome2-session but a startscript
# to install some preconfiguration for GNOME2
# and some variables to check.
#
# Send feedback to feedback@suse.de
#
#
# Set the path where GNOME2 is installed here. On SuSE
# this is /opt/gnome2
GNOMEPATH=/opt/gnome2
#
# Help GNOME2 guessing where KDE resides on the filesystem
export KDEDIR=/opt/kde3
#
#
#
# Do you want GDK to use XFT? Most probably yes.
export GDK_USE_XFT=1
#
#
# If gconfd 1 is still running, shut it down now
if [ -e /opt/gnome/bin/gconftool-1 ]
then
/opt/gnome/bin/gconftool-1 --shutdown
fi
#
#
# expand LD_LIBRARY_PATH to make sure GNOME2 libs can be reached
export LD_LIBRARY_PATH=$GNOMEPATH/lib:$LD_LIBRARY_PATH
#
#
# make sure that .gnome exists in users home directory
# as it is needed by gnome-vfs2
mkdir -p ~/.gnome
# make sure .skel is available
mkdir -p $HOME/.skel
# set a background until the gnome-session becomes visible
xsetroot -cursor_name watch -solid "#336633"
#
#
# use_gnome2_default: if the default preconfiguration is used,
# some modifications need to be done to setup correct wallpapers
#
function use_gnome2_default {
# do this only one time
[ -e $HOME/.skel/gnome2-run ] && return
# and only if no wallpaper is already set (or other background
# option)
[ -e $HOME/.gconf/desktop/gnome/background/%gconf.xml ] && return
mkdir -p ~/.gconf/desktop/gnome/background
# determine X-Resolution
X=$(xdpyinfo |grep dimensions:|cut -d " " -f 7 |cut -d "x" -f 1)
# if no config fits, use 1024x768
GNOME_WALLPAPER="dist-Desktop_1024.png"
[ $X -gt 799 ] && GNOME_WALLPAPER="dist-Desktop_800.png"
[ $X -gt 1023 ] && GNOME_WALLPAPER="dist-Desktop_1024.png"
[ $X -gt 1151 ] && GNOME_WALLPAPER="dist-Desktop_1152.png"
[ $X -gt 1279 ] && GNOME_WALLPAPER="dist-Desktop_1280.png"
[ $X -gt 1399 ] && GNOME_WALLPAPER="dist-Desktop_1400.png"
[ $X -gt 1599 ] && GNOME_WALLPAPER="dist-Desktop_1600.png"
GNOME_WALLPAPER="/opt/gnome2/share/dist/wallpapers/"$GNOME_WALLPAPER
# check if a wallpaper is actually available
if [ -e $GNOME_WALLPAPER ] ; then
echo 'WALLPAPERstretched' > ~/.gconf/desktop/gnome/background/%gconf.xml
sed -e "s|setup|$USER|g" ~/.gconf/desktop/gnome/background/%gconf.xml > ~/.skel/temp.xml
mv ~/.skel/temp.xml ~/.gconf/desktop/gnome/background/%gconf.xml
sed -e "s|WALLPAPER|$GNOME_WALLPAPER|g" ~/.gconf/desktop/gnome/background/%gconf.xml > ~/.skel/temp.xml
mv ~/.skel/temp.xml ~/.gconf/desktop/gnome/background/%gconf.xml
fi
# use a better adapted font size for specific resolutions
mkdir -p ~/.gconf/desktop/gnome/interface
[ $X -gt 1280 ] && SIZE=3
[ $X -gt 1023 ] && RESOLUTION=".1024"
[ $X -gt 800 ] && WEB_FONT_SIZE=0
DPY="`LANG=C xdpyinfo | sed -n -e '/resolution/ s,.*resolution: *\([^x]*\)x\([^ ]*\) .*,\1 + \2,p'|head -1`"
[ "$DPY" == " + " ] && DPY="75" \
|| DPY="$(( ( $DPY ) /2 ))"
FONT="$(( ( 10 * 92 ) / $DPY ))"
FONT="Sans "$FONT
echo 'FONTSIZE' > ~/.gconf/desktop/gnome/interface/%gconf.xml
sed -e "s|setup|$USER|g" ~/.gconf/desktop/gnome/interface/%gconf.xml > ~/.skel/temp.xml
mv ~/.skel/temp.xml ~/.gconf/desktop/gnome/interface/%gconf.xml
sed -e "s|FONTSIZE|$FONT|g" ~/.gconf/desktop/gnome/interface/%gconf.xml > ~/.skel/temp.xml
mv ~/.skel/temp.xml ~/.gconf/desktop/gnome/interface/%gconf.xml
# we are done, set the flag
touch ~/.skel/gnome2-run
}
# start up the gnome2 session
use_gnome2_default
exec $GNOMEPATH/bin/gnome-session