The updated scripts seems to be working for me as well. It uses 'uxterm',
which I never even knew I had installed!

I agree that an optional setting for the terminal would be a good idea.

J^n

On Tuesday, February 21, 2023 at 12:30:14 AM UTC [email protected] wrote:

> That's a good idea!  I think a setting would be the Leonine way to do it.  
> When I convert this into a Leo command, I'll look at making it happen.
>
> On Monday, February 20, 2023 at 7:06:26 PM UTC-5 SegundoBob wrote:
>
>> Thomas Passin,
>>
>> Your fix passes all my tests.
>>
>> You say that you may not always be able to find the terminal program the 
>> user wants you to use.  Maybe when you fail to find any suitable terminal 
>> program, you should report this to the user and ask him to enter the 
>> pathname to the terminal program he wants you to use always.  You should 
>> save it so he only has to do this once.  Maybe even when you can find a 
>> suitable terminal program, there should be a way for the user to tell you 
>> to use the terminal program he wants you to use.
>>
>> Regards,
>> SegundoBob
>> On Monday, February 20, 2023 at 2:58:11 PM UTC-8 [email protected] wrote:
>>
>>> @mike, that was a good diagnosis.  When Leo is not run from a terminal 
>>> (in Linux), the process space does not include a terminal and the shell may 
>>> not even be the same shell (e.g., *sh* instead of *bash*) as one might 
>>> expect.
>>>
>>> I have revised the terminal-finding code for Linux to try several 
>>> heuristics, starting with the same one as @SegundoBob tried.  After failing 
>>> that, it looks in /usr/bin and /bin for a name starting with either 
>>> **-terminal* or **term*.  That will find, e.g., *gnome-terminal, 
>>> xfce-terminal, *or *uxterm*. Failing that, it looks for *xterm* using 
>>> *shutil.which()*.  If none of them can be found, the script exits with 
>>> an error message.
>>>
>>> The reason for all this is that 1) a distro might not even have *xterm* 
>>> (I've seen it), *x-terminal-emulator*,  or *xdg-terminal* (or if it has 
>>> them, they don't always open right), and 2) the terminal program or link 
>>> might not be in /usr/bin or /bin.
>>>
>>> This is still not guaranteed to succeed, since it won't find, e.g., 
>>> *konsole*.  I may hard-code a few more well-known names but there are 
>>> so many possibilities that you can't be sure you can handle every variation 
>>> out there.  I haven't so far found a more general solution on the 
>>> internet.  There ought to be a way because the OS knows what terminal to 
>>> launch by default.  There just doesn't seem to be a standardized way to 
>>> find out from Python - as opposed to clicking on "About" in a terminal.
>>>
>>> The attached outline has the new version, which succeeds on all the 
>>> several distros I've tried even when Leo is not launched from a terminal.  
>>> Please try it out!
>>>
>>> On Sunday, February 19, 2023 at 8:02:47 PM UTC-5 [email protected] wrote:
>>>
>>>>
>>>>
>>>> On Sun, Feb 19, 2023, 17:02 SegundoBob <[email protected]> wrote:
>>>>
>>>>> Your "Execute script" code works well for me when I use it from a 
>>>>> Leo-Editor file that I open from a terminal, but it does not work when I 
>>>>> use the file browser Thunar to open the Leo-editor file.
>>>>>
>>>>> When I invoke your script from a Leo-Editor file opened by Thunar, I 
>>>>> get this error message even when the script is not a Bash script:
>>>>>
>>>>
>>>> My first feeling here is that there are some commands or variables that 
>>>> would be populated in an interactive shell session's environment but do 
>>>> not 
>>>> exist in a non-interactive shell session.
>>>>
>>>> I will take time tonight to try this out myself. I haven't had a need 
>>>> to use Leo in a long time but to help debug this issue I will make that 
>>>> change.   I'm not great at Python, but I do understand some of the 
>>>> complexities of making things work on Linux. 
>>>>
>>>> Mike
>>>>
>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/6d6dbd34-865c-4248-9981-dd52888982f4n%40googlegroups.com.

Reply via email to