Bug 80235

Summary: Want way to find session name from shell
Product: [Applications] konsole Reporter: Rob Sims <robsims>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:

Description Rob Sims 2004-04-23 23:30:23 UTC
Version:            (using KDE KDE 3.2.0)
Installed from:    Debian stable Packages
OS:          Linux

When I log in to KDE, my desktop is restored complete with tab names.  I would like to use those tab names to modify each shell's startup behavior.  I can find the name of all sessions that the parent konsole contains (see below), but can't quite associate the shell with a particular tab.  One possible fix is to add the ability to fetch the shell PID per session vi DCOP.
============================
#!/bin/sh

SHELLPID=`ps -p $$ -l | tail -1 | awk "{ print \\\$5 }"`
KONSPID=`ps -p $SHELLPID -l | tail -1 | awk "{ print \\\$5 }"`

#printf "Shell is $SHELLPID, konsole is $KONSPID\n"

SESSIONS=`dcop konsole-$KONSPID | grep ^session`

for SESSION in $SESSIONS; do
  SNAME=`dcop konsole-$KONSPID $SESSION sessionName`
  # Nice to have:
  # SPID=`dcop konsole-$KONSPID $SESSION sessionPID`
  echo Session $SESSION name is $SNAME
done
Comment 1 Stephan Binner 2004-04-26 21:31:40 UTC
> SHELLPID=`ps -p $$ -l | tail -1 | awk "{ print \\\$5 }"` 
> KONSPID=`ps -p $SHELLPID -l | tail -1 | awk "{ print \\\$5 }"`

This looks bogus, SHELLPID is then PID of Konsole and KONSPID the PID of kdeinit process?

> SESSIONS=`dcop konsole-$KONSPID | grep ^session`

May I simply suggest SESSIONS=`dcop \`dcopclient $KONSOLE_DCOP\` | grep ^session`
Comment 2 Stephan Binner 2004-04-26 21:42:31 UTC
CVS commit by binner: 

Add the ability to fetch the shell PID per session via DCOP
CCMAIL: 80235-done@bugs.kde.org


  M +1 -0      session.h   1.61.2.1
  M +1 -0      sessioniface.h   1.5.2.1


--- kdebase/konsole/konsole/session.h  #1.61:1.61.2.1
@@ -92,4 +92,5 @@ public:
   void renameSession(const QString &name);
   QString sessionName() { return title; }
+  int sessionPID() { return sh->pid(); }
 
   virtual bool processDynamic(const QCString &fun, const QByteArray &data, QCString& replyType, QByteArray &replyData);

--- kdebase/konsole/konsole/sessioniface.h  #1.5:1.5.2.1
@@ -15,4 +15,5 @@ class SessionIface : virtual public DCOP
     virtual void renameSession(const QString &name) =0;
     virtual QString sessionName() =0;
+    virtual int sessionPID() =0;
 };