<?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>code(alpha) &#187; Tutorials</title>
	<atom:link href="http://www.codealpha.net/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codealpha.net</link>
	<description>Tips &#38; Tutorials for Linux</description>
	<lastBuildDate>Sat, 25 Jun 2011 21:50:14 +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>How to restrict a specific package from installing (apt pinning)</title>
		<link>http://www.codealpha.net/737/how-to-restrict-a-specific-package-from-installing-apt-pinning/</link>
		<comments>http://www.codealpha.net/737/how-to-restrict-a-specific-package-from-installing-apt-pinning/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 14:46:02 +0000</pubDate>
		<dc:creator>Arnaud Soyez</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[pinning]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.codealpha.net/?p=737</guid>
		<description><![CDATA[I tend to be very picky so there are a couple of packages which I do not want installed on my machines: msttcorefonts: the Microsoft-like fonts. If you have those installed, Firefox will use them and you will get ugly windows-like font on most websites which I personally hate. wine: Application to run windows programs [...]]]></description>
			<content:encoded><![CDATA[<p>I tend to be very picky so there are a couple of packages which I do not want installed on my machines:</p>
<ul>
<li><strong>msttcorefonts</strong>: the Microsoft-like fonts. If you have those installed, Firefox will use them and you will get ugly windows-like font on most websites which I personally hate.</li>
<li><strong>wine</strong>: Application to run windows programs on linux. For security reasons.</li>
<li><strong>postfix</strong>: a mail server. Just because I do not want to run a mail server on my netbook.</li>
<li>...and some other</li>
</ul>
<p>The best way to restrict those packages from being installed is through <strong>Apt Pinning</strong>.</p>
<h3>Apt pinning</h3>
<p>It is very easy to pin packages and restrict them from being installed.<br />
You will need to edit /etc/apt/preferences and add something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Package: msttcorefonts
Pin: version  0.0
Pin-Priority: -1
&nbsp;
Package: ttf-liberation
Pin: version  0.0
Pin-Priority: -1
&nbsp;
Package: ttf-mscorefonts-installer
Pin: version  0.0
Pin-Priority: -1
&nbsp;
Package: wine
Pin: version  0.0
Pin-Priority: -1
&nbsp;
Package: postfix
Pin: version  0.0
Pin-Priority: -1</pre></div></div>

<p><strong>Pin-Priority: -1</strong> restricts the given version from being installed, and the <strong>version  0.0</strong> does not exist and should be a lower version than any versions of the given packages. As a conclusion, they will never be installed.</p>
<p>Be careful what you pin, though, as you might be too restrictive and could prevent installing or upgrading other useful packages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codealpha.net/737/how-to-restrict-a-specific-package-from-installing-apt-pinning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a simple approval queue with Request Tracker (RT) 3.8</title>
		<link>http://www.codealpha.net/664/how-to-create-a-simple-approval-queue-with-request-tracker-rt-3-8/</link>
		<comments>http://www.codealpha.net/664/how-to-create-a-simple-approval-queue-with-request-tracker-rt-3-8/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 14:39:23 +0000</pubDate>
		<dc:creator>Arnaud Soyez</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[request tracker]]></category>
		<category><![CDATA[rt]]></category>

		<guid isPermaLink="false">http://www.codealpha.net/?p=664</guid>
		<description><![CDATA[Introduction In this post I will show how to create a simple approval queue in Request Tracker 3.8. The General queue will be used as the approval queue. Here are the different entities (groups) we will create: Submitters: they can submit new tickets only to the General Queue. Approvers: they can approve tickets (move them [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>In this post I will show how to create a simple approval queue in <a href="http://bestpractical.com/rt/">Request Tracker 3.8</a>.</p>
<div style="text-align:center"><img src="http://www.codealpha.net/wp-content/uploads/2010/08/300px-Rt3.8-ticket-list.png" alt="Request Tracker" title="Request Tracker" width="300" height="195" class="aligncenter size-full wp-image-677" /></div>
<p>The <strong>General queue</strong> will be used as the approval queue.</p>
<p>Here are the different entities (groups) we will create:</p>
<ul>
<li><strong>Submitters</strong>: they can submit new tickets only to the General Queue.</li>
<li><strong>Approvers</strong>: they can approve tickets (move them from the general queue to another queue)</li>
</ul>
<p>I will also show how to add a new dashlet ("<strong>RT at a glance</strong>") containing all the tickets the user created ("My issues").</p>
<p><span id="more-664"></span></p>
<h2>Permissions and Rights</h2>
<p>In preferences, make sure the General queue is the default queue.</p>
<p>Create your other queues as needed.</p>
<p>First, we'll allow all requestors (person who created/initiated a new ticket) to see all tickets they created and also be able to reply to them. In <em>Configuration &gt; Global &gt; Group rights</em>, for the <strong>Requestors</strong> group add the following rights:</p>
<ul>
<li>ShowTicket</li>
<li>ReplyTicket</li>
</ul>
<h3>Submitters</h3>
<p>In <em>Configuration &gt; Groups &gt; Create</em>, create a group called "Submitters".</p>
<p>To allow the submitters to create new tickets to the general queue, go to <em>Configuration &gt; Queues</em> open the <strong>General</strong> queue, click on Group Rights (top menu), add the following rights to the "Submitters" group:</p>
<ul>
<li>SeeQueue</li>
<li>ShowTicket</li>
<li>CreateTicket</li>
</ul>
<p>For the submitters to be able to see their tickets (which they created) after they have been moved to another queue, they need some READ rights on all other queues. Go to <em>Configuration &gt; Queues</em>, <strong>for each queue</strong>, add the following <strong>Group Rights</strong> to the <strong>Submitters</strong> group:</p>
<ul>
<li>SeeQueue</li>
<li>ShowTicket</li>
</ul>
<h3>Approvers</h3>
<p>In <em>Configuration &gt; Groups &gt; Create</em>, create a group called "Approvers".</p>
<p>We need to allow the Approvers to see and create tickets in every queue, go to <em>Configuration &gt; Queues</em> and <strong>for each queue</strong> click on Group Rights (top menu), add the following rights to the "Approvers" group:</p>
<ul>
<li>SeeQueue</li>
<li>ShowTicket</li>
<li>CreateTicket</li>
</ul>
<p>Now they need to be able to <strong>modify</strong> tickets that are in the <strong>General Queue</strong>, go to <em>Configuration &gt; Queues &gt; General</em>  click on Group Rights (top menu), add the following rights to the "Approvers" group:</p>
<ul>
<li>SeeQueue</li>
<li>ShowTicket</li>
<li>CreateTicket</li>
<li>ModifyTicket</li>
</ul>
<h2>Dashlet for "My Issues"</h2>
<p>Now we allow the <strong>privileged</strong> users to use saved searches and dashboards: in <em>Configuration &gt; Global &gt; Group Rights</em>, find the "Privileged" group and add the following rights:</p>
<ul>
<li>LoadSavedSearch</li>
<li>ModifyOwnDashboard</li>
<li>ShowSavedSearches</li>
<li>SubscribeDashboard</li>
</ul>
<p>In <em>Tickets </em> go to <em>Advanced</em> (top menu), copy and paste the following query in the first textfield:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">(Creator = '__CurrentUser__')</pre></div></div>

<p>Click on <em>Edit Search</em> (top menu), tweak the search as necessary. When done, save it as an <strong>RT's system saved search</strong> (in the dashlet called "Saved searches"). Pick a name ("My Issues" for example).</p>
<p>Then we need to the change the default <em>RT at a glance</em>, go to <em>Configuration &gt; Global &gt; RT at a glance</em><br />
<br/>In <strong>RT at a glance: body</strong>, on the left column <strong>select your saved search</strong> ("My Issues") and click the <strong>right</strong> arrow. Then in the right column, you can move your dashlet up and down.</p>
<h2>Conclusion</h2>
<p>Now you can add new users and assign them to the <strong>Submitters group</strong> or the <strong>Approvers group</strong>, or even both.<br />
<strong>Submitters</strong> can create new tickets and still see them if they are moved to another queue or changed ownership.<br />
<strong>Approvers</strong> can move tickets from the General queue to other queues.<br />
<strong>Every privileged user</strong> should now see the "My issues" dashlet on their dashboard.</p>
<p><strong>Of course, I am giving the strict minimum amount of rights necessary to achieve this, but you are free to add more rights (e.g. add the Watch right, or ReplyTicket right to Approvers) if you need them</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codealpha.net/664/how-to-create-a-simple-approval-queue-with-request-tracker-rt-3-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to set up Expires header with Apache2 on Ubuntu Lucid 10.04</title>
		<link>http://www.codealpha.net/649/how-to-set-up-expires-header-with-apache2-on-ubuntu-lucid-10-04/</link>
		<comments>http://www.codealpha.net/649/how-to-set-up-expires-header-with-apache2-on-ubuntu-lucid-10-04/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 23:02:20 +0000</pubDate>
		<dc:creator>Arnaud Soyez</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.codealpha.net/?p=649</guid>
		<description><![CDATA[A very good way to reduce page load time on your website is to tell your visitors' browser it can cache some specific files and save a copy on the disk. This process is done by your web-server which is sending an Expires header and a max-age header during the HTTP response, e.g.: 200 OK [...]]]></description>
			<content:encoded><![CDATA[<p>A very good way to reduce page load time on your website is to tell your visitors' browser it can cache some specific files and save a copy on the disk.<br/><br />
This process is done by your web-server which is sending an <strong><em>Expires</em></strong> header and a <em><strong>max-age</strong></em> header during the HTTP response, e.g.:</p>
<div class="codewrapper"><code>200 OK<br />
<strong>Cache-Control: max-age=604800</strong><br />
Connection: close<br />
Date: Tue, 27 Jul 2010 22:31:03 GMT<br />
Accept-Ranges: bytes<br />
ETag: "2c956-376b-4696cb8b385c0"<br />
Server: Apache/2.2.14 (Ubuntu)<br />
Content-Length: 14187<br />
Content-Type: image/gif<br />
<strong>Expires: Tue, 03 Aug 2010 22:31:03 GMT</strong><br />
Last-Modified: Fri, 08 May 2009 20:46:23 GMT<br />
Client-Date: Tue, 27 Jul 2010 22:31:02 GMT<br />
Client-Peer: 127.217.30.5:80<br />
Client-Response-Num: 1</code></div>
</pre>
<p>Apache2 offers this feature through its <strong><a href="http://httpd.apache.org/docs/2.0/mod/mod_expires.html">mod_expires</a></strong> module. Note that this module is <strong>usually disabled by default</strong>, meaning your visitors would download all the files over again each time they change the page.</p>
<p><span id="more-649"></span></p>
<ul>
<li>First, to activate <em>mod_expires</em>, type this in a terminal:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod expires</pre></div></div>

</li>
<li>Then, we need to tell Apache2 which files can have an expire header. You can add this in your vhost configuration or your main apache2 configuration file you want it to apply to every vhost:

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ExpiresActive On
ExpiresByType image/gif &quot;access plus 7 days&quot;
ExpiresByType image/jpeg &quot;access plus 7 days&quot;
ExpiresByType image/png &quot;access plus 7 days&quot;
ExpiresByType image/x-icon &quot;access plus 3 months&quot;
ExpiresByType image/ico &quot;access plus 3 months&quot;
ExpiresByType text/css &quot;access plus 2 days&quot;</pre></div></div>

</li>
<li>Remember to restart Apache2:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> service apache2 restart</pre></div></div>

</li>
<li>You can look at the headers sent by your webserver using HEAD (on a linux machine) like so:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">HEAD http:<span style="color: #000000; font-weight: bold;">//</span>www.codealpha.net<span style="color: #000000; font-weight: bold;">/</span>wp-content<span style="color: #000000; font-weight: bold;">/</span>themes<span style="color: #000000; font-weight: bold;">/</span>notso_freshe<span style="color: #000000; font-weight: bold;">/</span>images<span style="color: #000000; font-weight: bold;">/</span>header.gif</pre></div></div>

</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.codealpha.net/649/how-to-set-up-expires-header-with-apache2-on-ubuntu-lucid-10-04/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Things to remember to backup or copy when migrating servers</title>
		<link>http://www.codealpha.net/600/things-to-remember-to-backup-or-copy-when-migrating-servers/</link>
		<comments>http://www.codealpha.net/600/things-to-remember-to-backup-or-copy-when-migrating-servers/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 18:10:38 +0000</pubDate>
		<dc:creator>Arnaud Soyez</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.codealpha.net/?p=600</guid>
		<description><![CDATA[A new version of your operating system just got released and you want to have a fresh new install, or you want to migrate all of your data to another machine. There are so much stuff to backup that you don't even know where to start? I will try to list the most common stuff [...]]]></description>
			<content:encoded><![CDATA[<p>A new version of your operating system just got released and you want to have <strong>a fresh new install</strong>, or you want to <strong>migrate all of your data to another machine</strong>. There are so much stuff to backup that you don't even know where to start?<br />
I will try to list <strong>the most common stuff (on a web-server) to backup or copy somewhere when you want to do a server migration.</strong></p>
<p><span id="more-600"></span><br />
This tutorial is targeted to Ubuntu systems, but can easily apply to Debian or other distributions.<br/><br />
Please also note that this should <strong>only be used as a guide, I do not guarantee that this will save all of your configuration. NO WARRANTY !</strong></p>
<ul>
<li>First, make sure you <strong>execute each command as root</strong>, or use <strong>sudo</strong>.</li>
<li>Make a secret temporary folder to store your backup and <em>cd</em> into it:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(mktemp -d)</span>&quot;</span></pre></div></div>

</li>
<li>The <strong>/home</strong> folder: just tar everything, <strong>as root</strong> type:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> home.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>home</pre></div></div>

</li>
<li>Backup <strong>/root</strong>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> root.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>root</pre></div></div>

</li>
<li>Backup <strong>users, passwords and groups</strong>:
<ul>
<li>users are in <strong>/etc/passwd</strong> and <strong>/etc/shadow</strong></li>
<li>groups are in <strong>/etc/group</strong> and <strong>/etc/gshadow</strong>,</li>
</ul>
<p><strong>JUST take the lines containing users/groups that YOU created (usually they have a uid &gt;= 1000)!</strong>
  </li>
<li>Backup <strong>crontabs</strong>, and <strong>atjobs</strong>:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> etc_crontab.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>crontab
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> spool_crontabs.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>cron<span style="color: #000000; font-weight: bold;">/</span>crontabs<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> spool_atjobs.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>cron<span style="color: #000000; font-weight: bold;">/</span>atjobs<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>Backup users' <strong>email</strong>:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> email.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>mail<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>
    <strong>Websites</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> www.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>Backup <strong>needed config files in /etc/</strong>:
<ul>
<li>Apache2 vhosts:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> vhosts.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li>Networking configuration:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--preserve</span> <span style="color: #660033;">-cvjf</span> network.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>interfaces <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

</li>
<li>Postfix configuration:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cvjf</span> postfix.tar.bz2 <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/*</span>.cf</pre></div></div>

</li>
<li>Anything else you see in <strong>/etc/</strong> and you wish to keep...</li>
</ul>
</li>
<li>Backup <strong>MySQL databases, users and privileges</strong>:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span> <span style="color: #660033;">--databases</span> mydb1 somedb2 anotherdb3 <span style="color: #000000; font-weight: bold;">&gt;</span> db.sql
mysqldump <span style="color: #660033;">-nt</span> <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span> <span style="color: #660033;">-w</span><span style="color: #ff0000;">&quot;User NOT LIKE 'root' AND User NOT LIKE 'debian%'&quot;</span> mysql user db <span style="color: #000000; font-weight: bold;">&gt;</span> users_privs.sql</pre></div></div>

</li>
</ul>
<p>I'm sure you can figure out where to put everything back on the destination server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codealpha.net/600/things-to-remember-to-backup-or-copy-when-migrating-servers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Script to capture a screenshot (with Chromium) (Command-line)</title>
		<link>http://www.codealpha.net/492/how-to-capture-a-screenshot-with-chromium-command-line/</link>
		<comments>http://www.codealpha.net/492/how-to-capture-a-screenshot-with-chromium-command-line/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 18:00:48 +0000</pubDate>
		<dc:creator>Arnaud Soyez</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[chromium]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command-line]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.codealpha.net/?p=492</guid>
		<description><![CDATA[Introduction I wanted to take screenshots of about 15 Websites, but didn't want to install any plugins as I wouldn't use them often. I saw a lot of how-to's using import from Imagemagick but they capture the whole screen, not clearly what I was looking for. Using chromium, xwininfo (from X) and import, I made [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>I wanted to take screenshots of about 15 Websites, but didn't want to install any plugins as I wouldn't use them often. I saw a lot of how-to's using <strong>import</strong> from <strong><a href="http://www.imagemagick.org/">Imagemagick</a></strong> but they capture the whole screen, not clearly what I was looking for.</p>
<p>Using <strong>chromium</strong>, <strong>xwininfo</strong> (from X) and <strong>import</strong>, I made this bash script which captures only the webpage. <strong>See below for the Source code.</strong></p>
<p><span id="more-492"></span></p>
<h2>How it works</h2>
<p>Upon calling chromium-capture:</p>
<ul>
<li>it finds <strong>every running chromium browser</strong> using xwininfo,</li>
<li>gets the window's id of <strong>each browser's currently opened tab</strong> (because hidden tabs cannot be accessed using xwininfo/import)</li>
<li>takes a <strong>screenshot</strong> of each webpages using import and the windows' ids.</li>
<li><strong>saves</strong> the screenshot in the current directy as <strong>chromium-WINDOWID.png</strong> (with WINDOWID = id of the respective window)</li>
</ul>
<p>You get a screenshot of only the website. All of the arguments and options given to chromium-capture will be used as arguments and options when calling import.</p>
<h2>Usage Examples</h2>
<p>Every argument or option given to chromium-capture will be given to import when called with every capture.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#do a simple capture</span>
<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>chromium-capture
&nbsp;
<span style="color: #666666; font-style: italic;">#capture and resize to a width of 300px</span>
<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>chromium-capture <span style="color: #660033;">-resize</span> <span style="color: #000000;">300</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#capture and rotate the image 10degres</span>
<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>chromium-capture <span style="color: #660033;">-rotate</span> <span style="color: #000000;">10</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#resize to a maximum width of 550px and reduce the number of colors to 16</span>
<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>chromium-capture <span style="color: #660033;">-resize</span> <span style="color: #000000;">550</span> <span style="color: #660033;">-colors</span> <span style="color: #000000;">16</span></pre></div></div>

<h2>Source Code</h2>
<p><strong>This code is licensed under the <a rel="nofollow" href="http://www.gnu.org/licenses/gpl.txt">GPLv3</a>.</strong><br/><br />
You can download the <strong>source code from <a href="/files/chromium-capture-201001081150.tar.gz">here</a></strong> (<a href="/files/chromium-capture-201001081150.md5sum">md5</a>) or copy it from below.</p>
<h3>chromium-capture</h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    Version: 201001081150</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    Copyright © 2010 Arnaud Soyez (contact me at codealpha.net)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    This program is free software: you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;">#    it under the terms of the GNU General Public License as published by</span>
<span style="color: #666666; font-style: italic;">#    the Free Software Foundation, either version 3 of the License, or</span>
<span style="color: #666666; font-style: italic;">#    (at your option) any later version.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;">#    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;">#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;">#    GNU General Public License for more details.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    You should have received a copy of the GNU General Public License</span>
<span style="color: #666666; font-style: italic;">#    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'`import` will be called with these args: '</span>$<span style="color: #000000; font-weight: bold;">@</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
&nbsp;
<span style="color: #007800;">CHROMIDS</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>xwininfo <span style="color: #660033;">-root</span> -children\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">' - Chromium&quot;: (&quot;chromium-browser&quot; &quot;Chromium-browser&quot;)'</span>\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $1 }'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getViewableId <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;">WINID</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>xwininfo <span style="color: #660033;">-id</span> <span style="color: #007800;">$1</span> -children\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">'^ +0x[0-9A-F]+'</span>\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">fgrep</span> <span style="color: #660033;">-v</span> <span style="color: #ff0000;">'1x1+'</span>\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $1 }'</span>\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span> xwininfo -id\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">'(xwininfo|Map State)'</span>\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'N;s/\
  Map//'</span>\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> IsViewable\
 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $4 }'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$WINID</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> CHROMID <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$CHROMIDS</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">'Capturing window id '</span><span style="color: #007800;">$CHROMID</span><span style="color: #ff0000;">' ...'</span>
  <span style="color: #007800;">FILENAME</span>=chromium-<span style="color: #007800;">$CHROMID</span>.png
  import <span style="color: #660033;">-window</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span> getViewableId <span style="color: #007800;">$CHROMID</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> $<span style="color: #000000; font-weight: bold;">@</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FILENAME</span>&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">' saved as '</span><span style="color: #007800;">$FILENAME</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'Done'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codealpha.net/492/how-to-capture-a-screenshot-with-chromium-command-line/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

