Cloudef / bemenu

Dynamic menu library and client program inspired by dmenu
GNU General Public License v3.0
1.16k stars 90 forks source link

Copy/Paste using xclip is broken ( x11-backend) #374

Closed thealio closed 2 months ago

thealio commented 7 months ago

Hi

copy/paste using xclip is broken : it only search wl-paste

I have installed bemenu and bemenu-x11 as packages

I' m on Arch + xorg + xclip (of course , xclip is installed)

The error is : sh: line 1: wl-paste: comand not found

I think #363 should be referred

A good improvement could to create an envirorment variable , for specify the copy/paste wrapper in bemenu .

But, before doing that , this issue should be fixed

thealio commented 7 months ago

I can confirm that xclip is totally ignored on bemenu-x11

I'm using this dirty workaround:

xclip -t text/plain -out


- then `chmod +x ~/.bin/wl-paste`

But, the issue should be fixed
thealio commented 7 months ago

I've not tested it, but , could something like this applied to menu.c fix the issue ? :

CODE TO REPLACE

        case BM_KEY_PASTE:
            {
                FILE *clipboard;
                clipboard = popen("wl-paste -t text/plain", "r");
                if (!clipboard) {
                    clipboard = popen("xclip -t text/plain -out", "r");
                }
                if (!clipboard) {
                    break;
                }

NEW CODE

        case BM_KEY_PASTE:
            {
                FILE *clipboard;
                case "$XDG_SESSION_TYPE" in
                'x11') clipboard = popen("xclip -t text/plain -out", "r");;
                'wayland') clipboard = popen("wl-paste -t text/plain", "r");;
                *) err "No clipboard manager";;
                 esac
                }
Cloudef commented 7 months ago

Does https://github.com/Cloudef/bemenu/commit/5b75b2c93aeedd315c447ebc4955c0bd00c0d574 fix this?

thealio commented 7 months ago

Does 5b75b2c fix this?

Hi I'm trying to compile from source, for test your changes I'm encountering this error bemenu: error while loading shared libraries: libbemenu.so.0: cannot open shared object file: No such file or directory

thealio commented 7 months ago

If you are able to successfully install and test that xclip worsk fine , can you push a point release for fixing this issue? Maybe a 0.6.16.5 version , if you don't want to push 0.6.17 yet

thealio commented 7 months ago

Does 5b75b2c fix this?

Hi I'm trying to compile from source, for test your changes I'm encountering this error bemenu: error while loading shared libraries: libbemenu.so.0: cannot open shared object file: No such file or directory

I was able to install doing the following

sudo make install 
sudo make install PREFIX=/usr

I ran bot the commands

However, now I have the following error pasting the text:

sh: line 1: wl-paste: comand not found
Waiting for clipboard paste program 'wl-paste -t text/plain' failed: No child processes
Waiting for clipboard paste program 'xclip -t text/plain -out' failed: No child processes 
thealio commented 7 months ago

Does 5b75b2c fix this?

Hi I'm trying to compile from source, for test your changes I'm encountering this error bemenu: error while loading shared libraries: libbemenu.so.0: cannot open shared object file: No such file or directory

I was able to install doing the following

sudo make install 
sudo make install PREFIX=/usr

I ran bot the commands

However, now I have the following error pasting the text:

sh: line 1: wl-paste: comand not found
Waiting for clipboard paste program 'wl-paste -t text/plain' failed: No child processes
Waiting for clipboard paste program 'xclip -t text/plain -out' failed: No child processes 

Any news about?

in the meantime , I 'm using this hacky solution , creating this script named as wl-paste

/bin/wl-paste

#!/bin/bash

  case "$XDG_SESSION_TYPE" in
    'x11') xclip -selection clipboard -o;;          # using xclip
#   'x11') xsel -bo;;                               # using xsel
    'wayland') wl-paste;;
    *) err "Unknown display server";;
  esac

I think the easiest solution is to add a bash script called bemenu-clip in/bin , similar to the case function above , and make bemenu redirect to the script for the clipboard to find the right clip manager

I also wanna going a little bit OT right there. bemenu is a tool with lots of options , and , in my opinion , the best way to manage it is with a config file, so the user can set options, like the preferred clip manager to use. I think this can make easier the development , and reduce this kind of issues

vain commented 7 months ago

I think the easiest solution is to add a bash script called bemenu-clip in/bin , similar to the case function above , and make bemenu redirect to the script for the clipboard to find the right clip manager

I agree that this would be a good solution.

Making this configurable would be a good idea anyway. It’s not only relevant on X11 but also on Wayland. It has been asked for before: https://github.com/Cloudef/bemenu/issues/294

Waiting for clipboard paste program 'xclip -t text/plain -out' failed: No child processes

Hm, I cannot explain this. 🤔 Are there no other error messages besides the ones you posted?

You could try running bemenu through strace and then post all the resulting log files (they’re quite large, though):

date | strace -tt -ff -o /tmp/bmenu.log bemenu

Maybe I can find something in there … but I can’t promise anything.

thealio commented 7 months ago

I think the easiest solution is to add a bash script called bemenu-clip in/bin , similar to the case function above , and make bemenu redirect to the script for the clipboard to find the right clip manager

I agree that this would be a good solution.

Making this configurable would be a good idea anyway. It’s not only relevant on X11 but also on Wayland. It has been asked for before: #294

Waiting for clipboard paste program 'xclip -t text/plain -out' failed: No child processes

Hm, I cannot explain this. 🤔 Are there no other error messages besides the ones you posted?

You could try running bemenu through strace and then post all the resulting log files (they’re quite large, though):

date | strace -tt -ff -o /tmp/bmenu.log bemenu

Maybe I can find something in there … but I can’t promise anything.

date | strace -tt -ff -o /tmp/bmenu.log bemenu

print only the current date into bemenu , in my case

vain commented 7 months ago

print only the current date into bemenu , in my case

Yes, that is correct. But it should also create a couple of log files in /tmp, their names all start with bemenu.log. They hopefully tell us why your bemenu was unable to start xclip.

Let be more clear:

thealio commented 6 months ago

print only the current date into bemenu , in my case

Yes, that is correct. But it should also create a couple of log files in /tmp, their names all start with bemenu.log. They hopefully tell us why your bemenu was unable to start xclip.

Let be more clear:

* Start `date | strace -tt -ff -o /tmp/bmenu.log bemenu`

* When bemenu shows up, try to paste something (so that xclip _should_ be called).

* Quit bemenu and post the resulting log files.

Hi @vain

This is the content of the log file, I hope this can help you


22:51:58.062713 rseq(0x7f45d9ffbfe0, 0x20, 0, 0x53053053) = 0
22:51:58.062795 set_robust_list(0x7f45d9ffb9a0, 24) = 0
22:51:58.062828 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
22:51:58.062865 mmap(0x7f45d0000000, 67108864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f45d0000000
22:51:58.062905 mprotect(0x7f45d0000000, 135168, PROT_READ|PROT_WRITE) = 0
22:51:58.063097 mprotect(0x7f45d0021000, 188416, PROT_READ|PROT_WRITE) = 0
22:51:58.063141 mprotect(0x7f45d004f000, 4096, PROT_READ|PROT_WRITE) = 0
22:51:58.063198 mprotect(0x7f45d0050000, 4096, PROT_READ|PROT_WRITE) = 0
22:51:58.065021 mprotect(0x7f45d0051000, 12288, PROT_READ|PROT_WRITE) = 0
22:51:58.069862 mprotect(0x7f45d0054000, 4096, PROT_READ|PROT_WRITE) = 0
22:51:58.070060 mprotect(0x7f45d0055000, 4096, PROT_READ|PROT_WRITE) = 0
22:51:58.070139 mprotect(0x7f45d0056000, 4096, PROT_READ|PROT_WRITE) = 0
22:51:58.070192 mprotect(0x7f45d0057000, 4096, PROT_READ|PROT_WRITE) = 0
22:51:58.070234 mprotect(0x7f45d0058000, 8192, PROT_READ|PROT_WRITE) = 0
22:51:58.070428 mprotect(0x7f45d005a000, 4096, PROT_READ|PROT_WRITE) = 0
22:51:58.072249 futex(0x563f0f590d08, FUTEX_WAKE_PRIVATE, 1) = 0
22:51:58.072454 rt_sigprocmask(SIG_BLOCK, ~[RT_1], NULL, 8) = 0
22:51:58.072501 madvise(0x7f45d97fb000, 8368128, MADV_DONTNEED) = 0
22:51:58.072542 exit(0)                 = ?
22:51:58.072582 +++ exited with 0 +++

By the way, were you able to fix the copy/paste issue on xorg? Cheers!

thealio commented 2 months ago

Hi @Cloudef the issue with copy/paste under x11 pestists Now even my dirty fix doesn't work anymore Are you planning to fix this? It's quite a while this issue happens

Cloudef commented 2 months ago

@thealio All code for this feature is provided by contributors. I don't personally use the feature so I haven't prioritized it. That said, the feature seems to work for me at least on wayland.

thealio commented 2 months ago

@thealio All code for this feature is provided by contributors. I don't personally use the feature so I haven't prioritized it. That said, the feature seems to work for me at least on wayland.

Hi @Cloudef My fault, sorry latest version 0.6.21 fixes the issue I've just noticed that on Arch, the package is out of date Cheers !