[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Script to Find KDE2
From: Andreas Pour <pour () mieterra ! com>
Date: 2000-10-30 3:39:59
[Download RAW message or body]
Hi,
I have written a little script to find KDE 2. It's easy to add more
search directories and as people report them they should be added. I
think it would be useful to add this script to kdesupport and install it
under /usr/bin or /usr/local/bin (it can't be under the KDE dir since
that largely defeats its purpose).
It is able to find both the global and user KDE directories.
It also has a nice feature to find all KDE dirctories by specifying an
"all" flag, so for example:
findKDE.sh -all
on my system returns:
bin_dir=/opt/kde2/bin
include_dir=/opt/kde2/include
[ ... ]
wallpapers_dir=/opt/kde2/share/wallpapers
or particular directories, so
findKDE.sh -dir bin
returns:
/opt/kde2/bin
or
findKDE.sh -dir applnk -user
returns
/home/pour/.kde/share/applnk
findKDE.sh -help shows the options.
Ciao,
Andreas Pour
http://www.kde.com/ : Everything KDE
http://apps.kde.com/: The Latest in KDE Applications
["findKDE.sh" (application/x-sh)]
#!/bin/bash
#
# This program is public domain, but it's use is conditioned on acceptance
# of the disclaimer below.
#
# THIS SOFTWARE IS PROVIDED TO YOU "AS IS", WITHOUT ANY WARRANTY OR
# GUARANTEE OF ANY KIND. THE AUTHORS AND DISTRIBUTORS OF THIS SOFTWARE
# OR ANY PART THEREOF SPECIFICALLY DISCLAIM ALL WARRANTIES OF ANY
# KIND, EITHER EXPRESSED OR IMPLIED (EITHER IN FACT OR BY LAW),
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY THAT THE SOFTWARE
# OR ANY PART THEREOF IS FREE OF DEFECTS AND THE WARRANTIES OF TITLE
# AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO
# THE QUALITY AND PERFORMANCE OF THE PACKAGE OR ANY PART THEREOF IS
# WITH THE USER. SHOULD ANY PART OF THE SOFTWARE PROVE DEFECTIVE,
# YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
# THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
# looks for KDE installation and/or particular directories
# if called without arguments returns the base KDE directory
# options: see the usage function
SCRIPT="`basename "$0"`"
function usage()
{
cat <<_EOF_
Usage: $SCRIPT [ -all | -dir DIR ] [ -global | -user | -auto | -both ]
Arguments:
-all
all standard KDE directories are returned in the format XX_dir=PATH
-dir
location of directory DIR is located (use -all to see all of them)
-global
returns the global location of the specified directory; this is
the default if none of -global, -user, -auto and -both is used
-user
returns the user location of the specified directory; the user
root cannot use this option (use -auto if not sure)
-both
returns both the user and global locations of the specified
directory
-auto
returns the user location if not running as root and the global
location if running as root
If neither -all and -dir is specified, the base KDE location is
returned
_EOF_
exit
}
ALL=
DIR=
GLOBAL=t
USER=
while test $# -gt 0 ; do
case $1 in
? | -? | --? | h | -h | --h | help | -help | --help)
usage
;;
all | -all | --all)
ALL=t
;;
dir | -dir | --dir)
if test $# -lt 2 ; then
usage
fi
DIR="$2"
shift
;;
global | -global | --global)
;;
user | -user | --user)
USER=t
GLOBAL=
if test `id -u` -eq 0 ; then
usage
fi
;;
both | -both | --both)
USER=t
;;
auto | -auto | --auto)
if test `id -u` -eq 0 ; then
GLOBAL=t
else
USER=t
GLOBAL=
fi
;;
*)
echo "Unrecognized option '$1'"
usage
esac
shift
done
if test "x$ALL" = "x" -a "x$DIR" = "x" ; then
LOC=t
else
LOC=
fi
#echo "GLOBAL=$GLOBAL,USER=$USER,DIR=$DIR,ALL=$ALL"
function findKDEAllDirs()
{
DIR="$1"
echo "bin_dir=$DIR/bin"
if test -d "$DIR/include" -a -e "$DIR/include/kglobal.h" ; then
echo "include_dir=$DIR/include"
fi
if test -d "$DIR/lib" -a \
"x`ls "$DIR/lib/libkdecore.so."* 2>/dev/null`" != "" ; then
echo "lib_dir=$DIR/lib"
fi
if test -d "$DIR/share/icons/hicolor" -a -d "$DIR/share/icons/locolor" ; then
echo "icon_dir=$DIR/share/icons"
fi
for subdir in applnk config fonts locale services sounds toolbar apps doc \
icons mimelnk servicetypes templates wallpapers ; do
if test -d "$DIR/share/$subdir" ; then
echo "${subdir}_dir=$DIR/share/$subdir"
fi
done
}
# locate global KDE
if test "$LOC" = "t" -o "$GLOBAL" = "t" ; then
GDIR=
if which kdeinit > /dev/null 2>& 1 ; then
GDIR="`which kdeinit | sed -e 's@/bin/kdeinit@@'`"
else
for guess in "$KDE2DIR" "`echo "$KDEDIRS" | sed -e s'@:@ @g'`" /opt/kde2 \
/usr /usr/local /usr/share /var/kde2 /ext/kde2 /usr/share \
/opt/kde /var/kde /ext/kde "$KDEDIR" "$HOME" "$HOME/kde2" \
"$HOME/kde" ; do
if test "x$guess" != "x" -a -d "$guess/bin" -a \
-e "$guess/bin/kdeinit" -a -x "$guess/bin/kdeinit" ; then
GDIR="$guess"
break
fi
done
fi
fi
if test "$LOC" = "t" -o "$USER" = "t" ; then
HDIR=
for guess in "$kdehome" "$KDEHOME" "$KDE2HOME" ~/".kde2" ~/".kde" ; do
if test "x$guess" != "x" -a -d "$guess/share/config" -a \
-e "$guess/share/applnk" ; then
HDIR="$guess"
break
fi
done
fi
# report results
if test "$LOC" = "t" ; then
if test "$GLOBAL" = "t" ; then
echo "$GDIR"
fi
if test "$USER" = "t" ; then
echo "$HDIR"
fi
elif test "$ALL" = "t" ; then
if test "$GLOBAL" = "t" ; then
if test "x$GDIR" != "x" ; then
findKDEAllDirs "$GDIR"
fi
fi
if test "$USER" = "t" ; then
if test "x$HDIR" != "x" ; then
findKDEAllDirs "$HDIR"
fi
fi
else # else DIR must be non-empty
what="${DIR}_dir"
if test "$GLOBAL" = "t" ; then
if test "x$GDIR" != "x" ; then
findKDEAllDirs "$GDIR" | grep "$what=" | sed -e "s@$what=@@"
fi
fi
if test "$USER" = "t" ; then
if test "x$HDIR" != "x" ; then
findKDEAllDirs "$HDIR" | grep "$what=" | sed -e "s@$what=@@"
fi
fi
fi
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic