Wayland environment ksnip cannot be copied problem solved
I previously wrote an article about taking screenshots in the wayland environment and then using ksnip to modify the pictures (http://mephisto.cc/tech/wayland-screenshot/). I recently discovered that after modifying the pictures, the pictures cannot be copied in some cases. I also found There is no pattern that triggers bugs🤷♂️.
The solution is as follows:
Modify screenshot script
1➜ ~ cat .config/labwc/screenshot.sh 2#!/bin/sh 3NOW=$(date +"%Y-%m-%d-%H%M%S") 4grim -g "$(slurp )" -t png $HOME/Pictures/grim-$NOW.png 5QT_QPA_PLATFORM=xcb /usr/bin/ksnip $HOME/Pictures/grim-$NOW.png
QT_QPA_PLATFORM=xcb /usr/bin/ksnip is passed in the environment variable before startup to enable XWayland, so that it does not affect other software.
- What is xcb?
The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility.
- What is QPA?
QPA is the platform abstraction layer for Qt 5 and replaces QWS and the platform ports from Qt 4.
Check out this link, which also has a YouTube video introduction, if you are interested, you can watch it.
- What the hell is QT_QPA_PLATFORM?
Qt will select a default QPA plugin, depending on the platform. The QT_QPA_PLATFORM environment variable and the -platform command line argument allow you to override this default. See [QGuiApplication](https://doc.qt.io/qt-6 /qguiapplication.html) for more details.
It means that through the setting of qt related environment variables, the qt program can call the xcb foreign aid so that it can handle the to copy.
Many software require XWayland to be turned on to input Chinese 🤷, but this configuration is nothing in comparison!
Restart related environments
In my labwc environment,
zhscreeenshot.sh is loaded into the memory at startup, and the trigger shortcut key is set, so it must be restarted to take effect. Simply changing the script is not enough.
After the actual measurement changes, there are no exceptions in the copy operation. It seems that XWayland is still necessary, and it is still far from error-free work in a pure Wayland environment.
Encouraging words from great men
"In short, the future is bright, but the road is tortuous. There are many difficulties before us, which cannot be ignored. If we unite with all the people and work together, we will be able to overcome all difficulties and achieve the goal of victory." —— Mao Zedong
- All content on this site is original, please do not reprint without authorization (because the typesetting is often disordered after reprinting, the content is uncontrollable, and cannot be continuously updated, etc.);
- For non-profit purposes, to deduce any content of this blog, please give the relevant webpage address of this site in the form of 'source of original text' or 'reference link' (for the convenience of readers).
- Screenshot plus post-modification in Wayland environment
- Gif screen recording in Wayland environment
- Wofi Tutorial
- Application launcher yofi configuration
- Snipe it asset management system installation and use
- Batch conversion of Simplified Chinese articles to Traditional Chinese
- Install the latest version of Python for Linux
- Ubuntu 22.10 connection bluetooth headset error 'br-connection-profile-unavailable solution'
- Minetest demo
- alacritty can't input Chinese and the title bar problem