-
-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[𝗛𝗲𝗹𝗽 𝗪𝗮𝗻𝘁𝗲𝗱] Clipboard steals focus every two seconds on Wayland #171
Comments
This is because 0.8.2 added asynchronous clipboard syncing, where CB will refresh every 2 seconds in the background to grab any changed desktop clipboard contents. Unfortunately, because you're using Ubuntu 22.04 on GNOME, this means you have Wayland. And because Wayland has this horrible new security feature where a window needs focus to get the clipboard, CB and other clipboard managers have to add a horrible hack by opening a temporary 1x1 window just to get focus. There is a special feature that some desktop systems support that gets rid of this issue, but it would require special handling code in CB to use. Therefore, you can try the following to work around this issue:
|
That sounds pretty horrible indeed. Thanks for explaining, it also explains some of the other things I've seen. Need to think about what to do now. I have played around with CLIPBOARD_NOGUI, but I just like to use cb together with ctrl-v pasting. Don't like it much to go back to X11 either. I guess this closes the issue then. |
I can see if anyone would like to make a PR to add the special Wayland code before closing this, because this is a recurring issue on Wayland |
can |
Actually, this may be easily possible in a future version by adding a custom script hook to each clipboard. However, I haven't done anything to add this feature yet, so stay tuned. |
Unfortunately, despite much experimentation, I haven't found a workaround to this on Gnome, and so have had to keep the GUI integration disabled, lest my typing be significantly disrupted by the constant focus stealing. Is there a way to monitor the clipboard in the background without stealing focus from other applications, eg putting it in the system tray instead? |
@MaddyGuthridge There is unfortunately no concrete fix, but the following will at least get rid of the symptom:
There is a way to keep Wayland support without interfering with the focus, but it involves supporting a new non-standard protocol and I refuse to do that because Wayland feels like a huge waste of effort to me. However, I'd be all ears for a PR if anybody wants to take on the challenge! |
The Could it be a better user experience to disable GUI integration on Gnome Wayland (and other affected desktops/WMs) by default, given the degree to which it breaks the user experience? Out of curiosity, which desktops/window managers aren't affected by the issue? Either way, maybe I'll look into improving the Wayland support if I have time, since this tool is so excellent on every other system I use. No promises though, since C++ and I have a pretty questionable relationship :p |
I think |
Perhaps having it only check for new data when performing a paste operation could improve things? Still less than ideal, but unless people have scripts running in the background, it at least wouldn't interrupt typing. Additionally, having a command to kill the daemon once it is started could be helpful (currently I need to kill it via my system monitor). |
I'm really interested in this project, and I do hope to see this issue get fixed eventually. I'm also pretty excited of the option to sync through wl-clipboard. If I find some time to learn more about Wayland, I'll gladly try my hand at raising a PR and providing a fix. |
|
Sorry for the super long wait, but next on my todo list is the script hook feature! Here's a preview of what it might look like:
|
@MaddyGuthridge do you mind testing out the latest commit? The new |
@Slackadays I'd love to give it a go! I'll have some time after work (later today). Excited to be able to have Clipboard properly integrated with my desktop! |
Hi @Slackadays! I am currently trying Version 0.9.1 (commit 9974069) using clipboard-git in Hyprland on EndeavourOS. I was trying the script function using
The issue is, as I am using Fish as my shell, clipboard can not assign And many thanks for such an awesome utility! (Also I'm not sure if I should create a new issue for this. Please let me know if I should.) |
@nhosama Not getting this in Fish: I also can't find anything about this issue anywhere else. Did you customize yours in some way that may be causing this problem? |
@Slackadays You're right. I tried the command on Fish EDIT: I couldn't find the problem after restarting once, not even on my config. Now it works fine every time. I don't know what was even happening. |
@Slackadays sorry for the wait! I've cloned and compiled it now, and it seemed to work perfectly on my system (Fedora 40, Gnome, Wayland). One point of confusion is that scripts seem to run before and after every single $ cb script --before=paste --after=cp,cut /path/to/script
...
$ cb cp "Example text"
# Text is copied
# Script is run
$ cb p
# Script is run
# Text is written to stdout That being said, I couldn't find much documentation on how scripts are planned to work, so perhaps you already have something similar in mind, and I just didn't realise. I imagine you'll document this far more before it is released. Here's the output of my testing. Seems pretty solid for the simple use cases I tried, and I especially like that the status of the program is reported if it exits with a failure code. # Me cloning your project to ~/Source/other-peoples-problems is a personal joke, not an insult, I swear!
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ git rev-parse --short HEAD
d89fcbb
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ ./cb script pwd
✔ Saved script "pwd"
/run/user/1000/Clipboard/0/data/3
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ ./cb cp "Hello world"
/run/user/1000/Clipboard/0/data/4
✔ Copied text "Hello world"
/run/user/1000/Clipboard/0/data/4
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ ./cb script ls
/run/user/1000/Clipboard/0/data/4
✔ Saved script "ls"
rawdata.clipboard
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ echo -e "#\!/usr/bin/env bash \ncat rawdata.clipboard" > example.sh
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ chmod +x example.sh
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ ./cb script /home/maddy/Source/other-peoples-problems/Clipboard/build/example.sh
rawdata.clipboard
✔ Saved script "#!/usr/bin/env bash
cat rawdata.clipboard
"
Hello world%
# !!! No trailing newline, but that's to-be-expected given my input didn't have a new-line.
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ ./cb cp "This is some example tests to check whether my fancy new script works correctly"
cat: rawdata.clipboard: No such file or directory
✘ Failed to run the clipboard script (returned exit code 1)
✔ Copied text "This is some example tests to check whether my fancy new script works correctly"
This is some example tests to check whether my fancy new script works correctly%
| maddy@yzma :: ~/Source/other-peoples-problems/Clipboard/build (main)
⋙ Note: as can be seen in the final command I ran, the behaviour of running the script before and after every operation seems less-than ideal, since it means that scripts must be made much more complex, as they must determine whether they should be run themselves, rather than relying on Given I'm not a C++ expert, your code was refreshingly simple to compile -- I just had to |
You'll need to add some way to check the action and timing from within the script itself. For example: if [ "$CLIPBOARD_ACTION" == "copy" ]; then exit 0; fi
if [ "$CLIPBOARD_SCRIPT_TIMING" == "before" ]; then exit 0; fi
|
Great to see there's a system for it, but I still think that scripts would be nicer to write if it was easier to bind them to specific events, just from a design perspective. I suppose that does add complexity to the process of registering scripts though, so the better solution depends on whether it is intended for average users to be writing their own scripts (simpler scripting interface is better) or using pre-written ones (simpler |
Just putting it out there again that if anybody knows C++ and can implement the wlr-data-control API, that would be incredible for everybody! |
@MaddyGuthridge The latest commit has the ability to configure the script actions and timing based on the |
Describe the bug
Once I have used Clipboard it will keep stealing for a split-second every two seconds or so. Very annoying when using context menus or other, that will just disappear if anything else gets focus.
To Reproduce
I might have a bit specific setup. I'm on Ubuntu (Gnome) 22.04, and I use ddterm as my terminal app, which is a Gnome specific extension that displays a dropdown, screen-wide terminal. I noticed that using this with Clipboard, results in the Clipboard application opening in the background whenever I issue a cb command. I then would have to alt+tab to the Clipboard application which then disappears and with that completes the command. I therefore installed the Gnome extension 'NoAnnoyance' which focuses directly any new spawn application, so I don't have to alt+tab to the Clipboard application. Not sure if that all contributes to the bug, I'll try to turn that off the next time before I use cb. Once this Clipboard behaviour started, it doesn't help to turn off 'NoAnnoyance'.
Expected behavior
Clearly, I don't want something to interfere with my input through mouse and/or keyboard typing, every two seconds.
Screenshots
Can't make any screenshots
Version
Clipboard 0.82, from Flathub, on Ubuntu 22.04, possibly influenced by the extension 'NoAnnoyance' thatThe version of CB you're using, how you got it, and what system you're using. Didn't have this problem with 0.81, but I have it quite consistently on other computers as well where I use Ubuntu/gnome extenstions as well.
Questionnaire
Check these boxes to see if your issue is valid or not.
Additional context
Add any other context about the problem here.
Before you post
Please make sure you check previous bug reports before filing a new one.
This will help keep the Issues section less cluttered. :)
Feel free to delete this section once you've completed this form.
The text was updated successfully, but these errors were encountered: