Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  17] [ 0]  / answers: 1 / hits: 7341  / 2 Years ago, wed, december 22, 2021, 8:17:13

I want to simulate keyboard input so that I can "paste" my clipboard contents to applications that don't allow it (e.g. remote KVM). Right now, I'm trying to use xdotool and xclip:



xdotool type "$(xclip -o)"


This command works if I stay in a terminal window, and type that command myself. It types back my clipboard contents when I run the command. My goal is to bind this command to a hotkey, so that it works in any application.



Linux Sendkeys



If I use this hotkey, unexpected behavior occurs to whatever window has focus. e.g. my terminal window size shrinks (it's somewhat amusing, actually). Similar results occur if I save it as a script and call the script, or if I encapsulate the command with sh -c. How can I make practical use of the powerful xdotool type command?


More From » 12.10

 Answers
2

You have two problems with this command. The first is that you need to make sure that the meta-keys in the binding are not pressed when it tries to run the command. Second, by default xclip selects XA_Primary buffer rather than the XA_CLIPBOARD. So you should pass clipboard as the selection parameter for xclip. Change your hotkey command to the following:



sh -c 'sleep 0.5; xdotool type "$(xclip -o -selection clipboard)"'

[#34469] Thursday, December 23, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
huovie

Total Points: 234
Total Questions: 99
Total Answers: 105

Location: Central African Republic
Member since Sun, Feb 26, 2023
1 Year ago
;