Reputation: 3824
I put LightTable in /opt/LightTable
By default, when you install the text editor LightTable in ubuntu 14.04 64 bits, you don't have an "open with LightTable" when you right-click the file you want to open with it.
Therefore I created a file /home/theuser/.local/share/applications/LightTable.desktop containing :
[Desktop Entry]
Name=LighTable Text Editor
Comment=Edit text files
Exec=/opt/LightTable/LightTable %f
Terminal=false
Type=Application
Icon=/opt/LightTable/core/img/lticon.png
Categories=Utility;TextEditor;
StartupNotify=true
MimeType=text/plain
so that a "open with LightTable" appears when I want open a file with LighTable. Now, the problems begin. When I do this, it only opens LightTable, as if I only ran the script
/opt/LightTable/LightTable
Therefore I went to see the script :
#!/bin/bash
BIN=ltbin
HERE=`dirname $(readlink -f $0)`
LIBUDEV_0=libudev.so.0
LIBUDEV_1=libudev.so.1
add_udev_symlinks() {
# 64-bit specific; look for libudev.so.0, and if that can't be
# found link it to libudev.so.1
FOLDERS="/lib64 /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib /lib"
for folder in $FOLDERS; do
if [ -f "${folder}/${LIBUDEV_0}" ]; then
return 0
fi
done
for folder in $FOLDERS; do
if [ -f "${folder}/${LIBUDEV_1}" ]; then
ln -snf "${folder}/${LIBUDEV_1}" "${HERE}/${LIBUDEV_0}"
return 0
fi
done
echo "${LIBUDEV_0} or ${LIBUDEV_1} not found in any of ${FOLDERS}".
exit 1
}
add_udev_symlinks
ARGS="$@"
CORRECTED=${ARGS//-/<d>}
CORRECTED=${CORRECTED// /<s>}
if [ -t 0 ] && [ $# != 0 ]; then
#We're in a terminal...
LD_LIBRARY_PATH="$HERE:$LD_LIBRARY_PATH" $HERE/$BIN "<d><d>dir=`pwd`<s>$CORRECTED" &
else
#We were double clicked
LD_LIBRARY_PATH="$HERE:$LD_LIBRARY_PATH" $HERE/$BIN &
fi
and replaced its ending if/else/fi by a simple :
LD_LIBRARY_PATH="$HERE:$LD_LIBRARY_PATH" $HERE/$BIN "<d><d>dir=`pwd`<s>$CORRECTED" &
so that the right behaviour (the one when opening a file from the terminal) is chosen.
This almost made my day. Now, if I double-click a file or right-click it and select "open with LightTable", the file is indeed opened in LightTable... but : this is true only if the file name and the path to the file have no blank space in their names.
If the file named "the file" is in the path thepath without space in it, when I double-click it, it opens two blank files "the" and "file" in LightTable. The same behavior is constated if thepath has space(s) in it.
Would someone have an idea ? I guess I should correct the bash script, but I'm not an expert in it. (I am not even sure that the script is really wrong...)
Thanks in advance
MEF
Upvotes: 1
Views: 580
Reputation: 2043
Actually, this is a bug in LightTable.
I opened an issue (https://github.com/LightTable/LightTable/issues/1762) and submitted a patch (https://github.com/LightTable/LightTable/pull/1763) to fix this :
There are 2 issues here:
- currently the deployed Bash script doesn't pass any arguments to LightTable if it's not invoked from a terminal, but this is needed e.g. to make a gnome desktop shortcut. This issue can also be reproduced by using the ALT+F2 launcher under Ubuntu.
- independently LightTable cannot currently open files whose names contain ' ' characters.
Upvotes: 0
Reputation: 246837
Your question has a tl;dr quality about it.
When you store "$@"
in a variable, you really have to use an array and lots of quotes to preserve the elements with whitespace:
ARGS=("$@")
CORRECTED=("${ARGS[@]//-/<d>}")
CORRECTED=("${CORRECTED[@]// /<s>}")
But then the way you have to pass the args is a problem:
LD_LIBRARY_PATH="$HERE:$LD_LIBRARY_PATH" $HERE/$BIN "<d><d>dir=`pwd`<s>$CORRECTED" &
It's impossible to expand the array into a single space-delimited string and then somehow extract the elements that have significant whitespace. You may have to do this, and see if it works:
export LD_LIBRARY_PATH="$HERE:$LD_LIBRARY_PATH" # might as well put on own line
"$HERE/$BIN" "<d><d>dir=`pwd`<s>" "${CORRECTED[@]}" &
# ...........^^^^^^^^^^^^^^^^^^^^ standalone argument
Upvotes: 0