<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pintant... &#187; Programari Lliure</title>
	<atom:link href="http://pintant.cat/category/programari-lliure/feed/" rel="self" type="application/rss+xml" />
	<link>http://pintant.cat</link>
	<description>amb teclat qwerty</description>
	<lastBuildDate>Sun, 22 Jan 2012 17:55:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Cap al Fosdem 2012</title>
		<link>http://pintant.cat/2012/01/08/cap-al-fosdem-2012/</link>
		<comments>http://pintant.cat/2012/01/08/cap-al-fosdem-2012/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 18:49:18 +0000</pubDate>
		<dc:creator>carles</dc:creator>
				<category><![CDATA[Programari Lliure]]></category>

		<guid isPermaLink="false">http://pintant.cat/?p=1123</guid>
		<description><![CDATA[Igual que anys anteriors: també vaig al Fosdem 2012. A veure quines sorpreses hi haurà enguany, bons conferenciants, etc. (breument, és la conferència de programari lliure més gran d&#8217;Europa i imagino que del món) Normalment surto de cada Fosdem amb una llista de projectes, programes, coses a mirar que tardo uns quants dies&#8230; Si algú [...]]]></description>
			<content:encoded><![CDATA[<p>Igual que anys anteriors: també vaig al <a href="http://fosdem.org/2012/">Fosdem 2012</a>. A veure quines sorpreses hi haurà enguany, bons conferenciants, etc.<br />
(breument, és la conferència de programari lliure més gran d&#8217;Europa i imagino que del món)</p>
<p>Normalment surto de cada Fosdem amb una llista de projectes, programes, coses a mirar que tardo uns quants dies&#8230;</p>
<p>Si algú ve i vol saludar que avisi. Companys de <a href="http://www.catux.org">Catux</a> també venen.</p>
]]></content:encoded>
			<wfw:commentRss>http://pintant.cat/2012/01/08/cap-al-fosdem-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Screensaver for KDE using Python and Pygame</title>
		<link>http://pintant.cat/2011/09/11/screensaver-for-kde-using-python-and-pygame/</link>
		<comments>http://pintant.cat/2011/09/11/screensaver-for-kde-using-python-and-pygame/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 17:49:13 +0000</pubDate>
		<dc:creator>carles</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Programari Lliure]]></category>
		<category><![CDATA[Tecnologia]]></category>

		<guid isPermaLink="false">http://pintant.cat/?p=1064</guid>
		<description><![CDATA[At Mendeley we have already done two hackdays. That&#8217;s quite interesting event: during a period of time (first one was on Friday until late night or overnight, second one Saturday and Sunday) we do whatever we want to do, it only needs to be a bit related with Mendeley. On the last hack weekend I [...]]]></description>
			<content:encoded><![CDATA[<p>At Mendeley we have already done two hackdays. That&#8217;s quite interesting event: during a period of time (first one was on Friday until late night or overnight, second one Saturday and Sunday) we do whatever we want to do, it only needs to be a bit related with Mendeley.</p>
<p>On the last hack weekend I did a screensaver using Python, which one is integrated with KDE. Probably with some small changes would work in other systems.</p>
<p>In this entry I&#8217;ll cover the basic of the screensavers in KDE (how to integrate the new screensaver in KDE), and how KDE interacts with the screensaver. You should know a little bit of Python and Pygame, but if you don&#8217;t know you can still understand the code and do the same using other systems.</p>
<p>The code is in <a href="http://git.pinux.info/?p=misc.git;a=tree;f=mendeley_screensaver;h=0a06a38244df08c0c926ca9455eaa912956cf995;hb=HEAD">Git</a>. Or if you want the quick example <a href="http://git.pinux.info/?p=misc.git;a=tree;f=mendeley_screensaver;hb=HEAD">look here.</a></p>
<p><span id="more-1064"></span></p>
<h2>How to add a new screensaver in the screensavers list from the system</h2>
<p>In KDE, in Settings, Display icon, screensavers: there is a list of screensavers (if you don&#8217;t have any you can install the packages kde-window-manager and kscreensaver-xsavers).</p>
<p>If you want to add a new screensaver there, you can create a file in the directory /usr/share/kde4/services/ScreenSavers , My new file is named &#8220;Mendeley.desktop&#8221; where you can follow the same structure than other entries there. My one looks like:<br />
<code><br />
[Desktop Entry]<br />
Exec=mendeley.kss<br />
Icon=preferences-desktop-screensaver<br />
Type=Service<br />
X-KDE-ServiceTypes=ScreenSaver<br />
Actions=Setup;InWindow;Root;<br />
# X-KDE-Category=Miscellaneous<br />
Name=Mendeley<br />
Name[ca]=Mendeley</p>
<p>[Desktop Action Setup]<br />
Exec=mendeley.kss -setup<br />
Name=Setup...<br />
Name[ca]=Arranjament...<br />
Icon=preferences-desktop-screensaver</p>
<p>[Desktop Action InWindow]<br />
Exec=mendeley.kss -window-id %w<br />
Name=Display in Specified Window<br />
Name[ca]=Mostra a la finestra especificada<br />
NoDisplay=true</p>
<p>[Desktop Action Root]<br />
Exec=mendeley.kss -root<br />
Name=Display in Root Window<br />
Name[ca]=Mostra a la finestra arrel<br />
NoDisplay=true<br />
</code><br />
See the different sections: Desktop Entry is a general one, defining which actions that particular screensaver can do (in the example: all of them: setup, preview -InWindow- and the real screensaver thing -root).</p>
<p>In each action it defines which the parameters will be passed to the binary. They can be changed, I&#8217;ve used the same than other screensavers.</p>
<p>In the above case, it says that when mendeley screensaver will be called in preview mode (or test mode) it will pass the parameter -window-id and then the window id. In execution mode it will pass only -root parameter, and in setup mode -setup.</p>
<p>In our case, mendeley.kss is just a Python file (the extension .kss is to use the same extensions than other screensavers, could be whatever we want).</p>
<p>The mendeley.kss should be in some directory in the path of the current user (else, the full path could be also used).</p>
<h2>Preview / test mode: window-id parameter</h2>
<p>Pygame, by default, uses SDL as an output. And SDL reads an environment variable (SDL_WINDOWID), if the variable exists uses that window to pain the things. Else SDL creates a new window, as it usually happens.</p>
<p>The basic code to handle the test and the preview mode would be like:</p>
<p><code><br />
#!/usr/bin/python</code></p>
<p>import os<br />
import pygame</p>
<p>if sys.argv[1] == &#8220;-window-id&#8221;:<br />
&nbsp;&nbsp;&nbsp;&nbsp;os.environ['SDL_WINDOWID'] = sys.argv[2]</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;pygame.init()<br />
self.window = pygame.display.set_mode((0,0)) # auto-resize</p>
<p>From here on we would just write standard Python using Pygame.</p>
<h2>Root window: the real case</h2>
<p>In case that the screensaver executable receives -root parameter, we need to search the root window of the current desktop.</p>
<p>As a first approach (that doesn&#8217;t work here), this could be found using xprop -root and then getting the &#8220;window id&#8221; from the output of the command. But we will find that when KDE is trying to use the screensaver, nothing will appear on the screen (as a note, here is where I spent quite a long time to understand what was happening&#8230;).</p>
<p>What we need to do is search for the virtual root window. This is a window that we need to use. This virtual root window is a window child of the root window and that one of the properties is __SWM_ROOT. Code to do this can be found in <a href="http://git.pinux.info/?p=misc.git;a=blob;f=mendeley_screensaver/virtualroot.py;h=2a0c6d459eee7dd53e9b1c6375d109fcc16a7df2;hb=HEAD">git</a>.</p>
<p>What the code does is to get all the children of the real root window, iterate over them and search which one contains __SWM_VROOT. Then returns the window id of the window that contains __SWM_VROOT.</p>
<p>The first version of the screensaver used a small C executable with some code borrowed from xscreensaver project that was doing the same using C libraries (libx11). I thought that would be more clear, Pythonic and easier to understand if I would implement it using xwininfo and xprop. If somebody knows a way to get the same result using just Python (without external calls) feel free to commend or mail me.</p>
<p>The code in mendeley.kss (which is the main Python file) to get the Virtual Root Window is like:<br />
<code><br />
if sys.argv[1] == "-root":<br />
&nbsp;&nbsp;&nbsp;&nbsp;windowid = virtualroot.getVirtualRootWindow()<br />
&nbsp;&nbsp;&nbsp;&nbsp;os.environ['SDL_WINDOWID'] = windowid<br />
</code></p>
<p>Instead of using the window-id that KDE provides us: searches for the windowid of the virtual root window and uses it.</p>
<h2>Configuration</h2>
<p>Maybe we would like to have a setup dialog for our new shiny screensaver. In that case (already specified in the .desktop file) KDE will launch the executable with the option -setup. I did something very simple as a proof of concept: I just launch a Qt dialog where the user can change some values, and the values are saved in a .py file. The main screensaver file just imports that .py file. Don&#8217;t do the same into the wild!</p>
<p>The code to do this (including the Qt code, etc.) can be found in the file mendeleyScreensaverSetup.py.</p>
<h2>Exiting</h2>
<p>When the user moves the mouse (or after writing the password): the KDE screensaver system will kill send a SIGTERM to the screensaver. In the handle_input of the screensaver code we can do:</p>
<p><code><br />
def handle_input(self,events):<br />
for event in events:<br />
# SIGTERM is handled by SDL and received a QUIT event<br />
if event.type == QUIT:<br />
&nbsp;&nbsp;&nbsp;&nbsp;sys.exit(0)<br />
</code></p>
<h2>All together now&#8230;</h2>
<p>All the code for the Mendeley screensaver can be found in <a href="http://git.pinux.info/?p=misc.git;a=tree;f=mendeley_screensaver;h=0a06a38244df08c0c926ca9455eaa912956cf995;hb=HEAD">git</a>.</p>
<p>I&#8217;ve done a reduced version without mainly any logic (only a text is displayed) so you could create your own screensaver from there on. <a href="http://git.pinux.info/?p=misc.git;a=blob;f=mendeley_screensaver/easy_example.kss;h=9b5de56eebb2bb67c8831b37533bf51c3fa4408a;hb=HEAD">See the code.</a></p>
<p>In my system, when the screensaver is printing something to the standard output, this is saved in the file ~/.xsession-errors .</p>
<h2>What about other desktop systems? (or operating systems?)</h2>
<p>Screensavers in Gnome? Maybe just xscreensaver? Or even on Mac OS X? Microsoft Windows? I haven&#8217;t done it, but as far as I&#8217;ve seen in Google the principles are quite similar. Good luck, comment here if you do. And perhaps I&#8217;ll do some other article about how to do screensavers in the other systems.</p>
<p>Here I found some information regarding Microsoft Windows (I haven&#8217;t tested): http://archives.seul.org/pygame/users/Mar-2003/msg00162.html</p>
<h2>Conclusion</h2>
<p>Doing screensaver using Python and Pygame is easy (when you have the basic) and can be very fun. And leave a quite big potential there: would you like your screensaver to do some network connections and show webpages? Or perhaps take photos of your desk? Or maybe a clock with how long you haven&#8217;t been there? Or show randomly your last git messages? everything can be done, it&#8217;s just Python code.</p>
<p>Also, thanks to Mendeley to organise the hackdays / hackweekends. It&#8217;s fun, you learn, you code for fun&#8230; without thinking too much about maintenance or other constraints. We did a blog post with some screenshots of some hacks.</p>
<p>Also, if you have some idea for some hackday: tell me. It&#8217;s usually more fun to do something that could potentially be useful (like an amazing screensaver <img src='http://pintant.cat/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ) than something not so terribly useful.</p>
<p>If you are curious what the Mendeley screensaver does: it connects to Mendeley using the Open-API, fetches some stats, shows on the screen using a black background and green fixed-width font, with a scrolling up. It also shows a random paper from your library and a random paper from the Mendeley catalog.</p>
]]></content:encoded>
			<wfw:commentRss>http://pintant.cat/2011/09/11/screensaver-for-kde-using-python-and-pygame/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Desenes Jornades de Programari Lliure</title>
		<link>http://pintant.cat/2011/06/05/desenes-jornades-de-programari-lliure/</link>
		<comments>http://pintant.cat/2011/06/05/desenes-jornades-de-programari-lliure/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 23:59:59 +0000</pubDate>
		<dc:creator>carles</dc:creator>
				<category><![CDATA[Programari Lliure]]></category>

		<guid isPermaLink="false">http://pintant.cat/?p=1037</guid>
		<description><![CDATA[Ja hi ha notícies, programa, inscripcions de les X Jornades de programari Lliure! La informació a la Web, com sempre: http://jornadespl.org/. Hi haurà xerrades per varis gustos: des de tècniques (programació amb QtQuick) a xerrades més d&#8217;àmbit legal -sempre relacionat amb el programari lliure. Tal com he dit, visiteu la Web.]]></description>
			<content:encoded><![CDATA[<p>Ja hi ha notícies, programa, inscripcions de les X Jornades de programari Lliure!</p>
<p>La informació a la Web, com sempre: <a href="http://jornadespl.org">http://jornadespl.org/</a>.</p>
<p>Hi haurà xerrades per varis gustos: des de tècniques (programació amb QtQuick) a xerrades més d&#8217;àmbit legal -sempre relacionat amb el programari lliure. Tal com he dit, visiteu <a href="http://jornadespl.org">la Web.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pintant.cat/2011/06/05/desenes-jornades-de-programari-lliure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vim filename:line:col</title>
		<link>http://pintant.cat/2011/05/06/vim-filenamelinecol/</link>
		<comments>http://pintant.cat/2011/05/06/vim-filenamelinecol/#comments</comments>
		<pubDate>Fri, 06 May 2011 18:08:04 +0000</pubDate>
		<dc:creator>carles</dc:creator>
				<category><![CDATA[Programari Lliure]]></category>
		<category><![CDATA[Tecnologia]]></category>

		<guid isPermaLink="false">http://pintant.cat/?p=1017</guid>
		<description><![CDATA[When g++ or gdb are reporting some error (e.g. compilation error) in some file the output is like: a.c:3: error: &#8216;pintf&#8217; was not declared in this scope then I usually do &#8220;vi a.c&#8221; and I go to the line 3 (:3). Using this script you can do: vi.py a.c:3 and will go to the line [...]]]></description>
			<content:encoded><![CDATA[<p>When g++ or gdb are reporting some error (e.g. compilation error) in some file the output is like:<br />
a.c:3: error: &#8216;pintf&#8217; was not declared in this scope</p>
<p>then I usually do &#8220;vi a.c&#8221; and I go to the line 3 (:3).</p>
<p>Using <a href="http://git.pinux.info/?p=misc.git;a=blob_plain;f=vim-line-col/vi.py;hb=HEAD">this script</a> you can do:<br />
vi.py a.c:3 and will go to the line 3.<br />
Or vi.py a.c:3:5 and will go the line 3, column 5.<br />
Or vi.py a.c:3: and will also go to the line 3 (so you can copy-paste g++ output).</p>
<p>The script also accepts some other variations, see the first big comment in the script sourcecode.</p>
<p>It&#8217;s useful in my case, I thought to share in case that it&#8217;s also useful for somebody else.</p>
<p>By the way, you can rename the script to vi and save in some directory that has preference to the standard vi, or create an alias, etc. I&#8217;m always using the script, since it just does something when it&#8217;s needed.</p>
<p>As said in the script: it could be improved a lot, but it&#8217;s not needed for my needs. If somebody has some suggestion just say it here or by mail, it&#8217;s inside the script.</p>
]]></content:encoded>
			<wfw:commentRss>http://pintant.cat/2011/05/06/vim-filenamelinecol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu Cola</title>
		<link>http://pintant.cat/2011/04/22/ubuntu-cola/</link>
		<comments>http://pintant.cat/2011/04/22/ubuntu-cola/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 10:14:12 +0000</pubDate>
		<dc:creator>carles</dc:creator>
				<category><![CDATA[Londres]]></category>
		<category><![CDATA[Programari Lliure]]></category>

		<guid isPermaLink="false">http://pintant.cat/?p=994</guid>
		<description><![CDATA[Em sonava haver-ho llegit, però fa unes setmanes em van dir que als supermercats Waitrose hi havia Ubuntu Cola. I efectivament&#8230; n&#8217;hi ha: No està relacionat amb Ubuntu distribució de GNU/Linux. Es pot llegir sobre el tema a la Wikipedia. És una cola de comerç just. Per cert, a vegades com costa trobar coses al [...]]]></description>
			<content:encoded><![CDATA[<p>Em sonava haver-ho llegit, però fa unes setmanes em van dir que als supermercats Waitrose hi havia Ubuntu Cola. I efectivament&#8230; n&#8217;hi ha:<br />
<a href="http://pintant.cat/wp-content/uploads/ubuntu_cola.jpg"><img src="http://pintant.cat/wp-content/uploads/ubuntu_cola.jpg" alt="" title="Ubuntu Cola" class="aligncenter size-full wp-image-995" /></a><br />
<span id="more-994"></span><br />
No està relacionat amb Ubuntu distribució de GNU/Linux. Es pot llegir sobre el tema a la <a href="http://en.wikipedia.org/wiki/Ubuntu_Cola">Wikipedia</a>. És una cola de comerç just.</p>
<p>Per cert, a vegades com costa trobar coses al supermercat. Trobo a faltar un buscador tipus &#8220;find&#8221; a la línia de comandes, o bé un select&#8230; where SQL, o alguna cosa! Les galetes de cereal, estan amb els cereals o amb les galetes? L&#8217;Ubuntu Cola està al costat de la Coca-cola i altres begudes o com era el cas aprop dels entrepans per endur? Qui sap&#8230;</p>
<p>Així que ja sabeu què portar a casa algun amic Linuxer que organitzi algun sopar.</p>
]]></content:encoded>
			<wfw:commentRss>http://pintant.cat/2011/04/22/ubuntu-cola/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

