From d1c121b2e39d2d070aac21cc954be065662c2616 Mon Sep 17 00:00:00 2001 From: Amand Tihon Date: Sat, 27 Mar 2010 10:03:03 +0100 Subject: [PATCH] Tabs renaming for konsole/kde4 --- S50_aliases | 2 +- S61_konsoletabs | 22 ++++++++++++++++++---- wrappers/konsoleautowrap | 9 ++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/S50_aliases b/S50_aliases index a42c3f7..6e825dc 100644 --- a/S50_aliases +++ b/S50_aliases @@ -55,7 +55,7 @@ alias scr='screen -rd' # 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 diff --git a/S61_konsoletabs b/S61_konsoletabs index 8af1f11..e93f389 100644 --- a/S61_konsoletabs +++ b/S61_konsoletabs @@ -2,7 +2,7 @@ # 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}/\~} @@ -13,13 +13,20 @@ konsole-rename-path () { 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 @@ -33,7 +40,14 @@ konsole-rename-cmd () { 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 } diff --git a/wrappers/konsoleautowrap b/wrappers/konsoleautowrap index de72cfd..78ebd5a 100755 --- a/wrappers/konsoleautowrap +++ b/wrappers/konsoleautowrap @@ -5,6 +5,13 @@ typeset -a args 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 "$@" -- 2.39.5