LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-07-2007, 05:51 AM   #1
BigBadPenguin
Member
 
Registered: Jun 2003
Location: Warwick (.ac.uk)
Distribution: Arch, Slackware 9.0, (knoppix standing by)
Posts: 256

Rep: Reputation: 30
Pipe shell output to X's PRIMARY selection?


This may well be wishful thinking, but it seems like it would be a very useful feature... Just wondering if it exists. Google has not been helpful.

What I'd like to be able to do is pipe output in the shell (hopefully bash) to X's PRIMARY selection, so that I can just middle click to paste it. Obviously it's really not hard to just select it in the terminal and paste, but I'm always on the lookout for better ways to do things.

I realise that bash has no real connection to X, and it's a little irrational to expect the two to interact in this way, is there another way of setting up the same effect? Is the PRIMARY selection accessible at all?

Cheers guys.
 
Old 02-07-2007, 07:25 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Interesting question. This confirms the volatile PRIMARY buffer is strictly a mouse-driven left-select, middle-paste thing and there is no access to it otherwise. ( While looking around I came across this which patches Xterm to use both CLIPBOARD and PRIMARY to overcome buffer volatility problems. Doesn't help your case though but it may be nice to know. ) As far as I can see it is not possible. A real kludge would be to write whatever you want to copy to a temp file, have an app in X notice the write, open the file, run a macro that yanks contents to CLIPBOARD. (And maybe use an app that manages multiple clippings (Freshmeat/SourceForge) to provide paste buffers.) That's nasty...
 
Old 02-07-2007, 07:38 AM   #3
BigBadPenguin
Member
 
Registered: Jun 2003
Location: Warwick (.ac.uk)
Distribution: Arch, Slackware 9.0, (knoppix standing by)
Posts: 256

Original Poster
Rep: Reputation: 30
Cheers dude, thanks for digging.

Is this a violation of "everything is a file", I wonder? I guess that idea is incompatible with how applications interface with selections in X. One of the links described it as drag-and-drop that allows a break between dragging and dropping, which makes sense. I can't think of any less nasty kludges, so I'll just carry on selecting and pasting. Like I said, it's hardly giving me RSI as it is.
 
Old 02-07-2007, 07:54 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Is this a violation of "everything is a file", I wonder?
If you can paste enough, how about checking /dev/*mem and swap?
 
Old 02-07-2007, 10:04 AM   #5
BigBadPenguin
Member
 
Registered: Jun 2003
Location: Warwick (.ac.uk)
Distribution: Arch, Slackware 9.0, (knoppix standing by)
Posts: 256

Original Poster
Rep: Reputation: 30
I think I don't quite have the inclination nor technical knowledge to get much out of doing that.. But thanks for the suggestion.
 
Old 04-13-2008, 12:04 PM   #6
Tischbein
Member
 
Registered: Oct 2006
Distribution: debian
Posts: 124

Rep: Reputation: 15
Rescuscitate - because it's a good question!

A complication is to consider what happens when ssh-ed into another machine. You could have a special string that got caught by ssh maybe - winkey-c-( could mean start capturing from the remote host, then winkey-c-) ends the capture.

But aside from the ssh complication I think your "everything is a file therefore piping to the clipboard should be possible" is entirely reasonable.

Myself, I am too used to the Sun copy and paste buttons. The selection _stays_ on the clipboard no matter what else I've clicked in the meantime. I wouldn't mind utilising the useless windows key on this machine to emulate sun's copy and paste functions.

Regards, Entenbein.
 
Old 04-13-2008, 12:24 PM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
You can access the selection or clipboard with either xsel or xclip.
To send text to the primary selection (the default for both programs) simply run:

echo "sometext" | xsel
echo "sometext" | xclip
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting sh output to a pipe elmafiacs Programming 0 05-10-2006 01:55 PM
pipe find output to scp groundhog_killer Linux - Networking 2 02-14-2006 10:46 AM
how to pipe output from make BBB Programming 2 05-20-2005 06:14 AM
Read the output from a pipe with bash ? fluppi Linux - Software 3 01-13-2004 12:59 PM
Output truncated when using pipe tells Linux - General 1 12-16-2003 08:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration