Comments (7)
Behaviour is the same no matter what variable QT_QPA_PLATFORM is set to.
from copyq.
@cafetestrest, I have exactly the same issue, also on hyprland, are you using nixos?
from copyq.
@cafetestrest ahh, I just saw your first screenshot and it looks like you are also on nixos, pretty sure it has to do with that we are on nixos ...
from copyq.
@gowallasnewpony @hluk ,
I got it working by using the following workaround:
- I have a script that opens terminal with fish shell (my default choice) in Hyprland exec-once
- By utilising function fish_greeting to start copyq in config.fish:
function fish_greeting
if not pidof copyq > /dev/null
env QT_QPA_PLATFORM=wayland copyq --start-server &
end
end
Does anyone happen to know why would it work like this? My suspicion is that hyprland with exec-once starts copyq differently than terminal (perhaps by user rather than root/service...).
Any feedback is appreciated.
from copyq.
So this does not seem like a bug in CopyQ, but a problem with how ydotool is set up.
Can you update to the latest Wayland Support command? It should print more details if a command fails.
from copyq.
Hi @hluk ,
My ydotool config looks like following (I've tried to remove as much hardening as possible): https://github.com/cafetestrest/nixos/blob/72b1b7ee096a6e5b43bd7173cacda5ca54cdbf29/nixos/ydotool.nix
I think I'm using the latest Wayland Support command, the one that I have right now has the following content (I was unable to locate newer one from this):
[Command]
Command="
/*
This adds support for KDE, Gnome, Sway and Hyprland Wayland sessions.
For Sway and Hyprland, this requires:
- `ydotool` utility to send copy/paste shortcuts to applications
- `grim` for taking screenshot
- `slurp` for selecting screenshot area
For KDE, this requires Spectacle for taking screenshots.
Getting current window title is not supported in KDE.
Global shortcut commands can be triggered with:
copyq triggerGlobalShortcut {COMMAND_NAME}
On Gnome, clipboard monitor is executed as X11 app using XWayland.
Links:
- https://github.com/ReimuNotMoe/ydotool
- https://github.com/emersion/grim
- https://github.com/emersion/slurp
*/
function isSway() {
return env('SWAYSOCK').length != 0
}
function isHyprland() {
return env('HYPRLAND_CMD').length != 0
}
function isGnome() {
return str(env('XAUTHORITY')).includes('mutter-Xwayland')
}
function run() {
var p = execute.apply(this, arguments)
if (!p) {
throw 'Failed to start ' + arguments[0]
}
if (p.exit_code !== 0) {
throw 'Failed command ' + arguments[0] + ': ' + str(p.stderr)
}
return p.stdout
}
function swayGetTree() {
var tree = run('swaymsg', '--raw', '--type', 'get_tree')
return JSON.parse(str(tree))
}
function swayFindFocused(tree) {
var nodes = tree['nodes'].concat(tree['floating_nodes'])
for (var i in nodes) {
var node = nodes[i]
if (node['focused'])
return node
var focusedNode = swayFindFocused(node)
if (focusedNode)
return focusedNode
}
return undefined
}
function hyprlandFindFocused() {
var window = run('hyprctl', '-j', 'activewindow')
return JSON.parse(str(window))
}
function sendShortcut(...shortcut) {
sleep(100)
run('ydotool', 'key', ...shortcut)
}
global.currentWindowTitle = function() {
if (isSway()) {
var tree = swayGetTree()
var focusedNode = swayFindFocused(tree)
return focusedNode ? focusedNode['name'] : ''
} else if (isHyprland()) {
var focusedWindow = hyprlandFindFocused()
return focusedWindow ? focusedWindow['title'] : ''
}
return ''
}
global.paste = function() {
sendShortcut('42:1', '110:1', '110:0', '42:0')
}
var copy_ = global.copy
global.copy = function() {
if (arguments.length == 0) {
sendShortcut('29:1', '46:1', '46:0', '29:0')
} else {
copy_.apply(this, arguments)
}
}
global.focusPrevious = function() {
hide()
}
var monitorClipboard_ = monitorClipboard
monitorClipboard = function() {
if (isGnome() && env('QT_QPA_PLATFORM') != 'xcb') {
serverLog('Starting X11 clipboard monitor')
setEnv('QT_QPA_PLATFORM', 'xcb')
execute('copyq', '--clipboard-access', 'monitorClipboard')
serverLog('Stopping X11 clipboard monitor')
return
}
return monitorClipboard_()
}
var onClipboardChanged_ = onClipboardChanged
onClipboardChanged = function() {
var title = currentWindowTitle()
if (title)
setData(mimeWindowTitle, title)
onClipboardChanged_()
}
screenshot = function(format, screenName) {
if (isSway() || isHyprland())
return run('grim', '-t', format || 'png', '-')
return run(
'spectacle',
'--background',
'--nonotify',
'--pointer',
'--output',
'/dev/stdout',
)
}
screenshotSelect = function(format, screenName) {
if (isSway() || isHyprland()) {
var geometry = run('slurp')
geometry = str(geometry).trim()
return run('grim', '-c', '-g', geometry, '-t', format || 'png', '-')
}
return run(
'spectacle',
'--background',
'--nonotify',
'--pointer',
'--region',
'--output',
'/dev/stdout',
)
}
global.triggerGlobalShortcut = function(commandName) {
var cmds = commands()
for (var i in cmds) {
var cmd = cmds[i]
if (cmd.isGlobalShortcut && cmd.enable && cmd.name == commandName)
return action(cmd.cmd)
}
throw 'Failed to find enabled global command with given name'
}"
Icon=
IsScript=true
Name=Wayland Support
from copyq.
Oh, sorry, that seems up-to-date - specifically this line: throw 'Failed command ' + arguments[0] + ': ' + str(p.stderr)
But I wonder why ydotool
does not print any error. Maybe it prints an error message to stdout
? Or showing the p.exit_code
might help if these are well-defined in ydotool
.
from copyq.
Related Issues (20)
- Paste in pycharm is unreliable [linux][Focus issue] HOT 2
- v9 and RDP: Remote machine does not see copied items from local machine HOT 2
- Copyq not working when copying in private browsing (firefox)
- Does not start. HOT 3
- Copyq icon does not show in panel. HOT 1
- wl-copy in wsl no longer displays in clipboard history on copyq version 9.0.0 HOT 4
- Weird flickering of items and menus. HOT 1
- Copyq disappears when I click on it HOT 1
- Does not work with Wayland (ok switching to X11) HOT 1
- inconsistent search selection
- Command "Ignore *"Password"* window" doesn't work HOT 6
- Manually editing the contents of the Item Content window
- Wish to optimize multi-device data synchronization
- How can I disable text/plain;charset=utf-8 ?
- Add an option to append to the clipboard based on an alt C or other key press HOT 1
- CopyQ v8 and v9 crash often HOT 5
- v8 and v9 are not working on macos 14.5 HOT 6
- CopyQ v9 sometimes fails to copy HOT 4
- #2679, #2680 break copying from private/incognito windows on Windows HOT 4
- Calling onTabSelected() breaks tab switching HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from copyq.