Edit Links |
Tips /
OpenFileInRunningLyxCategories: Scripts << | Page list | >>Open LyX File in Running InstanceHere's a little script I wrote that some other people may find useful. I got annoyed after a while that, if I double-clicked on a LyX file in my file manager, it would launch a new instance of LyX rather than open the file in the old one. I figured there had to be some way to deal with this problem using lyxpipe, and a little poking around on the wiki led to a solution. Of course, this only works when LyX is run on systems that support lyxpipe. Here is the script: #!/bin/bash FILENAME=$1 # Change the next line if you want a different command to be run LYX='/usr/bin/lyx -geometry 1024x1024+100+100' # Obviously, this line needs to be set to the location of your lyxpipe LYXPIPE="$HOME/.lyx/lyxpipe.in" CMD="file-open" if [ -e $LYXPIPE ]; then echo "LYXCMD:lyx-script:$CMD:$FILENAME" > $LYXPIPE else $LYX "$1" & fi Put this somewhere appropriate, like $HOME/bin or /usr/local/bin. Then use your file manager's file association dialog to associate .lyx files with this script. If you double-click a file, it will now open in your running instance of LyX, if one exists; otherwise, it will open LyX as usual. NOTE: If LyX crashes and leaves the lyxpipe open, then the script will fail silently. If anyone knows how we can ping the LyX server to make sure it's actually running (and do it in bash), I'd love to hear about it.
(Comment: perhaps |