LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   dcop konsole (https://www.linuxquestions.org/questions/linux-general-1/dcop-konsole-304844/)

bendeco13 03-22-2005 05:11 PM

dcop konsole
 
I'm trying to use a couple of commands to start konsole with a formatted prompt (PS1).
Heres what I have so far:

konsole --script &
dcop konsole-$! session-1 feedSession "PS1='\033[33;1m[\u \w]\$\033[0m '"

This sends the text ["PS1='\033[33;1m[\u \w]\$\033[0m '"] to the session, but I can't figure out how to emulate an enter from the dcop interface (submit the text).

Does anyone know how to do this?

Thanks In Advance
Bendeco

frankmulder 03-23-2005 11:50 AM

You can also edit ~/.bashrc and insert PS1='\033[33;1m[\u \w]\$\033[0m' there, to change your prompt.

But for your problem:
I managed to do your trick by typing konsole --script &
dcop konsole-$! session-1 feedSession "PS1='\033[33;1m[\u \w]\$\033[0m ', then Enter, and then " and again Enter. (So type an Enter before the last quotes)



-Frank

bendeco13 04-12-2005 04:29 AM

I understand how that works and I got mine to do the same thing in a similar fashion. I guess I didn't phrase my question in a clear manor.

My problem is that I don't want to have to hit the enter key, but emulate the same affect that the enter key would provide by passing some command that I don't have knowledge of. This would make it possible to add the command to a script.

Thanks for the reply... I hope this clears up my question.

bendeco13 04-12-2005 04:46 AM

Sorry about the prior reply, but after playing around with it for a little while.
I realized that you're idea is the correct way to do this.
I just had to add the last double quotation mark (") on a new line.

In a script it would look something like this:
Code:

#!/bin/bash
#
TIMEOUT=5
konsole --script &
SESSION=konsole-$!
TEST=`dcop $SESSION 2>&1 | grep "session-1"`
COUNT=0
while [ ! "$TEST" ];
do
  if [ $COUNT == $TIMEOUT ];
  then
      echo "Timed Out."
      exit 1
  fi
  TEST=`dcop $SESSION 2>&1 | grep "session-1"`
  sleep 1
  COUNT=$(($COUNT + 1))
done
dcop konsole-$! session-1 feedSession "PS1='\033[33;1m[\u \w]\$\033[0m '
"

The while loop ensures that the dcop interface is ready to communicate with before the script actually sends commands.

Thanks again Frankmulder


All times are GMT -5. The time now is 04:28 AM.