Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
xsel + xdotool, how does clipboard work?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
Holysword
l33t
l33t


Joined: 19 Nov 2006
Posts: 946
Location: Greece

PostPosted: Wed Nov 25, 2015 10:33 am    Post subject: xsel + xdotool, how does clipboard work? Reply with quote

Hello eberybody,
I am trying to come up with a script that copies a text snippet from a file and pastes it into current position in the text, regardless of which application I am using. The idea is that I can assign global shortcuts for them and then have effectively "many copy buffers". I am using primarily E19 WM, but also KDE sometimes, if that even matters.

The following line almost works:
Code:
source ~/myfile && echo $VAR1 | xsel --clipboard && xdotool key --clearmodifiers ctrl+v

except that it seems to ignore xsel and pastes whatever was the last thing I ctrl+c 'ed. I've tried the "primary" and "secondary" buffers from xsel too, neither works.

If I use xdotool click --clearmodifiers 2, that line works, but I then I have to point the mouse to where I want to paste, which is not really ideal when I am just using the keyboard.
xdotool type "$VAR1" does type the whole thing, but it comes out clumsy and it really... types it in, so it actually takes a while if the text is long-ish. Also, I had problems with some special characters.

Could anyone shed some light here? Is it even possible to do that?
_________________
"Nolite arbitrari quia venerim mittere pacem in terram non veni pacem mittere sed gladium" (Yeshua Ha Mashiach)
Back to top
View user's profile Send private message
Dr.Willy
Guru
Guru


Joined: 15 Jul 2007
Posts: 469
Location: NRW, Germany

PostPosted: Sat Nov 28, 2015 3:14 pm    Post subject: Reply with quote

I'm not really familliar with xdotool, but reading the documentation I don't understand why you even need xsel.
From what I read
Code:
source ~/myfile && xdotool type "$VAR1"
should do the trick, no?
Back to top
View user's profile Send private message
Holysword
l33t
l33t


Joined: 19 Nov 2006
Posts: 946
Location: Greece

PostPosted: Mon Nov 30, 2015 8:42 am    Post subject: Reply with quote

Dr.Willy wrote:
I'm not really familliar with xdotool, but reading the documentation I don't understand why you even need xsel.
From what I read
Code:
source ~/myfile && xdotool type "$VAR1"
should do the trick, no?

It does, but as I mentioned, "it comes out clumsy and it really... types it in, so it actually takes a while if the text is long-ish. Also, I had problems with some special characters."
Sometimes it skips some characters if I set the keypress delay to too quick. If the computer lags for some reason, (i.e. something heavy running int he background) it also skips some characters. This method is not reliable.
_________________
"Nolite arbitrari quia venerim mittere pacem in terram non veni pacem mittere sed gladium" (Yeshua Ha Mashiach)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum