Question

What I'm trying to do is make Gedit open a new window then in that new window open a new tab while having Gedit already open. The script I'm writing is a little big, 570 lines, so here is kind of an except of it.

File1="test"
File2="test2"
function Gedit() {
    local newwindow

    if [ "$2" == "yes" ]; then
         newwindow="--new-window"
    fi

    gedit $newwindow $1 & # & is Very Important b/c of KVIrc
}
function FunctionA {
    Gedit $a "yes"
    Gedit $b 
}

FunctionA

I figured out, that it is the ampersand (&) at the end. But as noted, that is very important because when I run my script I run it in KVIrc. If I take out the &, KVIrc waits for Gedit to completely close. I tried using, -s, --name and --sm-client-id with gedit. I tried also using coproc, that really didn't work. Any help would be greatly appreciated. Thank You.

Was it helpful?

Solution

Ok, this is how I solved it:

function OpenWithGedit() {
local newwin=$1
shift
local outfile ofile i
local newwindow

#splits $@ into two parts
ofile=${@:1:$(($#/2))}
outfile=${@:$(($#/2+1)):$#}

if [ "$newwin" == "yes" ]; then
    newwindow="--new-window"
fi 

for i in $outfile
do
    SayE "Gedit" $i #echos $i with some format
done
gedit $newwindow $ofile &
}

The format for this command is as follows:

OpenWithGedit "yes" $File1 $File2 $File3 $File1Out $File2Out $File3Out

where you can have as many $Files you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top