NikitaIvanovV / ctpv

Image previews for lf file manager
https://www.nikitaivanov.com/man1/ctpv
MIT License
264 stars 23 forks source link

slow preview cleaning after quit #64

Open NotMurPh opened 1 year ago

NotMurPh commented 1 year ago

hey so there is this issue that when you close lf using q keymap which defaults to quit, the preview lingers for too much time after the exit

video preview showcasing the problem : https://i.imgur.com/2gBZaxg.mp4

some system information : os : archlinux ctpv version from aur(yay) : local/ctpv-git r257.930535c-1 lf config files : https://github.com/NotMurPh/DotFiles/tree/main/StarryNight/home/murphy/.config/lf ctpv config files : https://github.com/NotMurPh/DotFiles/tree/main/StarryNight/home/murphy/.config/ctpv zshrc file contaning lfcd : https://github.com/NotMurPh/DotFiles/blob/main/StarryNight/home/murphy/.config/zsh/.zshrc

i think what happens is that ctpv doesn't run its cleaner on-quit and it causes images to only get cleaned after ctpv fully closes i am currenlty using this work around in my lfrc

cmd on-quit ${{
    pkill ctpv
}}

i couldn't use ctpv -c $id because when on-quit runs it refreshes the lf which causes ctpv to redraw the preview so its basically useless here

thanks in advance for your time :)

NikitaIvanovV commented 1 year ago

ctpvquit checks if it needs to kill ctpv every second, hence the delay. I think I should change the frequency.

A more proper fix is to replace &ctpvquit $id with cmd on-quit $ctpv -e $id: it will use native lf on-quit command. The only problem is that it's supported only on lf >= r27.

NotMurPh commented 1 year ago

A more proper fix is to replace &ctpvquit $id with cmd on-quit $ctpv -e $id: it will use native lf on-quit command.

ok so i've removed the &ctpvquit $id as you said and changed the

cmd on-quit ${{
    pkill ctpv
}}

to what you said cmd on-quit $ctpv -e $id but then i did some testing with this command :

while true ; do lf ; sleep 0.1 ; done and exiting manually right after

which turns out that if you get unlucky which i did in the second try while i was completely testing it manually at first, you could get stuck with a permanently lingering preview when i saw that i changed the line cmd on-quit $ctpv -e $id back to cmd on-quit $pkill ctpv and i couldn't get it to happen in my tests and looks like the ctpv -e method is sometimes like 1 in 15 times a tad slower which isn't important really

also if you remove &ctpvquit $id exiting the terminal causes the ctpv to stay open but the preview gets cleaned as it`s dependent on the terminal it self

nonetheless this issue isn't really important and already has a workaround for lf >= r27 as you said so feel free to close the issue if you want :)