<?xml version='1.0' encoding='utf-8' ?>
<!--  If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/  -->
<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
<channel>
  <title>x11 programming</title>
  <link>http://community.livejournal.com/x11_programming/</link>
  <description>x11 programming - LiveJournal.com</description>
  <lastBuildDate>Sun, 13 Jan 2008 15:43:28 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>x11_programming</lj:journal>
  <lj:journaltype>community</lj:journaltype>
  <image>
    <url>http://p-userpic.livejournal.com/70284484/14660179</url>
    <title>x11 programming</title>
    <link>http://community.livejournal.com/x11_programming/</link>
    <width>80</width>
    <height>80</height>
  </image>

<item>
  <guid isPermaLink='true'>http://community.livejournal.com/x11_programming/281.html</guid>
  <pubDate>Sun, 13 Jan 2008 15:43:28 GMT</pubDate>
  <link>http://community.livejournal.com/x11_programming/281.html</link>
  <description>-----BEGIN PGP SIGNED MESSAGE-----&lt;br /&gt;Hash: SHA1&lt;br /&gt;&lt;br /&gt;Ok, I&apos;ll start this community with a post. This is a neat program, it dump the x-windows clipboard to stdout.&lt;br /&gt;&lt;br /&gt;&lt;pre width=&quot;80&quot;&gt;&lt;font color=&quot;#A020F0&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/font&gt;
&lt;font color=&quot;#A020F0&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/font&gt;
&lt;font color=&quot;#A020F0&quot;&gt;#include &amp;lt;X11/Xlib.h&amp;gt;&lt;/font&gt;
&lt;font color=&quot;#A020F0&quot;&gt;#include &amp;lt;X11/Xatom.h&amp;gt;&lt;/font&gt;

&lt;strong&gt;&lt;font color=&quot;#228B22&quot;&gt;#define MAX_CLIP_SIZE        16384&lt;/font&gt;&lt;/strong&gt;

Display *disp;
Window w;
Atom x11_clipboard;
char nothing;

&lt;strong&gt;&lt;font color=&quot;#4169E1&quot;&gt;&lt;a name=&quot;clip_get&quot;&gt;&lt;/a&gt;char *clip_get(void)&lt;/font&gt;&lt;/strong&gt; {
 unsigned char *xdata;
 Atom prop, type;
 unsigned long len, dummy;
 int fmt;
 &lt;font color=&quot;#4169E1&quot;&gt;if&lt;/font&gt;(!(x11_clipboard = XInternAtom(disp, &lt;font color=&quot;#666666&quot;&gt;&quot;CLIPBOARD&quot;&lt;/font&gt;, True))) 
  &lt;font color=&quot;#4169E1&quot;&gt;return&lt;/font&gt; &amp;amp;nothing; 
 w = XGetSelectionOwner(disp, x11_clipboard);
 &lt;font color=&quot;#4169E1&quot;&gt;if&lt;/font&gt;(w==0) &lt;font color=&quot;#4169E1&quot;&gt;return&lt;/font&gt; &amp;amp;nothing;
 prop = 1;
 XChangeProperty(disp, w, prop, XA_STRING,
                 8, PropModeReplace, (unsigned char *)&lt;font color=&quot;#666666&quot;&gt;&quot;&quot;&lt;/font&gt;, 0);
 XConvertSelection(disp,x11_clipboard, XA_STRING, prop, w, CurrentTime);
 XFlush(disp);
 XGetWindowProperty(disp, w, prop, 0, MAX_CLIP_SIZE,0,
                    AnyPropertyType, &amp;amp;type, &amp;amp;fmt, &amp;amp;len, &amp;amp;dummy, &amp;amp;xdata);
 &lt;font color=&quot;#4169E1&quot;&gt;if&lt;/font&gt;(len == 0) &lt;font color=&quot;#4169E1&quot;&gt;return&lt;/font&gt; &amp;amp;nothing;
 &lt;font color=&quot;#4169E1&quot;&gt;if&lt;/font&gt;(len&amp;gt;MAX_CLIP_SIZE) &lt;font color=&quot;#4169E1&quot;&gt;return&lt;/font&gt; &amp;amp;nothing;
 &lt;font color=&quot;#4169E1&quot;&gt;return&lt;/font&gt; xdata;
}

&lt;strong&gt;&lt;font color=&quot;#4169E1&quot;&gt;&lt;a name=&quot;main&quot;&gt;&lt;/a&gt;int main(void)&lt;/font&gt;&lt;/strong&gt; {
 &lt;font color=&quot;#4169E1&quot;&gt;if&lt;/font&gt;(!(disp = XOpenDisplay(NULL))) {
  fprintf(stderr,&lt;font color=&quot;#666666&quot;&gt;&quot;cannot open display\n&quot;&lt;/font&gt;);
  exit(-1); 
 }
 nothing = 0;
 printf(clip_get());
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;- ---&lt;br /&gt;Get my public key at &lt;a href=&quot;http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x84F69E64&quot;&gt;http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x84F69E64&lt;/a&gt;&lt;br /&gt;My voice is my passport &lt;a href=&quot;http://hobones.dogsoft.net/passport.mp3&quot;&gt;http://hobones.dogsoft.net/passport.mp3&lt;/a&gt;&lt;br /&gt;-----BEGIN PGP SIGNATURE-----&lt;br /&gt;Version: GnuPG v1.4.6 (GNU/Linux)&lt;br /&gt;&lt;br /&gt;iD8DBQFHpJVN2zj8u4T2nmQRArghAKC8sQSo54WF+J7Vq/oRhRquv5EGsQCgp9eq&lt;br /&gt;GlxJLNOVubVwd+ulybh0I4U=&lt;br /&gt;=m1V6&lt;br /&gt;-----END PGP SIGNATURE-----</description>
  <comments>http://community.livejournal.com/x11_programming/281.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>ginaspider</lj:poster>
</item>
</channel>
</rss>
