Archive for May, 2010

Determining the base directory of a bash script

Sunday, May 9th, 2010

While writing bash scripts, I find it a good idea to put reusable functions into their own scripts and then source them into other scripts.

This means that one must use the source /file/to/source call to load these files. To be able to do this, the bash script must know where the scripts to source are. To not have to hardwire this into the script, I just have the requirement, that the script must be in the same directory as the script itself.

The following code shows how one can find the base directory, with out using any external commands and it should work with out regards to how the script is called:

SCRIPT_NAME="${0##*/}"
SCRIPT_DIR="${0%/*}"

# if the script was started from the base directory, then the
# expansion returns a period
if test "$SCRIPT_DIR" == "." ; then
  SCRIPT_DIR="$PWD"
# if the script was not called with an absolute path, then we need to add the
# current working directory to the relative path of the script
elif test "${SCRIPT_DIR:0:1}" != "/" ; then
  SCRIPT_DIR="$PWD/$SCRIPT_DIR"
fi

# now we can source our other scripts
source $SCRIPT_DIR/logger.sh

Ubuntu 10.04 and Lucid Lynx: No icons in menu or buttons

Thursday, May 6th, 2010

For the Ubuntu 10.04 Lucid Lynx, the developers decided to remove the Interface tab in System -> Preferences -> Appearance.

What made them do that I can not fathom. Yet there is (still) an option to put the icons back.

You can put it back for all new users by adding the following two lines to /usr/share/gconf/defaults/10_libgnome2-common:

/desktop/gnome/interface/menus_have_icons       true
/desktop/gnome/interface/buttons_have_icons      true

And you can activate it again for your current user by using these two commands:

gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons        true
gconftool-2 --type bool --set /desktop/gnome/interface/buttons_have_icons       true

I just really hope support for this isn’t removed altogether in new Gnome versions

Courtesy of the following two ubuntu forum threads:
No icons in context menu for 9.10
GTK menus missing icons