chmln / handlr

A better xdg-utils
MIT License
608 stars 24 forks source link

Bad stdin for text editors like neovim and nano. #34

Closed freed00m closed 3 years ago

freed00m commented 3 years ago

Before dismissing this, with xdg-utils Arch package, the following terminal *.desktop entriy works as expected.

at ~/.local/share/applications/nvim.desktop

[Desktop Entry]
Type=Application
Name=Neovim editor
cat mimeapps.list | grep nvim
application/octet-stream=nvim.desktop;
text/plain=nvim.desktop;
text/markdown=nvim.desktop;
application/x-shellscript=nvim.desktop;
Exec=nvim %F
Terminal=true
NoDisplay=true
Type=Application
Icon=nvim
Categories=Utility;TextEditor

the following

% handlr open simple.txt fails to launch nvim. (nvim is running in the background)

The nvim.desktop entry is matched correctly and used.

cat mimeapps.list | grep nvim
application/octet-stream=nvim.desktop;
text/plain=nvim.desktop;
text/markdown=nvim.desktop;
application/x-shellscript=nvim.desktop;

I am able to launch nvim in separate terminal window

if I change exec

Exec=alacritty -e nvim %F

Then it works and spawns new window with nvim opening the file.

freed00m commented 3 years ago

Every terminal interactive app gets send into the background, that's very unuseable.

Dioprz commented 3 years ago

I have exactly the same problem with nvim and the 'handlr-bin' package from AUR. Is there any other solution to modifying the .desktop file?

freed00m commented 3 years ago

@chmln - I've noticed your comment + commit https://github.com/chmln/handlr/pull/28#issuecomment-748528996

Is this change related? The multiple file detecting happens for all %F and %U detected even though use might want to open a single file and spawnit directly it being send into background.

"I wish I was a Rust programmer", looking at the source and fixing it might take lot of time for me.

@Wisehh - I am not sure, currently i would say no, but maybe there is a way how to TRAP the signal that sends it to background.

chmln commented 3 years ago

@freed00m @Wisehh Thanks for reporting this issue, this is fixed in the latest release. Feel free to re-open if you run into any issues

ghost commented 3 years ago

I am still having this error.. Using the handlr-bin from AUR.

I have ~/local/share/applications/ranger.desktop with:

[Desktop Entry]
Name=ranger
Type=Application
Terminal=true
Exec=ranger %F
MimeType=inode/directory;

And in ~/.config/mimeapps.list:

[Default Applications]
inode/directory=ranger.desktop;

Launching from dmenu works as expected, but from alacritty i get the following:

% handlr open .

Traceback (most recent call last):
  File "/usr/bin/ranger", line 37, in <module>
    sys.exit(ranger.main())  # pylint: disable=no-member
  File "/usr/lib/python3.9/site-packages/ranger/core/main.py", line 231, in main
    fm.ui.destroy()
  File "/usr/lib/python3.9/site-packages/ranger/gui/ui.py", line 178, in destroy
    self.suspend()
  File "/usr/lib/python3.9/site-packages/ranger/gui/ui.py", line 142, in suspend
    curses.nocbreak()
_curses.error: nocbreak() returned ERR

I don't know why but handlr --help gives:

handlr 0.5.0

USAGE:
    handlr <SUBCOMMAND>

Yes I have updated..

Also.. is terminal_emulator = "alacritty -e" in ~/.config/handlr/handlr.toml deprecated now? Because that is what I understand from the README. However if I delete that file, handlr recreate it with terminal_emulator = "xterm -e". So I don't really know if it is.

freed00m commented 3 years ago

@qwuy1290 is right, my AUR index were not updated

ghost commented 3 years ago

The last PKGBUILD uses version 0.6.1.. https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=handlr-bin

% pacman -Qi handlr-bin
Name            : handlr-bin
Version         : 0.6.1-1
Description     : Powerful alternative to xdg-utils written in Rust
.............
freed00m commented 3 years ago

@qwuy1290 I've just tried using LF file manager

 ~/.local/share/applications $ cat lf.desktop
[Desktop Entry]
Type=Application
Name=lf
TryExec=lf
Exec=lf %F
Terminal=true
NoDisplay=true
Type=Application
Icon=org.gnome.Nautilus
MimeType=inode/directory
Categories=System;FileTools;FileManager;ConsoleOnly
Keywords=File;Manager;Management;Explorer;Launcher

And it works as expected :) handlr open . does land me in LF manager.

Must be something on your end or issue with ranger

ghost commented 3 years ago

With your lf.desktop I get

% handlr open .
2021/04/24 15:49:48 initializing screen: input/output error

This is very strange. Which terminal are you using? Also, what version do you see with handlr --help?

freed00m commented 3 years ago

@qwuy1290 not sure, I am not inside any terminal multiplexer usually and in tmux it works :)

Can you detach from screen a run it directly in terminal emulator??

handlr -V
handlr 0.6.1
ghost commented 3 years ago

Ok apparently the file built by github-actions always build the same file (no file version in the filename). Also, in the PKGBUILD no checksum is specified, which doesn't help. paru was not redownloading the binary since previous version was in the cache. I cleared the cache and reinstalled, now it works! Sorry for the mess.