Some of you might know that I was and in part still am a Gentoo user as well. I always found something reassuring in watching terminal with compilation going on. It is a nice sight. Compiler crunching all those sources and preparing something new for you. On some conference I even saw Gentoo guys showing a recording of Gentoo installation – a lot of compilation in there. I really liked it and I thought that it would make a nice screensaver.
So how can I have such a nice experience in binary distribution like openSUSE? All the packages are built by OBS and I get only binaries. No obvious way how to heat up my apartment with my computer. But I can still get the nice almost warm feeling of packages being compiled! Solution is pretty easy, I just configured xscreensaver to use my script and show me what OBS is working on! The outcome is, I have a screensaver that shows in the cool way compilation output of what OBS is working on right now. I still can smell fresh packages being baked, but without heating up my CPU.
How to do it? Quite simple. You need the following simple script:
Source code <td align="right">
<a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="https://michal.hrusecky.net/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a> <a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="https://michal.hrusecky.net/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a> <a href="https://michal.hrusecky.net/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="https://michal.hrusecky.net/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>
</td>
</tr>
</table>
#!/bin/bash
mkdir -p ~/ .obs-saver
cd ~/ .obs-saver
while true ; do
URL ="$(curl --connect-timeout 2 'https://build.opensuse.org/monitor/old' 2> /dev/null | \
<li class="li1">
<div class="de1">
sed -n 's|.*/package/live_build_log/\([^"</span><span class="br0">]</span><span class="sy0">*</span>\<span class="br0">)</span><span class="sy0">/</span>\<span class="br0">(</span><span class="br0">[</span>^<span class="sy0">/</span><span class="br0">]</span><span class="sy0">*</span>\<span class="br0">)</span><span class="sy0">/</span>\<span class="br0">(</span><span class="br0">[</span>^<span class="sy0">/</span><span class="br0">]</span><span class="sy0">*</span>\<span class="br0">)</span><span class="sy0">/</span>\<span class="br0">(</span><span class="br0">[</span>^<span class="sy0">/</span><span class="br0">]</span><span class="sy0">*</span>\<span class="br0">)</span><span class="st0">".*|https://build.opensuse.org/build/\1/\3/\4/\2/_log|p' | <span class="es1">\</span></div></li>
<li class="li1">
<div class="de1">
sed -n "</span><span class="sy0">`</span><span class="kw2">expr</span> <span class="nu0">5</span> + \<span class="br0">(</span> <span class="co1">${RANDOM}</span> \<span class="sy0">*</span> <span class="nu0">10</span> <span class="sy0">/</span> <span class="nu0">32767</span> \<span class="br0">)</span><span class="sy0">`</span> p<span class="st0">")"</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw1">if</span> <span class="br0">[</span> <span class="st0">"<span class="es2">$URL</span>"</span> <span class="br0">]</span>; <span class="kw1">then</span>
</div>
</li>
<li class="li1">
<div class="de1">
curl <span class="re5">--connect-timeout</span> <span class="nu0">2</span> <span class="st0">"<span class="es2">$URL</span>"</span> 2<span class="sy0">></span> <span class="sy0">/</span>dev<span class="sy0">/</span>null <span class="sy0">|</span> <span class="kw2">tee</span> <span class="st0">"<span class="es5">`date +%s`</span>"</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="re2">LAST_BL</span>=<span class="st0">"<span class="es5">`ls -1 | tail -n 1`</span>"</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw1">if</span> <span class="br0">[</span> <span class="st0">"<span class="es5">`wc -l "$LAST_BL" | sed 's|\ .*||'`</span>"</span> <span class="re5">-lt</span> 5 <span class="br0">]</span>; <span class="kw1">then</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw2">rm</span> <span class="st0">"<span class="es2">$LAST_BL</span>"</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw2">cat</span> <span class="st0">"<span class="es5">`ls -1 | sort -R | tail -n 1`</span>"</span> 2<span class="sy0">></span> <span class="sy0">/</span>dev<span class="sy0">/</span>null
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw1">else</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw2">rm</span> <span class="re5">-f</span> <span class="st0">"<span class="es5">`ls -1 | head -n -10`</span>"</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw1">fi</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw1">else</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw2">cat</span> <span class="st0">"<span class="es5">`ls -1 | sort -R | tail -n 1`</span>"</span> 2<span class="sy0">></span> <span class="sy0">/</span>dev<span class="sy0">/</span>null
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw1">fi</span>
</div>
</li>
<li class="li1">
<div class="de1">
<span class="kw1">done</span>
</div>
</li></ol></pre></div></div>
<p>
Save it as <code>obs-saver</code> in your <code>~/bin</code> and make sure it is executable. Then if you are using xscreensaver, select “<em>Phosphor</em>” screen saver and in <code>settings</code> -> <code>advanced</code>, use following command line:
</p>
<pre>phosphor -root -scale 3 -ticks 5 -delay 2000 -program ~/bin/obs-saver</pre>
<p>
Now if you are connected to the internet and you will wait for screensaver to kick in, it will randomly select one of the latest packages being build on OBS and it will start showing you it’s build log 🙂 I hope you will enjoy it as much as I do! Feeling of stuff being compiled without actually wasting that much of electricity is great 😉
</p>
Perfect is the enemy of good!