kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.31k stars 977 forks source link

Vifm image preview return error #4174

Closed LamprosPitsillos closed 2 years ago

LamprosPitsillos commented 2 years ago

Using the exact snippet that @GeorgeHJ gave above , i get this error.

Traceback (most recent call last):                                                           
    File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main                       
    return _run_code(code, main_globals, None,                                               
            File "/usr/lib/python3.9/runpy.py", line 87, in _run_code                                  
            exec(code, run_globals)                                                                  
            File "/usr/bin/../lib/kitty/__main__.py", line 153, in <module>                            
            main()                                                                                   
            File "/usr/bin/../lib/kitty/__main__.py", line 144, in main                                
            namespaced(['+', first_arg[1:]] + sys.argv[2:])                                          
            File "/usr/bin/../lib/kitty/__main__.py", line 99, in namespaced                           
            func(args[1:])                                                                           
            File "/usr/bin/../lib/kitty/__main__.py", line 13, in icat                                 
            rk('icat')                                                                               
            File "/usr/bin/../lib/kitty/kittens/runner.py", line 122, in run_kitten                    
            runpy.run_module('kittens.{}.main'.format(kitten), run_name=run_name)                    
            File "/usr/lib/python3.9/runpy.py", line 213, in run_module                                
            return _run_code(code, {}, init_globals, run_name, mod_spec)                             
            File "/usr/lib/python3.9/runpy.py", line 87, in _run_code                                  
            exec(code, run_globals)                                                                  
            File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 583, in <module>                   
            main()                                                                                   
            File "/usr/bin/../lib/kitty/kittens/icat/main.py", line 507, in main                       
            sys.stdout = open(os.ctermid(), 'w')                                                     
    OSError: [Errno 6] No such device or address: '/dev/tty' 

Info

Kitty: kitty 0.23.1 Vifm:

Version: 0.12
Git info: built out of repository
Compiled at: Oct  3 2021 09:59:56

Support of extended keys is on
Parsing of .desktop files is enabled
Without GTK+ library
With magic library
Without X11 library
Without dynamic loading of X11 library
With file program
With -n option for cp and mv
With remote command execution

Os: Artix Linux

Originally posted by @LamprosPitsillos in https://github.com/kovidgoyal/kitty/issues/1308#issuecomment-933002336

Danielgb23 commented 2 years ago

Same here. Exact same error running:

filetype .bmp,.jpg,.jpeg,.png,.xpm open -a Preview %f & fileviewer .bmp,.jpg,.jpeg,.png,.xpm \ kitty +kitten icat --clear --transfer-mode=file --place=%pwx%ph@%pxx%py %c \ %pc \ kitty +kitten icat --transfer-mode=file --place=%pwx%ph@%pxx%py --clear

Os Arch linux kitty 0.23.1

I think it might be related to running the DE/WM from a tty with startx or something like that and os.ctermid() getting the id for that tty instead of the terminal window that is the target. Which is what I did. @LamprosPitsillos might confirm if he is running from the tty too

LamprosPitsillos commented 2 years ago

Same here. Exact same error running:

filetype .bmp,.jpg,.jpeg,.png,.xpm open -a Preview %f & fileviewer .bmp,.jpg,.jpeg,.png,.xpm \ kitty +kitten icat --clear --transfer-mode=file --place=%pwx%ph@%pxx%py %c \ %pc \ kitty +kitten icat --transfer-mode=file --place=%pwx%ph@%pxx%py --clear

Os Arch linux kitty 0.23.1

I think it might be related to running the DE/WM from a tty with startx or something like that and os.ctermid() getting the id for that tty instead of the terminal window that is the target. Which is what I did. @LamprosPitsillos might confirm if he is running from the tty too

I use Qtile , how do i check if it's starting from the tty?

Danielgb23 commented 2 years ago

If when you booted you had to login in a tty and run startx or whatever it is for wayland. I guess not if you are asking.

But I think it's not that. I ran the line by itself in a python term and it showed no error message. It probably is more complicated than that...

kovidgoyal commented 2 years ago

You are running your script in a process that is not attached to a terminal device. It needs to run in a process with an attached terminal.

LamprosPitsillos commented 2 years ago

You are running your script in a process that is not attached to a terminal device. It needs to run in a process with an attached terminal.

Sorry ,can you please be a bit more clear? I just start kitty and then type in vifm. Isn't this considered attached to the terminal?

GeorgeHJ commented 2 years ago

@LamprosPitsillos have you tried building vifm from master with this commit?

https://github.com/vifm/vifm/commit/09b8ee569fa1715a59022264c57b8badaf609c17

It looks like they've introduced the %N macro to deal with this type breakage.

Danielgb23 commented 2 years ago

Isn't this considered attached to the terminal?

It should be but it's not. I tested it and it's another process that runs the command (not the terminal)

Danielgb23 commented 2 years ago

@LamprosPitsillos have you tried building vifm from master with this commit?

vifm/vifm@09b8ee5

It looks like they've introduced the %N macro to deal with this type breakage.

I tested it in the one compiled from the recent master with

" Pictures
filetype *.bmp,*.jpg,*.jpeg,*.png,*.xpm open -a Preview %f &
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm
    \ kitty +kitten icat --transfer-mode=file --place=%pwx%ph@%pxx%py %c %N 
    \ %pc
    \ kitty +kitten icat --transfer-mode=file --place=%pwx%ph@%pxx%py --clear %N 

And it worked perfectly. It's just slow down your scrolling when you do it too fast. If you don't want to compile it just wait for the new update

hutou commented 2 years ago

vifm %N macro also solved the problem for me (see this post). However, browsing images was not very fluid (flash effect between images). I got much better results with ueberzug : explanation is given here (Be careful, create a new directory ~/.config/vifm before installation, to avoid any dysfunction).

Danielgb23 commented 2 years ago

I tried w3m and it hides the image and flashes them when you move the cursor. It didn't had the lag though. I will find a fix for it. I also have to configure the character pixel size in the script to position it properly. (Maybe there's a command to get it?)

On Mon, Nov 1, 2021, 10:57 hutou @.***> wrote:

vifm %N macro also solved the problem for me (see this post https://github.com/vifm/vifm/issues/731). However, browsing images was not very fluid (flash effect between images). I got much better results with ueberzug : explanation is given here https://github.com/cirala/vifmimg (Be careful, create a new directory ~/.config/vifm before installation, to avoid any dysfunction).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kovidgoyal/kitty/issues/4174#issuecomment-956255221, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH4Z6AIA6LKR5IWGI65ZCELUJ2MDBANCNFSM5HBTFXPQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.