ekickx / clipboard-image.nvim

Neovim Lua plugin to paste image from clipboard.
MIT License
309 stars 51 forks source link

fix: add support for XDG_SESSION_TYPE as tty #30

Closed m-fonseca closed 2 years ago

m-fonseca commented 2 years ago

Hello, this is a small fix that allowed this plugin to work in my environment. Thank you for the plugin!


If you don't start X with a display manager like gdm, and just use startx or similar, it seems your XDG_SESSION_TYPE will be 'tty', which causes an error. This adds a case to handle tty.

ekickx commented 2 years ago

Thank you for the PR!

But I think it's better to just write it like this:

- if display_server == 'x11' then
+ if display_server == 'x11' or display_server == 'tty' then
  cmd_check = 'xclip -selection clipboard -o -t TARGETS'
  cmd_paste = 'xclip -selection clipboard -t image/png -o > \'%s\''
elseif display_server == 'wayland' then
  cmd_check = 'wl-paste --list-types'
  cmd_paste = 'wl-paste --no-newline --type image/png > \'%s\''
- elseif display_server == 'tty' then
-   cmd_check = 'xclip -selection clipboard -o -t TARGETS'
-   cmd_paste = 'xclip -selection clipboard -t image/png -o > \'%s\''
end
ekickx commented 2 years ago

@m-fonseca Can you test my change?

m-fonseca commented 2 years ago

Works as I'd expect.

ekickx commented 2 years ago

merged