More precise identification of the lyx window (by id, instead of the buggy by title).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37410 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Tommaso Cucinotta 2011-02-01 22:57:10 +00:00
parent 82aa99f551
commit ac7572f366
2 changed files with 12 additions and 9 deletions

View File

@ -224,7 +224,7 @@ def RaiseWindow():
#os.system("echo x-session-manager open files: `lsof -p $X_PID | grep ICE-unix | wc -l`") #os.system("echo x-session-manager open files: `lsof -p $X_PID | grep ICE-unix | wc -l`")
####os.system("wmctrl -l | ( grep '"+lyx_window_name+"' || ( killall lyx ; sleep 1 ; killall -9 lyx ))") ####os.system("wmctrl -l | ( grep '"+lyx_window_name+"' || ( killall lyx ; sleep 1 ; killall -9 lyx ))")
#os.system("wmctrl -R '"+lyx_window_name+"' ;sleep 0.1") #os.system("wmctrl -R '"+lyx_window_name+"' ;sleep 0.1")
system_retry(30, "wmctrl -R '"+lyx_window_name+"'") system_retry(30, "wmctrl -a '"+lyx_window_name+"'")
lyx_pid = os.environ.get('LYX_PID') lyx_pid = os.environ.get('LYX_PID')
@ -274,7 +274,7 @@ else:
outfile = open(outfilename, 'w') outfile = open(outfilename, 'w')
if lyx_pid != "": if not lyx_pid is None:
RaiseWindow() RaiseWindow()
sendKeystring("\Afn", lyx_pid) sendKeystring("\Afn", lyx_pid)
@ -298,6 +298,8 @@ while not failed:
if lyx_pid != "": if lyx_pid != "":
print "Found running instance(s) of LyX: " + lyx_pid + ": killing them all\n" print "Found running instance(s) of LyX: " + lyx_pid + ": killing them all\n"
os.system("killall lyx") os.system("killall lyx")
time.sleep(0.5)
os.system("killall -KILL lyx")
time.sleep(0.2) time.sleep(0.2)
print "Starting LyX . . ." print "Starting LyX . . ."
if lyx_userdir is None: if lyx_userdir is None:
@ -306,6 +308,7 @@ while not failed:
os.system(lyx_exe + " -userdir " + lyx_userdir + " " + c[9:] + "&") os.system(lyx_exe + " -userdir " + lyx_userdir + " " + c[9:] + "&")
while True: while True:
lyx_pid=os.popen("pidof lyx").read().rstrip() lyx_pid=os.popen("pidof lyx").read().rstrip()
if lyx_pid != "":
lyx_window_name=os.popen("wmctrl -l -p | grep ' " + str(lyx_pid) + " ' | cut -d ' ' -f 1").read().rstrip() lyx_window_name=os.popen("wmctrl -l -p | grep ' " + str(lyx_pid) + " ' | cut -d ' ' -f 1").read().rstrip()
if lyx_window_name != "": if lyx_window_name != "":
break break
@ -314,9 +317,6 @@ while not failed:
time.sleep(1) time.sleep(1)
print 'lyx_pid: ' + lyx_pid + '\n' print 'lyx_pid: ' + lyx_pid + '\n'
print 'lyx_win: ' + lyx_window_name + '\n' print 'lyx_win: ' + lyx_window_name + '\n'
time.sleep(1)
#RaiseWindow()
#sendKeystring("\Afn", lyx_pid)
elif c[0:5] == 'Sleep': elif c[0:5] == 'Sleep':
print "\nSleeping for " + c[6:] + "\n" print "\nSleeping for " + c[6:] + "\n"
time.sleep(float(c[6:])) time.sleep(float(c[6:]))

View File

@ -16,7 +16,10 @@ if [ "$1" != "" ]; then
fi fi
export MAX_DROP=0 export MAX_DROP=0
export LYX_WINDOW_NAME=$(wmctrl -l | grep -v Mozilla | grep -v Firefox | grep LyX | sed -e 's/.*\(LyX: .*\)$/\1/') if [ "$(pidof lyx)" != "" ]; then
export LYX_PID=$(pidof lyx)
export LYX_WINDOW_NAME=$(wmctrl -l | grep " $LYX_PID " | cut -d ' ' -f 1);
fi
export MAX_LOOPS=1 export MAX_LOOPS=1
export LYX_EXE=${LYX_EXE:-../../src/lyx} export LYX_EXE=${LYX_EXE:-../../src/lyx}