This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Custom shortcut to type primary selection fails

Tags: None
(comma "," separated)
User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
I used to follow the advice here to use meta-v to type primary selection. However, this has stopped working at some stage. Specifically, I used the following code bound to a custom shortcut, but since upgrading to a vte3 terminal, it fails.
Code: Select all
sh -c 'sleep 1; xsel | xvkbd -xsendevent -file -'

I tried the other suggested code as follows, and that also fails.
Code: Select all
sh -c 'sleep 1; xdotool type --clearmodifiers -- "$(xsel)"'

However, this command works perfectly well directly on the command line, or when called from a script. However, if I trigger the command or script from the custom shortcut, it fails.

I tested that the custom shortcut was firing at all, and it is. It's also running xsel perfectly, if I write it to a file. Oddly enough, the following works both directly and via a custom shortcut.
Code: Select all
sh -c 'sleep 1; xdotool type --clearmodifiers -- "foo"'
sh -c 'xdotool type --clearmodifiers -- "foo"'

How can I make this command work when triggered by a custom shortcut?

I'm using up-to-date Arch Linux.

EDIT
I've got it partially working. I found I needed to use `xsel -o` to get it to work when triggered by the custom keyboard shortcut. I have no idea why. The output is the same with or without the option, either piping or not. There's also still the inconsistency when being triggered by the shortcut or manually. I could also then lose `sleep`. I trigger this command with Super_L + v. However, I now find that there is frequently some kind of race condition, and that often the Super_L key is held down. Hence I have to release it programatically. This is the final command in the System Settings.
Code: Select all
sh -c 'xdotool type --clearmodifiers -- "$(xsel -o)"; xdotool keyup Super_L'

This works well enough, except for one scenario. I might want to type Super_L + v, then, without releasing Super_L, do Super_L + 5. However, since the script releases Super_L at all times, this is not possible, and I have to press Super_L again.

Oddly enough I have another command that uses xdotool, and is triggered by Alt+Ctrl+D, and this done does not have the sticky modifier problem.
felagund
Registered Member
Posts
2
Karma
0
I just wanted to thank you for the writeup. I used to use xvkbd for this years ago, then the functionality broke (I was using Unity 7 at the time) and now when I moved to KDE, I tried it again and my script would not work, but yours with xdootool does, thank you. I do not even need to do anything about super_L!
User avatar
sparhawk
Registered Member
Posts
433
Karma
0
OS
felagund wrote:I just wanted to thank you for the writeup. I used to use xvkbd for this years ago, then the functionality broke (I was using Unity 7 at the time) and now when I moved to KDE, I tried it again and my script would not work, but yours with xdootool does, thank you. I do not even need to do anything about super_L!


Thanks you felagund for the feedback! I'm glad it could help someone!


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]