GiorgosXou / TUIFIManager

A cross-platform terminal-based termux-oriented file manager (and component), meant to be used with a Uni-Curses project or as is.
GNU General Public License v3.0
712 stars 14 forks source link

Shortcut "`ctrl+e` > exit with cd" (non rooted) & command `yd`, not working #121

Open cargilcm opened 4 days ago

cargilcm commented 4 days ago

Specifications

Describe the bug

The top most call in the execution stack is logged below: File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/TUIFIManager/TUItilities.py", line 49, in put_text_back_into_terminal_input_buffer for c in text: ioctl(1, TIOCSTI, c) ^^^^^^^^^^^^^^^^^^^^ PermissionError: [Errno 13] Permission denied

Additional context

I found a SO post that says the process must have root privileges for ioctl tiocsti operations to succeed. It would be nice if the cd path could be assigned to an variable that bash could call ie: bash -c cd $cdpath manually after tuifi exits if ioctl permissions are prohibitive. The error that is thrown by python crashes the terminal tab also so no further text can be displayed when typed after this type of exit. Let me know if you desire to see the whole stack trace from stderr.

Thank you

cargilcm commented 4 days ago

without putting on my code inspector goggles my first guess is that the yd command calls a function that uses tiocsti like the exit with CD operation does

This is a pretty large-size screenshot image, but termux-clipboard-set could be a potential workaround for such a function call in the termux environment depending on what other packages are used and how. I'm glad if I can write some code to this end to help out

Screenshot_20241109-193857

GiorgosXou commented 3 days ago

Thanks for the catch! I forgot to add that, here's the fix: https://github.com/GiorgosXou/TUIFIManager/commit/a4f79922fc9c47ff0d691acfabbab3ea087a6eb2

(Additional info for anyone coming across this issue, you do also need to install this and pkg install termux-api)

GiorgosXou commented 3 days ago

The top most call in the execution stack is logged below: File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/TUIFIManager/TUItilities.py", line 49, in put_text_back_into_terminal_input_buffer for c in text: ioctl(1, TIOCSTI, c) ^^^^^^^^^^^^^^^^^^^^ PermissionError: [Errno 13] Permission denied

Yes, that's a trick only available for root devices, but I just found that it might be possible via this way https://github.com/gokcehan/lf/issues/140#issuecomment-464910159, too. Once I find the time I'll see what I can do, but...

I'm glad if I can write some code to this end to help out

... feel free to do so, if you like.

cargilcm commented 2 days ago

Awesome, I love tuifi and I especially love your passion for programming and keeping others on the up with your attention to their input etc

Thank you, Giorgios, really..as to the lf program's scripts I think this is what can be hoped for alternative to iocntl because I learned to you can't set environment variables that persist beyond the life of the process(& subprocesses) in Python so yes you have to do some bash scripting (and to tweak possibly main.py so that after endwin it prints os.getcwd() or maybe the selected file? I'll upload some code and share what I use for "-last-directory" with the autojump program.

Thank You, Giorgos

GiorgosXou commented 2 days ago

Instaed of tweaking main.py I guess you could replace: https://github.com/GiorgosXou/TUIFIManager/blob/a4f79922fc9c47ff0d691acfabbab3ea087a6eb2/TUIFIManager/__init__.py#L637-L638 from: https://github.com/GiorgosXou/TUIFIManager/blob/a4f79922fc9c47ff0d691acfabbab3ea087a6eb2/TUIFIManager/__init__.py#L636-L642 with what you are trying to do.

GiorgosXou commented 1 day ago

crossreff: https://github.com/GiorgosXou/TUIFIManager/issues/85