#!/bin/sh # Script to copy Kate files from KDE 3.4.3 to KDE 3.5.x. Gets rid of # the obnoxious newer version of Kate that uses sessions and which never # receives the window focus when used in MDI with the '--use' option. # Using Kate from KDE 3.4.3 also restores Projects for those # who prefer them. # Please do not use this script blindly. Verify and triple verify the # variables and path locations. Understand what the script is modifying. # If uncomfortable with this script then make the system changes manually # as there are not all that many files to copy. # If all goes well then the next time you start Kate you'll see version 2.4.1 # from KDE 3.4.3. The menu bar will show Projects and not the obnoxious Sessions. # Your MRU (Most Recently Used) file list will no longer be controlled by each # session because there are no longer any sessions! The MDI nature of Kate again # works as intended as opening documents in Kate from the command line or # Konqueror always raises Kate to the foreground with Kate receiving the # window focus. # I am NOT a programmer or developer, nor am I intimate with the inner workings # of KDE. I'm not the world's greatest script writer. This solution evolved # from some anger and my stubbornness to restore Kate. Everything works the way # I want and allows me to use the latest version of KDE. To my knowledge this # reversion process works just fine. I have not noticed any bugs or issues. # YMMV. Please let me know if you improve upon this process. # Understand that this is only a workaround solution. With each update to KDE # you need to run this script again. The long-term solution is for stubborn # self-serving KDE developers to restore the behavior of Kate for those people # who do not want to use the new Sessions model and prefer an MDI model that # actually works. # Okay, let's get started. source /etc/functions-colors # Modify this variable to the version of KDE you are using. CRAPPYKATE="3.5.5" # The following location varies by distro and personal usage. # Modify as necessary. # CRAPPYKATEROOT="/opt/kde-$CRAPPYKATE" # CRAPPYKATEROOT="/opt/kde" # CRAPPYKATEROOT="/usr" CRAPPYKATEROOT="$KDEDIR" # This is a directory containing only the Kate 3.4.3 files # Unpack the files that came in a tar.gz package along with this # script to any convenient location. Then modify the following # variable to that location. The parent directory in the tar.gz # package is 'kate-3.4.3'. KATE343DIR="/usr/local/kde-mods/kate-3.4.3" # KATE343DIR="$HOME/tmp/kate-3.4.3" # KATE343DIR="/tmp/kate-3.4.3" # The following directory can be a second separate directory listed # in the environment variable $KDEDIRS, which should not be confused # with the environment variable $KDEDIR (notice the appending 'S'. # If not using a second $KDEDIR directory, the following variable can # be pointed directly to the sole $KDEDIR directory created in kde.sh # location of a second KDE directory: KDEDIRLOCAL="/usr/local/kde-mods" # location of the primary KDE directory: # KDEDIRLOCAL=$KDEDIR MoveTest() # Test whether original_file from version $CRAPPYKATE already exists. If so # then skip moving/renaming the file. The first time this script is run this # creates a backup file and if run thereafter preserves that original copy # of the replaced file. # Normal archiving and backup practices usually append the original file # name with an extension, such as .orig, .bak, etc. However, running # ldconfig will interfere with that plan because ldconfig updates sym links # in an alphabetical manner (this seems to be the case). Thus, for example, # ldconfig will first create the sym links for libkateinterfaces.0.0.0, but # then (alphabetically) next creates the sym links for # libkateinterfaces.0.0.0-$CRAPPYKATE, which leaves some sym links # pointing to the original files rather than the libraries for Kate 2.4.1 # (KDE 3.4.3). Therefore a renaming procedure is needed that does not simply # append the original file. Prefixing the original file name with the version # number succeeds better. Looks goofy but works. # Prefixing the original library file name requires extracting and # separating the file name from the path. Awkward, but doable. { FNAME="`basename $1`" DNAME="`dirname $1`" echo -e "Looking for ${BOLDGREEN}${DNAME}/${CRAPPYKATE}-${FNAME}${COLOR_RESET}" if [ -f "${DNAME}/${CRAPPYKATE}-${FNAME}" ] || [ -L "${DNAME}/${CRAPPYKATE}-${FNAME}" ]; then echo -e "${BOLDGREEN}${CRAPPYKATE}-${FNAME}${COLOR_RESET} already exists." else echo -e "Renaming ${BOLDGREEN}$1${COLOR_RESET} to ${BOLDWHITE}${CRAPPYKATE}-$FNAME${COLOR_RESET}" mv $1 ${DNAME}/${CRAPPYKATE}-${FNAME} fi } # The kate binary file: MoveTest $CRAPPYKATEROOT/bin/kate echo -e "Copying ${BOLDGREEN}$KATE343DIR/bin/kate${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/bin${COLOR_RESET}" cp $KATE343DIR/bin/kate $CRAPPYKATEROOT/bin echo # There are several files in the $KDEDIR/lib directory that are sym links. # They do not need to be modified. They all link to the files being modified # below. In the future should a user want to restore Kate, then # only the following files need be restored and the links will already be # pointing to the correct location. MoveTest $CRAPPYKATEROOT/lib/libkateinterfaces.la echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/libkateinterfaces.la${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib${COLOR_RESET}" cp $KATE343DIR/lib/libkateinterfaces.la $CRAPPYKATEROOT/lib echo MoveTest $CRAPPYKATEROOT/lib/libkateinterfaces.so.0.0.0 cp $KATE343DIR/lib/libkateinterfaces.so.0.0.0 $CRAPPYKATEROOT/lib echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/libkateinterfaces.so.0.0.0${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/libkatepartinterfaces.la cp $KATE343DIR/lib/libkatepartinterfaces.la $CRAPPYKATEROOT/lib echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/libkatepartinterfaces.la${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/libkatepartinterfaces.so.0.0.0 cp $KATE343DIR/lib/libkatepartinterfaces.so.0.0.0 $CRAPPYKATEROOT/lib echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/libkatepartinterfaces.so.0.0.0${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/libkateutils.la cp $KATE343DIR/lib/libkateutils.la $CRAPPYKATEROOT/lib echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/libkateutils.la${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/libkateutils.so.0.0.0 cp $KATE343DIR/lib/libkateutils.so.0.0.0 $CRAPPYKATEROOT/lib echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/libkateutils.so.0.0.0${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/libkdeinit_kate.la cp $KATE343DIR/lib/libkdeinit_kate.la $CRAPPYKATEROOT/lib echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/libkdeinit_kate.la${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/libkdeinit_kate.so.0.0.0 cp $KATE343DIR/lib/libkdeinit_kate.so.0.0.0 $CRAPPYKATEROOT/lib echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/libkdeinit_kate.so${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/kde3/kate.la cp $KATE343DIR/lib/kde3/kate.la $CRAPPYKATEROOT/lib/kde3 echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/kde3/kate.la${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib/kde3${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/kde3/kate.so cp $KATE343DIR/lib/kde3/kate.so $CRAPPYKATEROOT/lib/kde3 echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/kde3/kate.so${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib/kde3${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/kde3/libkatepart.la cp $KATE343DIR/lib/kde3/libkatepart.la $CRAPPYKATEROOT/lib/kde3 echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/kde3/libkatepart.la${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib/kde3${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/lib/kde3/libkatepart.so cp $KATE343DIR/lib/kde3/libkatepart.so $CRAPPYKATEROOT/lib/kde3 echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/kde3/libkatepart.so${COLOR_RESET} to ${BOLDWHITE}$CRAPPYKATEROOT/lib/kde3${COLOR_RESET}" echo # Some additional files # Although any preceding directory in the $KDEDIRS environment variable is # supposed to be dominant, for whatever reason Kate always uses the # ui.rc files from the $KDEDIR directory and then renames the ui.rc # files in the dominant directory to ui.rc.backup. Therefore the easiest # trick is just rename the $KDEDIR ui.rc files so that the dominant # directory is always used and the ui.rc files there are never renamed. # Understand that if you decide not to use a secondary KDE directory, then the # following script instructions will overwrite the existing KDE files. # These ui.rc files control the Kate menu bar. MoveTest $CRAPPYKATEROOT/share/apps/kate/kateui.rc cp -R $KATE343DIR/share/apps/kate $KDEDIRLOCAL/share/apps echo -e "Copying ${BOLDGREEN}$KATE343DIR/share/apps/kate/*/*${COLOR_RESET} to ${BOLDWHITE}$KDEDIRLOCAL/share/apps${COLOR_RESET}" echo MoveTest $CRAPPYKATEROOT/share/apps/katepart/katepartui.rc echo MoveTest $CRAPPYKATEROOT/share/apps/katepart/katepartreadonlyui.rc echo # Although the following line will copy all files in the directory tree, # the katepart syntax highlighting directory in the tar.gz file is # empty. Just use the latest syntax highlighting files in the latest KDE. cp -R $KATE343DIR/share/apps/katepart $KDEDIRLOCAL/share/apps echo -e "Copying ${BOLDGREEN}$KATE343DIR/share/apps/katepart/*/*${COLOR_RESET} to ${BOLDWHITE}$KDEDIRLOCAL/share/apps${COLOR_RESET}" echo # Files to support Kate projects: cp $KATE343DIR/lib/kde3/katedefaultprojectplugin.la $KDEDIRLOCAL/lib/kde3 echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/kde3/katedefaultprojectplugin.la${COLOR_RESET} to ${BOLDWHITE}$KDEDIRLOCAL/lib/kde3${COLOR_RESET}" echo cp $KATE343DIR/lib/kde3/katedefaultprojectplugin.so $KDEDIRLOCAL/lib/kde3 echo -e "Copying ${BOLDGREEN}$KATE343DIR/lib/kde3/katedefaultprojectplugin.so${COLOR_RESET} to ${BOLDWHITE}$KDEDIRLOCAL/lib/kde3${COLOR_RESET}" echo cp $KATE343DIR/share/services/katedefaultproject.desktop $KDEDIRLOCAL/share/services echo -e "Copying ${BOLDGREEN}$KATE343DIR/share/services/katedefaultproject.desktop${COLOR_RESET} to ${BOLDWHITE}$KDEDIRLOCAL/share/services${COLOR_RESET}" echo cp $KATE343DIR/share/servicetypes/kateprojectplugin.desktop $KDEDIRLOCAL/share/servicetypes echo -e "Copying ${BOLDGREEN}$KATE343DIR/share/servicetypes/kateprojectplugin.desktop${COLOR_RESET} to ${BOLDWHITE}$KDEDIRLOCAL/share/servicetypes${COLOR_RESET}" echo cp $KATE343DIR/share/mimelnk/application/x-kate-project.desktop $KDEDIRLOCAL/share/mimelnk/application echo -e "Copying ${BOLDGREEN}$KATE343DIR/share/mimelnk/application/x-kate-project.desktop${COLOR_RESET} to ${BOLDWHITE}$KDEDIRLOCAL/share/mimelnk/application${COLOR_RESET}" echo # Hopefully all went well! echo "That should be all of them!" echo echo "Be sure to edit $KDEDIR[LOCAL]/share/applications/kde/kate.desktop" echo "to remove the '--use' syntax."