<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="https://uname.pingveno.net/blog/index.php/feed/rss2/xslt" ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title># uname -a - Mot-clé - xscreensaver</title>
    <link>https://uname.pingveno.net/blog/index.php/</link>
    <atom:link href="https://uname.pingveno.net/blog/index.php/feed/tag/xscreensaver/rss2" rel="self" type="application/rss+xml" />
    <description>Le blog de uname.pingveno.net</description>
    <language>fr</language>
    <pubDate>Wed, 01 Apr 2026 16:19:15 +0200</pubDate>
    <copyright>Mathieu Pellegrin</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Dotclear</generator>
          <item>
        <title>Start spycam on xscreensaver lock</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2013/10/12/Start-spycam-on-xscreensaver-lock</link>
        <guid isPermaLink="false">urn:md5:0d012b1d45770063f849315b252fec78</guid>
        <pubDate>Sat, 12 Oct 2013 19:24:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>c</category>
                  <category>code</category>
                  <category>gcc</category>
                  <category>xscreensaver</category>
                <description>&lt;p&gt;Ever annoyed by those silly people trying to crack by hand your
laptop password while your are away&amp;#160;? Never wanted to know who is acting
in such kiddy behavior&amp;#160;?&lt;/p&gt;
&lt;p&gt;Here is how to set up Motion to start when Xscreensaver is on, and to stop when it is off.&lt;/p&gt;          The following guide is for Debian/Ubuntu, you should adapt the code if you are using an other distribution or a custom Motion/Xscreensaver install&lt;br /&gt;&lt;h3&gt;Requirements&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Motion&lt;/strong&gt; (from repositories) (to capture from webcam while the screen is locked)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Xscreensaver&lt;/strong&gt; (from repositories) (not gnome-screensaver, the original xscreensaver)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;build-essentials&lt;/strong&gt; (from repositories) (to compile the watchdog)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Install the requirements according to your distribution (Debian way&amp;#160;: &lt;code&gt;sudo apt-get install build-essentials motion xscreensaver&lt;/code&gt;).&lt;/p&gt;
&lt;h3&gt;How it works&amp;#160;?&lt;/h3&gt;
&lt;p&gt;Xscreensaver has a very handy utility&amp;#160;: &lt;code&gt;xscreensaver-command&lt;/code&gt;. You can lock and unlock the screen thanks to this tool, but you can also &amp;#8220;watch&amp;#8221; for status changes&amp;#160;!&lt;/p&gt;
&lt;p&gt;All we have to do is to write a daemon that will fork to start &lt;code&gt;xscreesaver-command&lt;/code&gt;, and wait for its &lt;code&gt;stdout&lt;/code&gt; result from a pipe. If it locks, we will fork to start Motion, and kill that child as soon as the screen is unlocked.&lt;/p&gt;
&lt;h3&gt;The environment&lt;/h3&gt;
&lt;p&gt;Create a directory named &amp;#8220;&lt;code&gt;motion&lt;/code&gt;&amp;#8221; in &lt;code&gt;/home&lt;/code&gt; to store the captured pictures from webcam.&lt;/p&gt;
&lt;p&gt;All-in-one command line&amp;#160;: &lt;code&gt;mkdir /home/motion&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;The daemon&lt;/h3&gt;
&lt;p&gt;Compile the attached code (at the end of this article), and place the result in &lt;code&gt;/usr/local/bin/xscreensaver_watchdog&lt;/code&gt;, and make it executable.&lt;/p&gt;
&lt;p&gt;All-in-one command line&amp;#160;: &lt;code&gt;gcc -O3 xscreensaver_watchdog.c -o xscreensaver_watchdog &amp;amp;&amp;amp; mv xcreensaver_watchdog /usr/local/bin &amp;amp;&amp;amp; chmod +x /usr/local/bin/xscreensaver_watchdog&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;The init script&lt;/h3&gt;
&lt;p&gt;As our daemon needs a graphic TTY to run (&lt;code&gt;xscreensaver-command&lt;/code&gt; is tty-dependant), we can&amp;#8217;t create a startup script for this daemon.&lt;/p&gt;
&lt;p&gt;You have to set it at the session startup, every decent Destkop environment (KDE, Gnome, Xfce, LXDE) has a way to do it.&lt;/p&gt;
&lt;h3&gt;Addendum&lt;/h3&gt;
&lt;p&gt;Well, I had a lot of fun writing this tiny program, and it is giving me new ideas.&lt;/p&gt;
&lt;p&gt;Why not recording the microphone input while the screensaver is locked&amp;#160;? It may be useful to know what your colleagues are saying when your are way.&lt;/p&gt;
&lt;p&gt;I won&amp;#8217;t write that program, but you still can. &lt;img src=&quot;/blog/themes/mathedit_material3/smilies/wink.png&quot; alt=&quot;;)&quot; class=&quot;smiley&quot;&gt;&lt;/p&gt;</description>
        
          <enclosure url="/blog/public/code/c/xscreensaver_watchdog.c" length="3308" type="application/octet-stream" />
        
              </item>
      </channel>
</rss>
