EmojiRunner
EmojiRunner copied to clipboard
Wayland support
Hi!
Does it work on Wayland, or any plans to add support? I noticed it uses xdotool, which doesn't support Wayland.
I am using it in a Wayland session with no problem (at least none related to Wayland).
xdotool works well for me (only used for ctrl+v). If you don't have it, the paste option will simply be deactivated (tested in a VM), so no problem. https://github.com/alex1701c/EmojiRunner/blob/5aaa24cfad7e7cee7553c532e3b6c77d1ae9798c/src/runner/emojirunner.cpp#L139
If needed, it could be changed to something like wl-paste
.
If needed, it could be changed to something like wl-paste.
That seems like good idea, I will play around with it!
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 492f0cf..d662a69 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@ include(ECMDeprecationSettings)
# Find the required Libaries
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED CONFIG COMPONENTS Widgets Core)
-find_package(KF${QT_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS I18n Runner ConfigWidgets KCMUtils)
+find_package(KF${QT_MAJOR_VERSION} ${KF_MIN_VERSION} REQUIRED COMPONENTS I18n Runner KCMUtils WindowSystem)
ecm_set_disabled_deprecation_versions(
KF ${KF_MIN_VERSION}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1950175..9c7ead7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,7 +2,13 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_org.kde.emojirunner\")
set(CMAKE_AUTOUIC ON)
kcoreaddons_add_plugin(emojirunner SOURCES runner/emojirunner.cpp core/Emoji.cpp core/FileReader.cpp INSTALL_NAMESPACE "kf${QT_MAJOR_VERSION}/krunner")
-target_link_libraries(emojirunner KF${QT_MAJOR_VERSION}::Runner KF${QT_MAJOR_VERSION}::I18n KF${QT_MAJOR_VERSION}::ConfigCore Qt::Widgets) # Widgets for QAction, this will change to Qt::Gui in Qt6
+target_link_libraries(emojirunner
+ KF${QT_MAJOR_VERSION}::Runner
+ KF${QT_MAJOR_VERSION}::WindowSystem
+ KF${QT_MAJOR_VERSION}::I18n
+ KF${QT_MAJOR_VERSION}::ConfigCore
+ Qt::Widgets # Widgets for QAction, this will change to Qt::Gui in Qt6
+)
find_path(XDO_HEADER xdo.h)
find_library(XDO_LIB "xdo")
@@ -28,7 +34,6 @@ target_link_libraries(kcm_krunner_emojirunner
KF${QT_MAJOR_VERSION}::CoreAddons
KF${QT_MAJOR_VERSION}::KCMUtils
KF${QT_MAJOR_VERSION}::ConfigCore
- KF${QT_MAJOR_VERSION}::ConfigWidgets
)
install(TARGETS kcm_krunner_emojirunner DESTINATION ${KDE_INSTALL_QTPLUGINDIR}/)
install(FILES core/emojis.json DESTINATION ${KDE_INSTALL_DATADIR}/emojirunner/)
diff --git a/src/runner/emojirunner.cpp b/src/runner/emojirunner.cpp
index f5f8259..4e2caaa 100644
--- a/src/runner/emojirunner.cpp
+++ b/src/runner/emojirunner.cpp
@@ -6,6 +6,7 @@
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
+#include <KWindowSystem>
#include <krunner_version.h>
#include <QApplication>
@@ -157,6 +158,13 @@ KRunner::QueryMatch EmojiRunner::createQueryMatch(const Emoji &emoji, const qrea
void EmojiRunner::emitCTRLV()
{
+ const static QString wlPaste = QStandardPaths::findExecutable("wl-paste");
+ if (KWindowSystem::isPlatformWayland() && !wlPaste.isEmpty()) {
+ QTimer::singleShot(50, []() {
+ QProcess::startDetached(wlPaste);
+ });
+ return;
+ }
#ifdef XDO_LIB
// Emit Ctrl+V to paste clipboard content
xdo_send_keysequence_window(xdo, CURRENTWINDOW, "ctrl+v", 0);
Hmm, but wl-paste sends it not to the focussed window :(
Giving a closer look at wl-clipboard, it seems that pasting to another window is not a use case, despite what I though, sorry about that.
Rofimoji uses wtype. Unfortunatly, wtype requires https://wayland.app/protocols/virtual-keyboard-unstable-v1 which is not yet available in KDE (KWin 6.0.4 currently).
Using ydotool:
-
ydotool type "Hello 🏃!"
doesn't work with emojis -
ydotool key 135:1 135:0
(KEY_PASTE)- works in firefox by default
- works in other applications only after adding "Paste" as a custom shortcut for Paste in the system manager or the application settings for konsole (hmm).
- ~~(works only in firefox when using QProcess startDetached?)~~ run with a delay
QProcess::startDetached("sh", QStringList{"-c", "sleep 0.2; ydotool key 135:1 135:0"});
-
ydotool key 29:1 47:1 47:0 29:0
(KEY_LEFTCTRL KEY_V)- works, even in QProcess, but the application must use Ctrl+V as paste shortcut. https://github.com/ReimuNotMoe/ydotool/issues/22#issuecomment-1825023908
- (doesn't work in KWrite?)
-
ydotool key 54:1 110:1 110:0 54:0
(KEY_LEFTSHIFT KEY_INSERT)- works, even in QProcess, without changing the settings
- doesn't work when the application uses the other clipboard (XTerm, the terminal in VSCode)
Side note: xdotool key ctrl+v
still works in some applications (e.g. electron apps).
So, lots of possibilities... with a downside to each. wtype may be the way to go if supported. I will try shift+insert for now.
Side note: xdotool key ctrl+v still works in some applications (e.g. electron apps).
I think that is due to the xwayland stuff ;)
So, lots of possibilities... with a downside to each. wtype may be the way to go if supported.
Yeah ... not really sure what to do
I am using Wayland as well, and the AUR package I build uses xdotool (library) and it works fine.
Maybe xdotool gained Wayland support?