]> git.alrj.org Git - zsh.d.git/blobdiff - S61_konsoletabs
Correct Konsole tab renaming
[zsh.d.git] / S61_konsoletabs
index 7488e06895eb3f52c3978743a7f7a9c3295673c0..58dbb9fdde8f5a82ed2c0d61190bdcf3b318b9dd 100644 (file)
@@ -2,17 +2,31 @@
 
 # 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}/\~}
-        dcop ${KONSOLE_DCOP_SESSION} renameSession "$DIR"
+        SDIR="${DIR[-28,-1]}"
+        if [[ "$SDIR" != "$DIR" ]]
+        then
+           SDIR="...${DIR[-25,-1]}"
+        else
+           SDIR="$DIR"
+        fi
+        if [ -n "$KONSOLE_DCOP_SESSION" ]
+        then
+          dcop ${KONSOLE_DCOP_SESSION} renameSession "$SDIR"
+        elif [ -n "$KONSOLE_DBUS_SESSION" ]
+        then
+          qdbus ${KONSOLE_DBUS_SERVICE} ${KONSOLE_DBUS_SESSION} setTitle 0 "$SDIR" > /dev/null 2>&1
+          qdbus ${KONSOLE_DBUS_SERVICE} ${KONSOLE_DBUS_SESSION} setTitle 1 "$SDIR" > /dev/null 2>&1
+        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
@@ -26,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 ${KONSOLE_DBUS_SERVICE} ${KONSOLE_DBUS_SESSION} setTitle 0 "$TXT" > /dev/null 2>&1
+              qdbus ${KONSOLE_DBUS_SERVICE} ${KONSOLE_DBUS_SESSION} setTitle 1 "$TXT" > /dev/null 2>&1
+            fi
         fi
     fi
 }