# Konsole tab renaming. Courtesy of Sebastian Kuegler
# http://vizzzion.org/?blogentry=737
-if [ "$KONSOLE_DCOP_SESSION" ]
+if [ -n "$KONSOLE_DCOP_SESSION" -o -n "$KONSOLE_DBUS_SESSION" ]
then
if [ `/usr/bin/whoami` != 'root' ]
then
# Change konsole tab to current path
konsole-rename-path () {
- if [ "$KONSOLE_DCOP_SESSION" ]
+ if [ -n "$KONSOLE_DCOP_SESSION" -o -n "$KONSOLE_DBUS_SESSION" ]
then
local DIR
DIR=${PWD/#${HOME}/\~}
else
SDIR="$DIR"
fi
- dcop ${KONSOLE_DCOP_SESSION} renameSession "$SDIR"
+ if [ -n "$KONSOLE_DCOP_SESSION" ]
+ then
+ dcop ${KONSOLE_DCOP_SESSION} renameSession "$SDIR"
+ elif [ -n "$KONSOLE_DBUS_SESSION" ]
+ then
+ qdbus org.kde.konsole ${KONSOLE_DBUS_SESSION} setTitle 0 "$SDIR" > /dev/null
+ qdbus org.kde.konsole ${KONSOLE_DBUS_SESSION} setTitle 1 "$SDIR" > /dev/null
+ fi
fi
}
# Change konsole tab to current command
konsole-rename-cmd () {
- if [ "$KONSOLE_DCOP_SESSION" ]
+ if [ -n "$KONSOLE_DCOP_SESSION" -o -n "$KONSOLE_DBUS_SESSION" ]
then
# We don't need to change tab to "cd xyz" or precmd redefinition
# Yes, this is a dirty hack
else
TXT="$1"
fi
- dcop ${KONSOLE_DCOP_SESSION} renameSession "$TXT"
+ if [ -n "$KONSOLE_DCOP_SESSION" ]
+ then
+ dcop ${KONSOLE_DCOP_SESSION} renameSession "$TXT"
+ elif [ -n "$KONSOLE_DBUS_SESSION" ]
+ then
+ qdbus org.kde.konsole ${KONSOLE_DBUS_SESSION} setTitle 0 "$TXT" > /dev/null
+ qdbus org.kde.konsole ${KONSOLE_DBUS_SESSION} setTitle 1 "$TXT" > /dev/null
+ fi
fi
fi
}
cmd=`basename $0`
args=$@
lastarg="${args[(w)-1]}"
-dcop ${KONSOLE_DCOP_SESSION} renameSession "$lastarg"
+if [ -n "$KONSOLE_DCOP_SESSION" ]
+then
+ dcop ${KONSOLE_DCOP_SESSION} renameSession "$lastarg"
+elif [ -n "$KONSOLE_DBUS_SESSION" ]
+then
+ qdbus org.kde.konsole ${KONSOLE_DBUS_SESSION} setTitle 0 "$lastarg" > /dev/null
+ qdbus org.kde.konsole ${KONSOLE_DBUS_SESSION} setTitle 1 "$lastarg" > /dev/null
+fi
exec $cmd "$@"