monochromatic

monochromatic blog: http://blog.z3bra.org
git clone git://z3bra.org/monochromatic
Log | Files | Refs

commit 07e6ce25eba10c2beafd9c25b996292779f22213
parent e722726500374283ce875ba652de523f84a5a10c
Author: z3bra <willy@mailoo.org>
Date:   Tue,  1 Apr 2014 10:36:14 +0200

Changed markdown extension and removed HTML files

Diffstat:
2013/08/test-your-css.html | 128-------------------------------------------------------------------------------
2013/08/test-your-css.md | 78------------------------------------------------------------------------------
2013/08/test-your-css.txt | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/08/the-hard-way.html | 143-------------------------------------------------------------------------------
2013/08/the-hard-way.md | 103-------------------------------------------------------------------------------
2013/08/the-hard-way.txt | 103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/09/java-without-eclipse.html | 258-------------------------------------------------------------------------------
2013/09/java-without-eclipse.md | 207-------------------------------------------------------------------------------
2013/09/java-without-eclipse.txt | 207+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/10/home-sweet-home.html | 598-------------------------------------------------------------------------------
2013/10/home-sweet-home.md | 454-------------------------------------------------------------------------------
2013/10/home-sweet-home.txt | 454+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/11/plain-old-mails.html | 276-------------------------------------------------------------------------------
2013/11/plain-old-mails.md | 187-------------------------------------------------------------------------------
2013/11/plain-old-mails.txt | 187+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/12/love-me-some-latex.html | 400-------------------------------------------------------------------------------
2013/12/love-me-some-latex.md | 330-------------------------------------------------------------------------------
2013/12/love-me-some-latex.txt | 330+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014/01/images-in-terminal.html | 273-------------------------------------------------------------------------------
2014/01/images-in-terminal.md | 188-------------------------------------------------------------------------------
2014/01/images-in-terminal.txt | 188+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014/03/toolbox.html | 530-------------------------------------------------------------------------------
2014/03/toolbox.md | 328-------------------------------------------------------------------------------
2014/03/toolbox.txt | 328+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014/03/unleash-your-desktop.md | 22----------------------
2014/03/unleash-your-desktop.txt | 22++++++++++++++++++++++
about.md | 37-------------------------------------
about.txt | 37+++++++++++++++++++++++++++++++++++++
index.md | 50--------------------------------------------------
index.txt | 50++++++++++++++++++++++++++++++++++++++++++++++++++
30 files changed, 1984 insertions(+), 4590 deletions(-)

diff --git a/2013/08/test-your-css.html b/2013/08/test-your-css.html @@ -1,128 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset='utf-8'/> - <link rel='stylesheet' href='/css/monochrome.css'/> - <link rel='stylesheet' href='/css/code.css'/> - <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/> - <title>z3bra.org - monochromatic blog</title> - </head> - <body> - <header> - <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2> - </header> - <div id='wrapper'> - <section> - <h1> - <a href='#'>Test your CSS !</a> - </h1> - <h2> - &mdash; 8 August, 2013 - </h2> - - <article> - <h3>Text Formatting</h3> - <p> - Yay ! Here we are. Here is somethig <em>important</em>. There is also something <strong>strong</strong>.<br /> - We are, of course, in a paragraph. And it contains an inline quotation :<br /> - <cite>Richard M. Stallman</cite> said <q>La cuisine indienne favorise les plats curryeux.</q><br /> - But... What about blockquotes ?! Let's test : - </p> - - <blockquote> - <p> - There are some people who live in a dream world, and there are some who face reality; - and then there are those who turn one into the other. - </p> - &mdash; <cite>Douglas Everett</cite> - </blockquote> - - <p> - That was a fine quote. Now, go on ! - </p> - - <h3>Long texts</h3> - <p> - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - </p> - - <h3>Images</h3> - <p> - <a class='a_img' href='/img/2013-08-ratpoison.jpg'> - <img class='a_img' src='/img/thumb/2013-08-ratpoison.jpg' alt='ratpoison screenshot'/> - </a> - <span class='caption'>&larr; Ratpoison screenshot &mdash; Uses "ratpoison -c set border 28" to make the shot sexier</span> - </p> - - <h3>Tables and code</h3> - <table> - <thead> - <tr> - <th>column #0</th> - <th>column #1</th> - <th>column #2</th> - <th>column #3</th> - <th>column #4</th> - </tr> - </thead> - <tbody> - <tr> <td>cell #0-0</td> <td>cell #0-1</td> <td>cell #0-2</td> <td>cell #0-3</td> <td>cell #0-4</td> </tr> - <tr> <td>cell #1-0</td> <td>cell #1-1</td> <td>cell #1-2</td> <td>cell #1-3</td> <td>cell #1-4</td> </tr> - <tr> <td>cell #2-0</td> <td>cell #2-1</td> <td>cell #2-2</td> <td>cell #2-3</td> <td>cell #2-4</td> </tr> - <tr> <td>cell #3-0</td> <td>cell #3-1</td> <td>cell #3-2</td> <td>cell #3-3</td> <td>cell #3-4</td> </tr> - <tr> <td>cell #4-0</td> <td>cell #4-1</td> <td>cell #4-2</td> <td>cell #4-3</td> <td>cell #4-4</td> </tr> - </tbody> - </table> - - <p> - Pretty nice isn't it ? - </p> - - <p> - Here is some code, using the &lt;pre&gt; tag (remember to escape special chars !) - </p> - - <pre><code>index.html - -<span class="Comment">&lt;!DOCTYPE html&gt;</span> -<span class="Function">&lt;</span><span class="Statement">html</span><span class="Function">&gt;</span> - <span class="Function">&lt;</span><span class="Statement">head</span><span class="Function">&gt;</span> -<span class="PreProc"> </span><span class="Function">&lt;</span><span class="Statement">title</span><span class="Function">&gt;</span><span class="Normal">monochromatic</span><span class="Identifier">&lt;/</span><span class="Statement">title</span><span class="Identifier">&gt;</span> -<span class="PreProc"> </span><span class="Identifier">&lt;/</span><span class="Statement">head</span><span class="Identifier">&gt;</span> - <span class="Function">&lt;</span><span class="Statement">body</span><span class="Function">&gt;</span> - <span class="Function">&lt;</span><span class="Statement">p</span><span class="Function"> </span><span class="Type">id</span><span class="Function">=</span><span class="String">'shblah'</span><span class="Function">&gt;</span> - Hello, World! - <span class="Identifier">&lt;/</span><span class="Statement">p</span><span class="Identifier">&gt;</span> - <span class="Identifier">&lt;/</span><span class="Statement">body</span><span class="Identifier">&gt;</span> -<span class="Identifier">&lt;/</span><span class="Statement">html</span><span class="Identifier">&gt;</span></code></pre> - -<pre><code>main.c - -<span class="PreProc">#include </span><span class="String">&lt;stdio.h&gt;</span> - -<span class="PreProc">#define TEXT </span><span class="String">&quot;Hello, World!&quot;</span> -<span class="PreProc">#define </span><span class="Constant">EXIT_SUCCESS</span><span class="PreProc"> </span><span class="Constant">0</span> - -<span class="Type">int</span> -main (<span class="Type">int</span> argc, <span class="Type">char</span> **argv) -{ - printf(<span class="String">&quot;</span><span class="Special">%s</span><span class="Special">\n</span><span class="String">&quot;</span>, TEXT); - - <span class="Statement">return</span> <span class="Constant">EXIT_SUCCESS</span>; -}</code></pre> - - </article> - </section> - </div> - <!-- footer {{{ --> - <footer> - <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->// - <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->// - <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->// - <a href='http://z3bra.org'>root</a> <!-- &#9774; -->// - <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; --> - </footer> - <!-- }}} --> - </body> -</html> -<!-- vim: set sw=2 et ai fdm=marker ft=html: --> diff --git a/2013/08/test-your-css.md b/2013/08/test-your-css.md @@ -1,78 +0,0 @@ - -# [Test your CSS !](#) -## &mdash; 8 August, 2013 - -### Text Formatting - -Yay ! Here we are. Here is somethig _important_. There is also something **strong**. -We are, of course, in a paragraph. And it contains an inline quotation : -<cite>Richard M. Stallman</cite> said <q>La cuisine indienne favorise les plats curryeux.</q> -But... What about blockquotes ?! Let's test : - -> There are some people who live in a dream world, and there are some who face reality; -> and then there are those who turn one into the other. -> &mdash; <cite>Douglas Everett</cite> - -That was a fine quote. Now, go on ! - -### Long texts - -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - -### Images - -[![ratpoison screenshot](/img/thumb/2013-08-ratpoison.jpg)](/img/2013-08-ratpoison.jpg) -&larr; Ratpoison screenshot &mdash; Uses "ratpoison -c set border 28" to make the shot sexier - -### Tables and code - <table> -<thead> - <tr> - <th>column #0</th> - <th>column #1</th> - <th>column #2</th> - <th>column #3</th> - <th>column #4</th> - </tr> -</thead> - <tbody> - <tr><td>cell 0-0</td><td>cell 0-1</td><td>cell 0-2</td><td>cell 0-3</td><td>cell 0-4</td></tr> - <tr><td>cell 1-0</td><td>cell 1-1</td><td>cell 1-2</td><td>cell 1-3</td><td>cell 1-4</td></tr> - <tr><td>cell 2-0</td><td>cell 2-1</td><td>cell 2-2</td><td>cell 2-3</td><td>cell 2-4</td></tr> - <tr><td>cell 3-0</td><td>cell 3-1</td><td>cell 3-2</td><td>cell 3-3</td><td>cell 3-4</td></tr> - <tr><td>cell 4-0</td><td>cell 4-1</td><td>cell 4-2</td><td>cell 4-3</td><td>cell 4-4</td></tr> - </tbody> -</table> - -Pretty nice isn't it ? - -Here is some code, using the `<pre>` tag (remember to escape special chars !) - -index.html - - <!DOCTYPE html> - <html> - <head> - <title>monochromatic</title> - </head> - <body> - <p id='shblah'>Hello, World!</p> - </body> - </html> - -main.c - - #include <stdio.h> - - #define TEXT "Hello, World!" - #define EXIT_SUCCESS 0 - - int - main (int argc, char **argv) - { - printf("%s\n", TEXT); - - return EXIT_SUCCESS; - } - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/08/test-your-css.txt b/2013/08/test-your-css.txt @@ -0,0 +1,78 @@ + +# [Test your CSS !](#) +## &mdash; 8 August, 2013 + +### Text Formatting + +Yay ! Here we are. Here is somethig _important_. There is also something **strong**. +We are, of course, in a paragraph. And it contains an inline quotation : +<cite>Richard M. Stallman</cite> said <q>La cuisine indienne favorise les plats curryeux.</q> +But... What about blockquotes ?! Let's test : + +> There are some people who live in a dream world, and there are some who face reality; +> and then there are those who turn one into the other. +> &mdash; <cite>Douglas Everett</cite> + +That was a fine quote. Now, go on ! + +### Long texts + +Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +### Images + +[![ratpoison screenshot](/img/thumb/2013-08-ratpoison.jpg)](/img/2013-08-ratpoison.jpg) +&larr; Ratpoison screenshot &mdash; Uses "ratpoison -c set border 28" to make the shot sexier + +### Tables and code + <table> +<thead> + <tr> + <th>column #0</th> + <th>column #1</th> + <th>column #2</th> + <th>column #3</th> + <th>column #4</th> + </tr> +</thead> + <tbody> + <tr><td>cell 0-0</td><td>cell 0-1</td><td>cell 0-2</td><td>cell 0-3</td><td>cell 0-4</td></tr> + <tr><td>cell 1-0</td><td>cell 1-1</td><td>cell 1-2</td><td>cell 1-3</td><td>cell 1-4</td></tr> + <tr><td>cell 2-0</td><td>cell 2-1</td><td>cell 2-2</td><td>cell 2-3</td><td>cell 2-4</td></tr> + <tr><td>cell 3-0</td><td>cell 3-1</td><td>cell 3-2</td><td>cell 3-3</td><td>cell 3-4</td></tr> + <tr><td>cell 4-0</td><td>cell 4-1</td><td>cell 4-2</td><td>cell 4-3</td><td>cell 4-4</td></tr> + </tbody> +</table> + +Pretty nice isn't it ? + +Here is some code, using the `<pre>` tag (remember to escape special chars !) + +index.html + + <!DOCTYPE html> + <html> + <head> + <title>monochromatic</title> + </head> + <body> + <p id='shblah'>Hello, World!</p> + </body> + </html> + +main.c + + #include <stdio.h> + + #define TEXT "Hello, World!" + #define EXIT_SUCCESS 0 + + int + main (int argc, char **argv) + { + printf("%s\n", TEXT); + + return EXIT_SUCCESS; + } + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/08/the-hard-way.html b/2013/08/the-hard-way.html @@ -1,143 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset='utf-8'/> - <link rel='stylesheet' href='/css/monochrome.css'/> - <link rel='stylesheet' href='/css/code.css'/> - <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/> - <title>z3bra.org - monochromatic blog</title> - </head> - <body> - <header> - <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2> - </header> - <div id='wrapper'> - <section> - <h1> - <a href='#'>The Hard way</a> - </h1> - <h2> - &mdash; 9 August, 2013 - </h2> - <article> - - <p> - As you will notice, I am fond of learning things "The Hard Way".<br /> - I'm going to tell you why, but before that, here is my background, so that you'll understand - how I came to that opinion: - </p> - - <ul> - <li><strong>2011, september</strong> &mdash; First attempt at linux, dual-booting Ubuntu 10.10</li> - <li><strong>2012, february</strong> &mdash; Upgrading to Archlinux, single booting</li> - <li><strong>2012, june</strong> &mdash; Obtaining an old computer, and setting it up as a home server</li> - <li><strong>2012, december</strong> &mdash; Switching to Archlinux at work, single booting</li> - <li><strong>2013, july</strong> &mdash; Installing CRUX on my notebook</li> - </ul> - - <p> - I have alway tried to put myself in difficulties, to challenge myself and learn new things.<br /> - During this period, I have searched plenty of tools matching the Unix Philosophy, by <cite>Ken Thompson</cite>: - </p> - - <blockquote> - <p> - Write programs that do one thing and do it well. Write programs to work together. - Write programs to handle text streams, because that is a universal interface. - </p> - </blockquote> - - <p> - This is the reason why I prefer using CLI based tools rather than GUI based ones. I've come to the point where - grabbing the mouse to click on a button is a <em>real</em> pain.<br /> - But let's go back to <strong>the hard way</strong>. - </p> - - <h3 id="what-is-it">What is that ? Can I eat it ?</h3> - <p> - Learning stuff the hard way is (talking about computers), starting using tools or learning stuff, - without a formation, any piece of help, or any hack to make it more simple to use/learn.<br /> - Being put in front of a difficulty will force you to search how something works, how do this or that, and you will - know what not to do after you did it.<br /> - Basically, by learning tstuff his way <strong>you will learn from your mistakes, and understand - what you are doing</strong>. <br /> - To illustrate this, I will use my own experience with a hard to master tool: Vim.<br /> - <br /> - Vim, is an extremly powerful modal text editor. Modal means here that there are multiple modes, each one - made to do different tasks. We see here that it is totally different from the standard text editor everyone knows - (I'm looking at you notepad...).<br /> - Vim is hard to approach, and difficult to master, because of your good ol' reflexes. So it is an excellent tool to - learn how to learn the hard way!<br /> - Here are the basic steps: - </p> - - <ol> - <li>Use it as your <em>main editor</em>, stop using every other alternatives</li> - <li>Use it <em>before</em> starting to configure it</li> - <li>Do not use any plugin <em>at all</em></li> - <li>Don't give up !</li> - </ol> - - <p> - Using Vim this way (at least, at the beginning), will help you mastering the tool faster than learning progressively. - Of course, you could still use the mouse, until you are ready to stop using it, use the arrow keys to move within the - buffer, delete by selecting your text in visual mode, and pressing &lt;SUPPR&gt;.<br /> - But, WHEN will you be ready ? WHEN will you force yourself not to do that ? WHY not doing this now?<br /> - <br /> - I forced myself to use it this way, and after a week or two, I was putting ":wqjk{wB" in every other text editor, - because I were finally comfortable with, and used to Vim. - </p> - - <h3 id='drawbacks'>Drawbacks</h3> - <p> - I see you raising the <q>I can't have a productivity loss at my work</q> card, and you are right. - This method is not shipped with only advantages, and sometimes, you should avoid it. If you think that you can't - handle a productivity loss, postpone the learning for when you will have the time. But don't do that to much, because - you have to be aware that <strong>you will have a productivity loss</strong>. So I will ask a single question:<br /> - <q>Before being ultra-productive, would you rather be totally unproductive for one week, or almost productive - for one month ?</q><br /> - Actually, I have never suffered from that 'bad productivity' the hard way implies. And believe me, it's worth the pain! - </p> - - <p> - This is all about choice. Everybody has his learning curve, find yours!<br /> - If you're not convinced about this. Please try it. You will, at least, have your own opinion, which is great.<br /> - After that, you will be more pleased to tell if the tool is made for you or not, and if you want to make your life - easier. (Show me one Vim user that has choosen to enable the mouse because it enhance his productivity... I dare you - <span class='smiley'>;)</span> ). - </p> - - <h3 id='homeworks'>Homeworks</h3> - <p> - There are a lot of place in the UNIX domain where the hard way can be applied, here are a few examples: - </p> - - <ul> - <li>Write shell script that uses multiple tools to reproduce the behavior of another tool (eg, - <a href='http://tools.suckless.org/ii'>irc it</a>)</li> - <li>Switch from a desktop environnement to a standalone window manager, like <a href='http://www.6809.org.uk/evilwm/'>evilwm</a></li> - <li>When you master a tool, search for another one, less featured</li> - <li>Put yourself in difficulties. Don't be affraid to break things</li> - <li><strong>Break things!</strong></li> - <li>...</li> - </ul> - - <p> - I hope I conviced you, at least, to try it. It might be hard at first, But that's the point. - </p> - - </article> - </section> - </div> - <!-- footer {{{ --> - <footer> - <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->// - <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->// - <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->// - <a href='http://z3bra.org'>root</a> <!-- &#9774; -->// - <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; --> - </footer> - <!-- }}} --> - </body> -</html> -<!-- vim: set sw=2 et ai fdm=marker ft=html: --> diff --git a/2013/08/the-hard-way.md b/2013/08/the-hard-way.md @@ -1,103 +0,0 @@ - -# [The Hard way](#) -## &mdash; 9 August, 2013 - -As you will notice, I am fond of learning things "The Hard Way". -I'm going to tell you why, but before that, here is my background, so that you'll understand -how I came to that opinion: - -* **2011, september** &mdash; First attempt at linux, dual-booting Ubuntu 10.10 -* **2012, february** &mdash; Upgrading to Archlinux, single booting -* **2012, june** &mdash; Obtaining an old computer, and setting it up as a home server -* **2012, december** &mdash; Switching to Archlinux at work, single booting -* **2013, july** &mdash; Installing CRUX on my notebook - -I have alway tried to put myself in difficulties, to challenge myself and learn -new things. During this period, I have searched plenty of tools matching the -Unix Philosophy, by <cite>Ken Thompson</cite>: - -> Write programs that do one thing and do it well. Write programs to work together. -> Write programs to handle text streams, because that is a universal interface. - -This is the reason why I prefer using CLI based tools rather than GUI based -ones. I've come to the point where grabbing the mouse to click on a button is a -_real_ pain. -But let's go back to **the hard way**. - -### What is that ? Can I eat it ? - -Learning stuff the hard way is (talking about computers), starting using tools -or learning stuff, without a formation, any piece of help, or any hack to make -it more simple to use/learn. -Being put in front of a difficulty will force you to search how something -works, how do this or that, and you will know what not to do after you did it. -Basically, by learning tstuff his way **you will learn from your mistakes, and -understand what you are doing**. - -To illustrate this, I will use my own experience with a hard to master tool: -Vim. - -Vim, is an extremly powerful modal text editor. Modal means here that there are -multiple modes, each one made to do different tasks. We see here that it is -totally different from the standard text editor everyone knows (I'm looking at -you notepad...). -Vim is hard to approach, and difficult to master, because of your good ol' -reflexes. So it is an excellent tool to learn how to learn the hard way! -Here are the basic steps: - -1. Use it as your _main editor_, stop using every other alternatives -2. Use it _before_ starting to configure it -3. Do not use any plugin _at all_ -4. Don't give up ! - -Using Vim this way (at least, at the beginning), will help you mastering the -tool faster than learning progressively. Of course, you could still use the -mouse, until you are ready to stop using it, use the arrow keys to move within -the buffer, delete by selecting your text in visual mode, and pressing -`<SUPPR>`. -But, WHEN will you be ready ? WHEN will you force yourself not to do that ? WHY -not doing this now? - -I forced myself to use it this way, and after a week or two, I was putting -":wqjk{wB" in every other text editor, because I were finally comfortable with, -and used to Vim. - -### Drawbacks - -I see you raising the <q>I can't have a productivity loss at my work</q> card, -and you are right. This method is not shipped with only advantages, and -sometimes, you should avoid it. If you think that you can't handle a -productivity loss, postpone the learning for when you will have the time. But -don't do that to much, because you have to be aware that **you will have a -productivity loss**. So I will ask a single question: -<q>Before being ultra-productive, would you rather be totally unproductive for -one week, or almost productive for one month ?</q> -Actually, I have never suffered from that 'bad productivity' the hard way -implies. And believe me, it's worth the pain! - -This is all about choice. Everybody has his learning curve, find yours! -If you're not convinced about this. Please try it. You will, at least, have -your own opinion, which is great. -After that, you will be more pleased to tell if the tool is made for you or -not, and if you want to make your life easier. (Show me one Vim user that has -choosen to enable the mouse because it enhance his productivity... I dare you -;) ). - -### Homeworks - -There are a lot of place in the UNIX domain where the hard way can be applied, -here are a few examples: - -* Write shell script that uses multiple tools to reproduce the behavior of - another tool (eg, [irc it](http://tools.suckless.org/ii)) -* Switch from a desktop environnement to a standalone window manager, like - [evilwm](http://www.6809.org.uk/evilwm/) -* When you master a tool, search for another one, less featured -* Put yourself in difficulties. Don't be affraid to break things -* **Break things!** -* ... - -I hope I conviced you, at least, to try it. It might be hard at first, But -that's the point. - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/08/the-hard-way.txt b/2013/08/the-hard-way.txt @@ -0,0 +1,103 @@ + +# [The Hard way](#) +## &mdash; 9 August, 2013 + +As you will notice, I am fond of learning things "The Hard Way". +I'm going to tell you why, but before that, here is my background, so that you'll understand +how I came to that opinion: + +* **2011, september** &mdash; First attempt at linux, dual-booting Ubuntu 10.10 +* **2012, february** &mdash; Upgrading to Archlinux, single booting +* **2012, june** &mdash; Obtaining an old computer, and setting it up as a home server +* **2012, december** &mdash; Switching to Archlinux at work, single booting +* **2013, july** &mdash; Installing CRUX on my notebook + +I have alway tried to put myself in difficulties, to challenge myself and learn +new things. During this period, I have searched plenty of tools matching the +Unix Philosophy, by <cite>Ken Thompson</cite>: + +> Write programs that do one thing and do it well. Write programs to work together. +> Write programs to handle text streams, because that is a universal interface. + +This is the reason why I prefer using CLI based tools rather than GUI based +ones. I've come to the point where grabbing the mouse to click on a button is a +_real_ pain. +But let's go back to **the hard way**. + +### What is that ? Can I eat it ? + +Learning stuff the hard way is (talking about computers), starting using tools +or learning stuff, without a formation, any piece of help, or any hack to make +it more simple to use/learn. +Being put in front of a difficulty will force you to search how something +works, how do this or that, and you will know what not to do after you did it. +Basically, by learning tstuff his way **you will learn from your mistakes, and +understand what you are doing**. + +To illustrate this, I will use my own experience with a hard to master tool: +Vim. + +Vim, is an extremly powerful modal text editor. Modal means here that there are +multiple modes, each one made to do different tasks. We see here that it is +totally different from the standard text editor everyone knows (I'm looking at +you notepad...). +Vim is hard to approach, and difficult to master, because of your good ol' +reflexes. So it is an excellent tool to learn how to learn the hard way! +Here are the basic steps: + +1. Use it as your _main editor_, stop using every other alternatives +2. Use it _before_ starting to configure it +3. Do not use any plugin _at all_ +4. Don't give up ! + +Using Vim this way (at least, at the beginning), will help you mastering the +tool faster than learning progressively. Of course, you could still use the +mouse, until you are ready to stop using it, use the arrow keys to move within +the buffer, delete by selecting your text in visual mode, and pressing +`<SUPPR>`. +But, WHEN will you be ready ? WHEN will you force yourself not to do that ? WHY +not doing this now? + +I forced myself to use it this way, and after a week or two, I was putting +":wqjk{wB" in every other text editor, because I were finally comfortable with, +and used to Vim. + +### Drawbacks + +I see you raising the <q>I can't have a productivity loss at my work</q> card, +and you are right. This method is not shipped with only advantages, and +sometimes, you should avoid it. If you think that you can't handle a +productivity loss, postpone the learning for when you will have the time. But +don't do that to much, because you have to be aware that **you will have a +productivity loss**. So I will ask a single question: +<q>Before being ultra-productive, would you rather be totally unproductive for +one week, or almost productive for one month ?</q> +Actually, I have never suffered from that 'bad productivity' the hard way +implies. And believe me, it's worth the pain! + +This is all about choice. Everybody has his learning curve, find yours! +If you're not convinced about this. Please try it. You will, at least, have +your own opinion, which is great. +After that, you will be more pleased to tell if the tool is made for you or +not, and if you want to make your life easier. (Show me one Vim user that has +choosen to enable the mouse because it enhance his productivity... I dare you +;) ). + +### Homeworks + +There are a lot of place in the UNIX domain where the hard way can be applied, +here are a few examples: + +* Write shell script that uses multiple tools to reproduce the behavior of + another tool (eg, [irc it](http://tools.suckless.org/ii)) +* Switch from a desktop environnement to a standalone window manager, like + [evilwm](http://www.6809.org.uk/evilwm/) +* When you master a tool, search for another one, less featured +* Put yourself in difficulties. Don't be affraid to break things +* **Break things!** +* ... + +I hope I conviced you, at least, to try it. It might be hard at first, But +that's the point. + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/09/java-without-eclipse.html b/2013/09/java-without-eclipse.html @@ -1,258 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset='utf-8'/> - <link rel='stylesheet' href='/css/monochrome.css'/> - <link rel='stylesheet' href='/css/code.css'/> - <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/> - <title>z3bra.org - monochromatic blog</title> - </head> - <body> - <header> - <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2> - </header> - <div id='wrapper'> - <section> - <h1> - <a href='#'>Java without Eclipse</a> - </h1> - <h2> - &mdash; 08 September, 2013 - </h2> - <article> - <p> - This is a fact, when someone starts developping with java, he (or she) is - given an IDE: Eclipse.<br /> - <br /> - When one codes in C, using plain gcc + Makefile and a good text editor is adviced. - This is the same for C++, bash, ruby, haskell, perl, python, bla bla bla...<br /> - Why would java escape the rules ?!<br /> - </p> - - <ul> - <li>It is hard to play with classpath.</li> - <li>It is boring to compile java by hand</li> - <li>Eclipse is SOOOOOOO good at it !</li> - <li>Eclipse has plenty of plugin to manage a project</li> - <li>bla bla bla...</li> - </ul> - - <p> - Of course, there are advantages ! And if these are good enough for you. Go with eclipse - And have some fun !<br /> - <br /> - </p> - <h3>Throwing Eclipse away</h3> - <p> - For that to be clear, <strong>I am not saying that IDEs are evil ! I am just showing how - you can avoid them, in favor of your daily tools</strong>.<br /> - I just finished a java project for my CS studies, on a bare notebook (without X.org).<br /> - And I had NO PROBLEM with not using Eclipse at all !<br /> - Now let me introduce my setup. Of course, it's not as easy as double-clicking on the - eclipse-setup.exe. but it follows my ideas, and I'm happy with it !<br /> - <br /> - It needs the following: - </p> - - <ul> - <li>Your editor of choice</li> - <li>JRE (O RLY?)</li> - <li>JDK (U DON'T SAY)</li> - <li>Know your shit !</li> - </ul> - - <p> - You just have to know how to compile/run a java project. - Here is what I learnt:<br /> - <strong>javac</strong> is used for compiling, - <strong>java</strong> to run an application.<br /> - javac takes a .java file, and compiles it into a .class file, - that you will run with java. Who needs Eclipse to do that ?!<br /> - <br /> - <q>But real-life project are -a lot- more complicated than that ! - You have to put files in packages, classes in another directory, etc...</q><br /> - <br /> - And you just activated my trap card...<br /> - For sure, real project are a lot more complicated ! For example:<br /> - <br /> - </p> - - <pre><code>~/src/java/eg -├── bin -├── build -│ └── build.xml -├── conf -│ └── server-log4j.properties -├── lib -│ ├── junit-4.11.jar -│ └── log4j-1.2.12.jar -├── src -│ └── com -│ └── irc -│ ├── client -│ │ ├── ClientConnexion.java -│ │ ├── ClientFenetre.java -│ │ ├── Client.java -│ │ └── Client_TEST.java -│ ├── server -│ │ ├── ClientRun.java -│ │ ├── Server.java -│ │ └── Server_TEST.java -│ └── utils -│ ├── Command.java -│ ├── Command_TEST.java -│ ├── Communication.java -│ ├── Communication_TEST.java -│ └── Log.java -└── tags</code></pre> - - <p> - This is what my project looks like. sources are in src/, - classes compiled in bin/. Each source has it's own package.<br /> - <br /> - Let's see how to handle this project, using UNIX as your IDE ! - </p> - <h3>Compilation</h3> - <p> - It probably is the hardest part. Java is hard to compile properly, - so tools like Ant are used in IDEs.<br /> - <br /> - Basicaly, compilation goes like this: - <p> - - <pre><code>javac -d bin/ -sourcepath src/ -classpath bin/ src/com/irc/utils/Command.java</code></pre> - - <p> - -d specifies the directory where your classes will go.<br /> - -sourcepath tells javac where to search for source files.<br /> - -classpath is the same as the abode, but for class files.<br /> - <br /> - Do you see it coming ? <strong>YES</strong>, we will use a Makefile.<br /> - Here is mine: - </p> - - <pre><code><span class="Comment"># Locate directories</span> -<span class="Identifier">class_d</span>=bin -<span class="Identifier">lib_d</span>=lib -<span class="Identifier">source_d</span>=src -<span class="Identifier">package_d</span>=com/irc - -<span class="Comment"># Compilation stuff</span> -<span class="Identifier">JAVAC</span>=javac -<span class="Identifier">JFLAGS</span>=-g -d <span class="Identifier">$(class_d)</span> -sourcepath <span class="Identifier">$(source_d)</span> -Xlint:all - -<span class="Identifier">classpath</span>:=<span class="Identifier">$(class_d)</span>:<span class="Identifier">$(lib_d)</span>/junit-4.11.jar:<span class="Identifier">$(lib_d)</span>/log4j-1.2.12.jar - -<span class="Comment"># If there's already a CLASSPATH, put it on the front</span> -<span class="PreProc">ifneq</span> (<span class="Identifier">$(CLASSPATH)</span>,) -<span class="Identifier"> classpath</span>:= <span class="Identifier">$(CLASSPATH)</span>:<span class="Identifier">$(classpath)</span> -<span class="PreProc">endif</span> - -<span class="Comment"># Re-export the CLASSPATH.</span> -<span class="Statement">export</span> CLASSPATH:=<span class="Identifier">$(classpath)</span> - -<span class="Identifier">MATCH</span>=<span class="String">'.*[^(_TEST)]\.java'</span> - -<span class="PreProc">ifdef</span> TEST -<span class="PreProc"> ifeq</span> (<span class="Identifier">$(TEST)</span>, all) -<span class="Identifier"> MATCH</span>=<span class="String">'.*_TEST\.java'</span> -<span class="PreProc"> else</span> -<span class="Identifier"> MATCH</span>=<span class="String">'.*\/</span><span class="Identifier">$(TEST)</span><span class="String">\/.*_TEST\.java'</span> -<span class="PreProc"> endif</span> -<span class="PreProc">endif</span> - -<span class="Comment"># Find all the source and convert them to class files</span> -<span class="Identifier">S_SERVER</span>= <span class="Identifier">$(</span><span class="Statement">shell</span><span class="Identifier"> find $(source_d)/com/irc/server -regex $(MATCH))</span> -<span class="Identifier">C_SERVER</span>= <span class="Identifier">$(</span><span class="Statement">patsubst</span><span class="Identifier"> src/%.java, bin/%.class, $(S_SERVER))</span> -<span class="Identifier">S_CLIENT</span>= <span class="Identifier">$(</span><span class="Statement">shell</span><span class="Identifier"> find $(source_d)/com/irc/client -regex $(MATCH))</span> -<span class="Identifier">C_CLIENT</span>= <span class="Identifier">$(</span><span class="Statement">patsubst</span><span class="Identifier"> src/%.java, bin/%.class, $(S_CLIENT))</span> -<span class="Identifier">S_UTILS</span>= <span class="Identifier">$(</span><span class="Statement">shell</span><span class="Identifier"> find $(source_d)/com/irc/utils -regex $(MATCH))</span> -<span class="Identifier">C_UTILS</span>= <span class="Identifier">$(</span><span class="Statement">patsubst</span><span class="Identifier"> src/%.java, bin/%.class, $(S_UTILS))</span> - -<span class="Statement">.SUFFIXES:</span> .java .class -<span class="Statement">.PHONY:</span> default server client utils clean init all - -<span class="Function">default:</span> classes - -<span class="Function">$(class_d)/%.class:</span> <span class="Identifier">$(source_d)</span>/<span class="Identifier">%</span>.java -<span class="Special"> @</span><span class="Constant">echo </span><span class="String">&quot;JAVAC </span><span class="Identifier">$&lt;</span><span class="String">&quot;</span> -<span class="Special"> @</span><span class="Identifier">$(JAVAC)</span><span class="Constant"> </span><span class="Identifier">$(JFLAGS)</span><span class="Constant"> </span><span class="Identifier">$&lt;</span> - -<span class="Function">classes:</span> utils server client <span class="Identifier">$(class_d)</span> - -<span class="Function">server:</span> <span class="Identifier">$(C_SERVER)</span> utils -<span class="Function">client:</span> <span class="Identifier">$(C_CLIENT)</span> utils -<span class="Function">utils:</span> <span class="Identifier">$(C_UTILS)</span> - -<span class="Function">all:</span> init classes - -<span class="Identifier">$(class_d)</span><span class="Function">:</span> -<span class="Constant"> mkdir </span><span class="Identifier">$(class_d)</span> - -<span class="Function">clean:</span> -<span class="Constant"> rm -rf </span><span class="Identifier">$(class_d)</span><span class="Constant">/*</span></code></pre> - - <p> - It will search the appropriate sources in your sourcepath, and compile them in the - associated classpath.<br /> - Building the tests appart is done with <code>make TEST=[server|client|utils|all]</code> - And it will compile your code only if it has changed (thanks GNU/make !).<br /> - <br /> - It there you need more explaination on this, mail me your questions ! - </p> - <h3>Running</h3> - <p> - Running your program will be a lot more easier. And you probably know - What I'm going to tell you: <em>shell script</em>.<br /> - <br /> - Simple huh ? You just need to know how to run a java program:<br /> - <code>java -classpath bin/ com.irc.server.Server</code><br /> - Do I really need to explain what -classpath is ..?<br /> - On the other hand, "com.irc.server" is the package containing my - Server class, and "Server" is the class containing the method main().<br /> - <br /> - So you will have no problems building the correct script that will run your - application. It will probably (in its simplest form) look like this:<br /> - </p> - - <pre><code><span class="Comment">#!/bin/sh</span> - -<span class="Identifier">classpath</span>=bin:lib/log4j-1.2.12.jar -<span class="Identifier">package</span>=com.irc.server - -java <span class="Special">-cp</span> <span class="PreProc">$classpath</span> <span class="PreProc">$package.Server</span></code></pre> - - <p> - Isn't that easy ? - </p> - <h3>Conclusion</h3> - <p> - <strong>YOU. DON'T. NEED. ECLIPSE. AT ALL.</strong><br /> - I know that a lot of people will discard me, telling that - This is a pain in the neck to go like this, that you need to know - Makefile, and take the time to write them, etc...<br /> - But these are reusable, and it helps you to know how to manage the - whole process !<br /> - Furthermore, it can be interesting to (at least) try this method, just - to see how it goes.<br /> - You will be able to use every tool you want, git, vim, emacs, - svn, ctags, ...<br /> - <br /> - No needs to get used to the Eclipse interface, and to forget about your - favorite editor ! Isn't that promising ? - </p> - </article> - </section> - </div> - <!-- footer {{{ --> - <footer> - <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->// - <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->// - <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->// - <a href='http://z3bra.org'>root</a> <!-- &#9774; -->// - <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; --> - </footer> - <!-- }}} --> - </body> -</html> -<!-- vim: set sw=2 et ai fdm=marker ft=html: --> diff --git a/2013/09/java-without-eclipse.md b/2013/09/java-without-eclipse.md @@ -1,207 +0,0 @@ - -# [Java without Eclipse](#) -## &mdash; 08 September, 2013 - -This is a fact, when someone starts developping with java, he (or she) is given -an IDE: Eclipse. - -When one codes in C, using plain gcc + Makefile and a good text editor is -adviced. This is the same for C++, bash, ruby, haskell, perl, python, bla bla -bla... -Why would java escape the rules ?! - -* It is hard to play with classpath. -* It is boring to compile java by hand -* Eclipse is SOOOOOOO good at it ! -* Eclipse has plenty of plugin to manage a project -* bla bla bla... - -Of course, there are advantages ! And if these are good enough for you. Go with -eclipse And have some fun ! - -### Throwing Eclipse away - -For that to be clear, **I am not saying that IDEs are evil ! I am just showing -how you can avoid them, in favor of your daily tools**. -I just finished a java project for my CS studies, on a bare notebook (without -X.org). And I had NO PROBLEM with not using Eclipse at all ! -Now let me introduce my setup. Of course, it's not as easy as double-clicking -on the eclipse-setup.exe. but it follows my ideas, and I'm happy with it ! - -It needs the following: - -* Your editor of choice -* JRE (O RLY?) -* JDK (U DON'T SAY) -* Know your shit ! - -You just have to know how to compile/run a java project. Here is what I -learnt: -**javac** is used for compiling, **java** to run an application. -javac takes a .java file, and compiles it into a .class file, that you will run -with java. Who needs Eclipse to do that ?! - -<q>But real-life project are -a lot- more complicated than that ! You have to -put files in packages, classes in another directory, etc...</q> - -And you just activated my trap card... -For sure, real project are a lot more complicated ! For example: - - ~/src/java/eg - ├── bin - ├── build - │ └── build.xml - ├── conf - │ └── server-log4j.properties - ├── lib - │ ├── junit-4.11.jar - │ └── log4j-1.2.12.jar - ├── src - │ └── com - │ └── irc - │ ├── client - │ │ ├── ClientConnexion.java - │ │ ├── ClientFenetre.java - │ │ ├── Client.java - │ │ └── Client_TEST.java - │ ├── server - │ │ ├── ClientRun.java - │ │ ├── Server.java - │ │ └── Server_TEST.java - │ └── utils - │ ├── Command.java - │ ├── Command_TEST.java - │ ├── Communication.java - │ ├── Communication_TEST.java - │ └── Log.java - └── tags - -This is what my project looks like. sources are in src/, classes compiled in -bin/. Each source has it's own package. - -Let's see how to handle this project, using UNIX as your IDE ! - -### Compilation - -It probably is the hardest part. Java is hard to compile properly, so tools -like Ant are used in IDEs. - -Basicaly, compilation goes like this: - - javac -d bin/ -sourcepath src/ -classpath bin/ src/com/irc/utils/Command.java - - -d specifies the directory where your classes will go. - -sourcepath tells javac where to search for source files. - -classpath is the same as the abode, but for class files. - -Do you see it coming ? **YES**, we will use a Makefile. -Here is mine: - - # Locate directories - class_d=bin - lib_d=lib - source_d=src - package_d=com/irc - - # Compilation stuff - JAVAC=javac - JFLAGS=-g -d $(class_d) -sourcepath $(source_d) -Xlint:all - - classpath:=$(class_d):$(lib_d)/junit-4.11.jar:$(lib_d)/log4j-1.2.12.jar - - # If there's already a CLASSPATH, put it on the front - ifneq ($(CLASSPATH),) - classpath:= $(CLASSPATH):$(classpath) - endif - - # Re-export the CLASSPATH. - export CLASSPATH:=$(classpath) - - MATCH='.*[^(_TEST)]\.java' - - ifdef TEST - ifeq ($(TEST), all) - MATCH='.*_TEST\.java' - else - MATCH='.*\/$(TEST)\/.*_TEST\.java' - endif - endif - - # Find all the source and convert them to class files - S_SERVER= $(shell find $(source_d)/com/irc/server -regex $(MATCH)) - C_SERVER= $(patsubst src/%.java, bin/%.class, $(S_SERVER)) - S_CLIENT= $(shell find $(source_d)/com/irc/client -regex $(MATCH)) - C_CLIENT= $(patsubst src/%.java, bin/%.class, $(S_CLIENT)) - S_UTILS= $(shell find $(source_d)/com/irc/utils -regex $(MATCH)) - C_UTILS= $(patsubst src/%.java, bin/%.class, $(S_UTILS)) - - .SUFFIXES: .java .class - .PHONY: default server client utils clean init all - - default: classes - - $(class_d)/%.class: $(source_d)/%.java - @echo &quot;JAVAC $&lt;&quot; - @$(JAVAC) $(JFLAGS) $&lt; - - classes: utils server client $(class_d) - - server: $(C_SERVER) utils - client: $(C_CLIENT) utils - utils: $(C_UTILS) - - all: init classes - - $(class_d): - mkdir $(class_d) - - clean: - rm -rf $(class_d)/* - -It will search the appropriate sources in your sourcepath, and compile them in the -associated classpath. -Building the tests appart is done with `make TEST=[server|client|utils|all]` -And it will compile your code only if it has changed (thanks GNU/make !). - -It there you need more explaination on this, mail me your questions ! - -### Running - -Running your program will be a lot more easier. And you probably know What I'm -going to tell you: _shell script_. - -Simple huh ? You just need to know how to run a java program: - - java -classpath bin/ com.irc.server.Server - -Do I really need to explain what -classpath is ..? -On the other hand, "com.irc.server" is the package containing my Server class, -and "Server" is the class containing the method main(). - -So you will have no problems building the correct script that will run your -application. It will probably (in its simplest form) look like this: - - #!/bin/sh - - classpath=bin:lib/log4j-1.2.12.jar - package=com.irc.server - - java -cp $classpath $package.Server - -Isn't that easy ? - -### Conclusion - -**YOU. DON'T. NEED. ECLIPSE. AT ALL.** - -I know that a lot of people will discard me, telling that This is a pain in the -neck to go like this, that you need to know Makefile, and take the time to -write them, etc... But these are reusable, and it helps you to know how to -manage the whole process ! Furthermore, it can be interesting to (at least) try -this method, just to see how it goes. You will be able to use every tool you -want, git, vim, emacs, svn, ctags, ... - -No needs to get used to the Eclipse interface, and to forget about your -favorite editor ! Isn't that promising ? - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/09/java-without-eclipse.txt b/2013/09/java-without-eclipse.txt @@ -0,0 +1,207 @@ + +# [Java without Eclipse](#) +## &mdash; 08 September, 2013 + +This is a fact, when someone starts developping with java, he (or she) is given +an IDE: Eclipse. + +When one codes in C, using plain gcc + Makefile and a good text editor is +adviced. This is the same for C++, bash, ruby, haskell, perl, python, bla bla +bla... +Why would java escape the rules ?! + +* It is hard to play with classpath. +* It is boring to compile java by hand +* Eclipse is SOOOOOOO good at it ! +* Eclipse has plenty of plugin to manage a project +* bla bla bla... + +Of course, there are advantages ! And if these are good enough for you. Go with +eclipse And have some fun ! + +### Throwing Eclipse away + +For that to be clear, **I am not saying that IDEs are evil ! I am just showing +how you can avoid them, in favor of your daily tools**. +I just finished a java project for my CS studies, on a bare notebook (without +X.org). And I had NO PROBLEM with not using Eclipse at all ! +Now let me introduce my setup. Of course, it's not as easy as double-clicking +on the eclipse-setup.exe. but it follows my ideas, and I'm happy with it ! + +It needs the following: + +* Your editor of choice +* JRE (O RLY?) +* JDK (U DON'T SAY) +* Know your shit ! + +You just have to know how to compile/run a java project. Here is what I +learnt: +**javac** is used for compiling, **java** to run an application. +javac takes a .java file, and compiles it into a .class file, that you will run +with java. Who needs Eclipse to do that ?! + +<q>But real-life project are -a lot- more complicated than that ! You have to +put files in packages, classes in another directory, etc...</q> + +And you just activated my trap card... +For sure, real project are a lot more complicated ! For example: + + ~/src/java/eg + ├── bin + ├── build + │ └── build.xml + ├── conf + │ └── server-log4j.properties + ├── lib + │ ├── junit-4.11.jar + │ └── log4j-1.2.12.jar + ├── src + │ └── com + │ └── irc + │ ├── client + │ │ ├── ClientConnexion.java + │ │ ├── ClientFenetre.java + │ │ ├── Client.java + │ │ └── Client_TEST.java + │ ├── server + │ │ ├── ClientRun.java + │ │ ├── Server.java + │ │ └── Server_TEST.java + │ └── utils + │ ├── Command.java + │ ├── Command_TEST.java + │ ├── Communication.java + │ ├── Communication_TEST.java + │ └── Log.java + └── tags + +This is what my project looks like. sources are in src/, classes compiled in +bin/. Each source has it's own package. + +Let's see how to handle this project, using UNIX as your IDE ! + +### Compilation + +It probably is the hardest part. Java is hard to compile properly, so tools +like Ant are used in IDEs. + +Basicaly, compilation goes like this: + + javac -d bin/ -sourcepath src/ -classpath bin/ src/com/irc/utils/Command.java + + -d specifies the directory where your classes will go. + -sourcepath tells javac where to search for source files. + -classpath is the same as the abode, but for class files. + +Do you see it coming ? **YES**, we will use a Makefile. +Here is mine: + + # Locate directories + class_d=bin + lib_d=lib + source_d=src + package_d=com/irc + + # Compilation stuff + JAVAC=javac + JFLAGS=-g -d $(class_d) -sourcepath $(source_d) -Xlint:all + + classpath:=$(class_d):$(lib_d)/junit-4.11.jar:$(lib_d)/log4j-1.2.12.jar + + # If there's already a CLASSPATH, put it on the front + ifneq ($(CLASSPATH),) + classpath:= $(CLASSPATH):$(classpath) + endif + + # Re-export the CLASSPATH. + export CLASSPATH:=$(classpath) + + MATCH='.*[^(_TEST)]\.java' + + ifdef TEST + ifeq ($(TEST), all) + MATCH='.*_TEST\.java' + else + MATCH='.*\/$(TEST)\/.*_TEST\.java' + endif + endif + + # Find all the source and convert them to class files + S_SERVER= $(shell find $(source_d)/com/irc/server -regex $(MATCH)) + C_SERVER= $(patsubst src/%.java, bin/%.class, $(S_SERVER)) + S_CLIENT= $(shell find $(source_d)/com/irc/client -regex $(MATCH)) + C_CLIENT= $(patsubst src/%.java, bin/%.class, $(S_CLIENT)) + S_UTILS= $(shell find $(source_d)/com/irc/utils -regex $(MATCH)) + C_UTILS= $(patsubst src/%.java, bin/%.class, $(S_UTILS)) + + .SUFFIXES: .java .class + .PHONY: default server client utils clean init all + + default: classes + + $(class_d)/%.class: $(source_d)/%.java + @echo &quot;JAVAC $&lt;&quot; + @$(JAVAC) $(JFLAGS) $&lt; + + classes: utils server client $(class_d) + + server: $(C_SERVER) utils + client: $(C_CLIENT) utils + utils: $(C_UTILS) + + all: init classes + + $(class_d): + mkdir $(class_d) + + clean: + rm -rf $(class_d)/* + +It will search the appropriate sources in your sourcepath, and compile them in the +associated classpath. +Building the tests appart is done with `make TEST=[server|client|utils|all]` +And it will compile your code only if it has changed (thanks GNU/make !). + +It there you need more explaination on this, mail me your questions ! + +### Running + +Running your program will be a lot more easier. And you probably know What I'm +going to tell you: _shell script_. + +Simple huh ? You just need to know how to run a java program: + + java -classpath bin/ com.irc.server.Server + +Do I really need to explain what -classpath is ..? +On the other hand, "com.irc.server" is the package containing my Server class, +and "Server" is the class containing the method main(). + +So you will have no problems building the correct script that will run your +application. It will probably (in its simplest form) look like this: + + #!/bin/sh + + classpath=bin:lib/log4j-1.2.12.jar + package=com.irc.server + + java -cp $classpath $package.Server + +Isn't that easy ? + +### Conclusion + +**YOU. DON'T. NEED. ECLIPSE. AT ALL.** + +I know that a lot of people will discard me, telling that This is a pain in the +neck to go like this, that you need to know Makefile, and take the time to +write them, etc... But these are reusable, and it helps you to know how to +manage the whole process ! Furthermore, it can be interesting to (at least) try +this method, just to see how it goes. You will be able to use every tool you +want, git, vim, emacs, svn, ctags, ... + +No needs to get used to the Eclipse interface, and to forget about your +favorite editor ! Isn't that promising ? + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/10/home-sweet-home.html b/2013/10/home-sweet-home.html @@ -1,598 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset='utf-8'/> - <link rel='stylesheet' href='/css/monochrome.css'/> - <link rel='stylesheet' href='/css/code.css'/> - <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/> - <title>z3bra.org - monochromatic blog</title> - </head> - <body> - <header> - <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2> - </header> - <div id='wrapper'> - <section> - <h1> - <a href='#'>Home, sweet home</a> - </h1> - <h2> - &mdash; 28 October, 2013 - </h2> - <article> - <h3>Summary</h3> - <p> - Yes, a summary, because that's gonna be a LONG article. - </p> - <ul> - <li><a href="#intro">Introduction</a></li> - <li><a href="#wm">Window manager</a></li> - <li><a href="#term">Terminal</a></li> - <li><a href="#sh">Shell</a></li> - <li><a href="#cli">CLI tools</a></li> - <li><a href="#bar">Status bar</a></li> - <li><a href="#setup">Integration</a></li> - </ul> - - <hr/> - <h3 id="intro">Introduction</h3> - <p> - Okay, so you have finally installed your distro of choice, cleaned - the whole setup, installed X.org, xterm and vim...<br /> - <br /> - <strong>And now, what?!</strong> - </p> - <p> - I've asked myself this question more than I should (probably because - I liking tweaking my desktop, but that's not the point here).<br /> - And I bet that you did too ! - </p> - <p> - In this post, I'll go through all the mandatory tweak that should be - done to a clean base system. YOUR system, 'cause there is no place - like home.<br /> - Once standing in your ~, starring at your shell prompt, you should - be like <q>Uuuh that is life, eh!</q> - </p> - <p> - I'll not wait more to give you my secrets, but please, keep in mind - that these are <em>MY OPINIONS</em> and I'm not asking you to agree - with me. If you feel uncomfortable with some points, just avoid - them. You're not here to feel bad, but to find advices on - <strong>setting up your home!</strong> - </p> - - <hr/> - <h3 id="wm">Window manager</h3> - <p> - This is the most important part of your future environment. It is - the god that will tell all your windows where to go, how to move, - etc.. So you can take a little time to choose a WM, it totally - understandable. - </p> - <p> - There are three types of window managers: - </p> - <ul> - <li><strong>Floating</strong> &mdash; windows overlaps</li> - <li><strong>Tilling</strong> &mdash; windows are arranged in tiles - (kinda like a grid)</li> - <li><strong>Dynamics</strong> &mdash; both floating and tilling - are possible</li> - <li><strong>Aliens</strong> &mdash; Go home WM, you're drunk.</li> - </ul> - <p> - Floating management is the management style we're all used to, - windows are independent and you can resize/move them freely around - your desktop.<br /> - Tilled window managers arrange the windows depending on what is - currently on your desktop. The windows <em>CAN'T</em> overlap. When - you create a new window, the whole set of window is rearranging to - let the new window find a place (Not always in fact, but that's the - idea behind tilling).<br /> - Finally, dynamic WM can switch between the two managment styles - (most of the time, at cost of complexity and binary size, but that's - just my opinion). Note that most tilling WM are, in fact, dynamic - WM. But the way they manage floating windows is just so poor...<br /> - <br /> - Oh, and for the alien part, keep in mind that some WM just don't - manage windows like that. But their behaviors are to specific to be - described here. Just RTFM 'em. - </p> - <p> - FYI, here is a non-exhaustive list of window managers I like (F = - floating, T = tilling, D = dynamic... U DON'T SAY!) - </p> - <ul> - <li>cwm &mdash; Calm Window Manager (F)</li> - <li>Ratpoison (A)</li> - <li>ctwm (F)</li> - <li>herbstluftwm (T) (<q>Hebrstrutoflutudobleyouhem</q>)</li> - <li>evilwm (F)</li> - <li>xmonad (D)</li> - <li>spectrwm (T)</li> - <li>...</li> - </ul> - <p> - - Note that I <em>DIDN'T</em> mentioned AwesomeWM or openbox. beuâh. - </p> - <p> - Once you have chosen your WM, go through its manpage/doc, set it up - to look the way you want. Use stuff like <a - href="http://gnome-look.org/content/show.php/Another+Gtk+RGBA+module+?content=100968">librgba</a>, - <a href="https://github.com/chjj/compton">compton</a> to make it - even prettier!<br /> - - <a class='a_img' href='/img/2013-10-28-cwm.jpg'> - <img class='a_img' src='/img/thumb/2013-10-28-cwm.jpg' alt='cwm screenshot'/> - </a> - <span class="caption">Here is a quick CWM setup, using compton and - librgba</span> - </p> - <p> - Oh! A last advice, <strong>do not bind applications through your WM</strong>. Using an application like <a href="http://www.nongnu.org/xbindkeys/xbindkeys.html">xbindkeys</a> to do that is a better idea, as it follow the <a href="http://www.faqs.org/docs/artu/ch01s06.html">UNIX philosophy</a>, and it will help you a lot if you want to try another WM. - </p> - - <hr/> - <h3 id="term">Terminal</h3> - <p> - Here we are. The terminal. The central part of the whole setup! - <br /> - As an advanced user, you spend a lot of time within the terminal, - so it is important to keep your terminal a pleasant place for your - eyes.<br /> - There are, in fact, only two ways to tweak your terminal: - <strong>colors and font</strong>. The goal is to find the best - readability/usability/awesomeness ratio.<br /> - I'd recommend that you start from a dark scheme, as it's better for - your eyes by night (But that's just my opinion, light colorschemes - can look pretty good!).<br /> - Terminals usually manage up to 256 colors, but you will use only 16 - of them:<br /> - &rarr; [0-7] for normal text<br /> - &rarr; [8-15] for bold text<br /> - Here is the color chart: - </p> - - <table> - <tr> - <th></th> - <th>black</th> - <th>red</th> - <th>green</th> - <th>yellow</th> - <th>blue</th> - <th>magenta</th> - <th>cyan</th> - <th>white</th> - </tr> - <tr> - <th>dark</th> - <td>00</td> - <td>01</td> - <td>02</td> - <td>03</td> - <td>04</td> - <td>05</td> - <td>06</td> - <td>07</td> - </tr> - <tr> - <th>light</th> - <td>08</td> - <td>09</td> - <td>10</td> - <td>11</td> - <td>12</td> - <td>13</td> - <td>14</td> - <td>15</td> - </tr> - </table> - - <p> - Now, just tweak each color to fit your perfect theme!<br /> - To do so, refer to the manual of your terminal. - </p> - <p> - If you don't have one, here is a list of terminal you can use: - </p> - <ul> - <li><a href="http://software.schmorp.de/pkg/rxvt-unicode.html">rxvt-unicode</a></li> - <li><a href="https://github.com/thestinger/termite/">termite</a></li> - <li><a href="http://www.calno.com/evilvte/">evilvte</a> - <li><a href="http://www.afterstep.org/aterm.php">aterm</a> - <li><a href="http://freecode.com/projects/mterm">mterm</a> - </ul> - - <p> - I have stick with rxvt-unicode (urxvt) personnally. I find it pretty - powerfull, light and fast. Also, it can be extended in perl, which - is great (muh URL selection). - </p> - <p> - Back to terminal colors! The best way I know to change the terminal - colorscheme, is using the X server resource database (xrdb). But it - does not work with every terminal (it works, at least, with xterm and - urxvt).<br /> - All you have to do, is configure your colors in a file called - <code>~/.Xresources</code>, and source it with the command: - </p> - - <pre><code>xrdb -load ~/.Xresources</code></pre> - - <p> - For example, here is mine (screenshot at the end of the section): - </p> - - <pre><code>Xresources - -*background:#222222 -*foreground:#e8e9ca - -*color0: #222222 -*color1: #8b3e2f -*color2: #526f33 -*color3: #665847 -*color4: #4a708b -*color5: #7a378b -*color6: #528b8b -*color7: #999999 - -*color8: #4c4c4c -*color9: #d75f00 -*color10: #cee318 -*color11: #eee685 -*color12: #9ac0cd -*color13: #9f79ee -*color14: #79cdcd -*color15: #e8e9ca</code></pre> - - <p> - For the font, it's quite the same, but I suggest that you search for - the terms <em>xft font</em>, <em>bitmap fonts</em> and <em>X - resources</em> cause it can be a little tricky to understand. - <br /> - Quickly, there are two way to draw fonts in your terminal, with, and - without xft. XFT allows you to draw nice fonts and scale them the - way you want, like BitStream Vera Sans, Monospace, etc... But these - are "slow" to draw. - The other method is the one used by TTY, bitmap fonts. Those are - fixed pixeled font that can look odd, but draw fastly.<br /> - Just make a choice.<br /> - To declare a XFT font: - </p> - - <pre><code>xft:&lt;font name&gt;:size=&lt;size&gt;</code></pre> - - <p> - Bitmap font are declared like this (taken from <code>xfontsel - -print</code>, thanks to <a href="http://www.reddit.com/r/unixporn/comments/1pf6p4/howto_build_your_graphical_environment_piece_by/cd200mg">Gnu42</a> for the package). - You can then use the <code>xfontsel</code> package, or look for a - file named <code>fonts.dir</code> in your font directory. - </p> - - <pre><code>-fndry-fmly-wght-slant-sWdth-astyl-pxlsz-ptSz-resx-resy-spc-avgWdth-rgstry-encdng</code></pre> - - <p> - Here is a small example: - </p> - - <pre><code>Xresources - -*font: xft:monospace:size=10 -*font: -misc-tamsyn-medium-*-*--14-101-*-*-*-*-*</code></pre> - - <p> - So, we have seen how to tweak the terminal, let's see what it looks - like! - I wrote a small script for the purpose:<br /> - <br /> - <a class='a_img' href='/img/2013-10-28-term.jpg'> - <img class='a_img' src='/img/thumb/2013-10-28-term.jpg' alt='term screenshot'/> - </a> - <span class="caption">A terminal running the script <a href="http://git.z3bra.org/cgit.cgi/scripts/tree/info.sh">info.sh</a> that dump 16 colors along system informations</span> - </p> - - <hr/> - <h3 id="sh">Shell</h3> - <p> - right after seeing the terminal, you can't avoid it's main program: - <strong>the shell</strong>.<br /> - If you don't know this already, the shell is the link between the - user and the programs. It's a program you will communicate with to - manipulate your system. An important program tough.<br /> - Choose it carefully then. Here is the main shell list: - </p> - - <ul> - <li>sh &mdash; The historical shell</li> - <li>bash &mdash; Improved shell, based on sh</li> - <li>zsh &mdash; An extremly powerfull shell with a great - completion system</li> - <li>fish &mdash; A user friendly shell, really different from the - above</li> - <li>csh &mdash; The Berkeley UNIX shell</li> - <li>tcsh &mdash; An improvement of csh</li> - </ul> - - <p> - I personnaly used zsh a lot because it has a feature I like, - the right prompt. also, it's completion system is really great - (argument completion is a good thing to have, trust me..). But I now - use bash again because I don't need much of the features zsh - provide, so that was kinda like using a chainsaw to cut a thin rope. - <br /> - - Anyway, I'll treat here only the "standard shell": bash <br /> - - The first thing you will see from the shell is its prompt. The - prompt is a set of characters that gives info to the user, and - invite him to input commands. Basically, it looks like this: - </p> - - <pre><code>$ </code></pre> - - <p> - Fancy huh ? - The prompt chars are contained in the variable <code>PS1</code> for - sh/bash, and <code>PROMPT</code>/<code>RPROMPT</code> for zsh. - </p> - - <pre><code>$ PS1='z3bra-$ ' -z3bra-$</code></pre> - - <p> - (You don't have to issue the two command to make it works.) - Take a look at the bash manpage, section "Prompting" for more info - on how to tweak it. - Here is my personnal prompt: - </p> - - <pre><code>bashrc - -<span class="Comment"># Fancy prompt</span> -<span class="Statement">fg</span><span class="Statement">=</span><span class="PreProc">(</span><span class="Statement">'</span><span class="String">\[\e[0;30m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[0;31m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[0;32m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[0;33m\]</span><span class="Statement">'</span> -<span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[0;34m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[0;35m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[0;36m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[0;37m\]</span><span class="Statement">'</span> -<span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[1;30m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[1;31m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[1;32m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[1;33m\]</span><span class="Statement">'</span> -<span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[1;34m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[1;35m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[1;36m\]</span><span class="Statement">'</span><span class="Special"> </span><span class="Statement">'</span><span class="String">\[\e[1;37m\]</span><span class="Statement">'</span><span class="PreProc">)</span> -<span class="Identifier">nofg</span>=<span class="Statement">'</span><span class="String">\[\e[0m\]</span><span class="Statement">'</span> - -<span class="Identifier">PS1</span>=<span class="Statement">''</span>;<span class="Statement">[</span> <span class="Statement">-n</span> <span class="Statement">&quot;</span><span class="PreProc">$SSH_CLIENT</span><span class="Statement">&quot;</span> <span class="Statement">]</span> &amp;&amp; <span class="Identifier">PS1</span>=<span class="Statement">&quot;</span><span class="PreProc">${</span><span class="PreProc">fg</span><span class="PreProc">[</span><span class="Constant">8</span><span class="PreProc">]</span><span class="PreProc">}</span><span class="PreProc">$(</span><span class="Special">hostname|cut </span><span class="Special">-b-2</span><span class="PreProc">)</span><span class="String"> </span><span class="Statement">&quot;</span> -<span class="Statement">export</span><span class="Identifier"> PS1=</span><span class="Statement">&quot;</span><span class="String"> </span><span class="PreProc">${</span><span class="PreProc">PS1</span><span class="PreProc">}${</span><span class="PreProc">fg</span><span class="PreProc">[</span><span class="Constant">11</span><span class="PreProc">]</span><span class="PreProc">}</span><span class="String">──── </span><span class="PreProc">${</span><span class="PreProc">nofg</span><span class="PreProc">}</span><span class="Statement">&quot;</span></code></pre> - - <p> - And my old zsh prompt: - </p> - - <pre><code>zshrc - -<span class="Identifier">PROMPT</span>=<span class="Statement">&quot;</span> <span class="String">%{</span><span class="PreProc">$fg_bold</span><span class="String">[yellow]%} » </span><span class="Statement">&quot;</span> -<span class="Identifier">RPROMPT</span>=<span class="Statement">&quot;</span><span class="String">%{</span><span class="PreProc">$fg</span><span class="String">[black]%}%M:%{</span><span class="PreProc">$fg_bold</span><span class="String">[yellow]%}%~%{</span><span class="PreProc">$reset_color</span><span class="String">%} </span><span class="Statement">&quot;</span></code></pre> - - <p> - <a class='a_img' href='/img/2013-10-28-shell.jpg'> - <img class='a_img' src='/img/thumb/2013-10-28-shell.jpg' alt='shell screenshot'/> - </a> - <span class="caption">A few different prompts, from top to bottom: - sh, zsh, bash, zsh</span> - </p> - - <hr/> - <h3 id="cli">CLI tools</h3> - <p> - The shell is the core of a UNIX/Linux based system. So having a - bunch of fast, light and efficient CLI tools is a must. There are - applications for (almost) everything you do on a daily basis with - you computer: IRC clients, Text editor, Video games, Web browsers, - image viewer, ...<br /> - <br /> - Okay, I agree that some of them are not really practical to use - everyday. Mostly when it involve images (web lurking, image - processing, gaming, ...).<br /> - But when you don't need images, <strong>unleash your - shell!</strong><br /> - Use CLI based app for text-based task. It has many advantages: - </p> - - <ul> - <li>ALWAYS fit your colorscheme (see <a - href="#terminal">Terminal</a>)</li> - <li>Focus on usability</li> - <li>Integrate well with your whole setup</li> - <li>This is fast as hell</li> - <li>This is powerfull as hell</li> - <li><span class='strike'>You look like a hacker</span></li> - </ul> - - <p> - I personnaly use <a href="http://vim.org">vim</a>, <a - href="http://irssi.org">irssi</a> and <a - href="http://mutt.org">mutt</a> on a daily basis.<br /> - As an alternative, take a look at <a - href="https://www.gnu.org/software/emacs/">emacs</a>, <a - href="http://weechat.org/">weechat</a> and <a - href="http://sourceforge.net/projects/re-alpine/">Alpine</a>. - <br /> - <br /> - <a class='a_img' href='/img/2013-10-28-cli.jpg'> - <img class='a_img' src='/img/thumb/2013-10-28-cli.jpg' alt='cwm screenshot'/> - </a> - <span class="caption"> - Mandatory screenshot of the setup with those apps (and custom - themes).<br /> - top-left: <strong>vim</strong><br /> - top-right: <strong>mutt</strong><br /> - bottom-left: <strong>tmux</strong><br /> - bottom-right: <strong>irssi</strong><br /> - </span> - </p> - - <hr/> - <h3 id="bar">Status bar</h3> - <p> - All of this is great, but I think that if you want to check the - time, you're not willing to open a terminal, and type: - </p> - - <pre><code>date +%H:%M</code></pre> - - <p> - It's not really practical most of the time. The same can apply to - the amount of free space, to current volume level or the number of - unread mails you have.<br /> - That's what status bar are made for. They pick infos for you and - display them in a thin bar on an edge of your screen.<br /> - - My bar of choice is, by far, <a - href="https://github.com/LemonBoy/bar">bar ain't recursive</a>, by - Lemon Boy.<br /> - It is light, fast and simple. Exactly how I like it! - the purpose is simple: - </p> - - <ol> - <li>Write a script that output a bunch of informations</li> - <li>Pipe that script into the bar</li> - <li>Run them within an infinite loop!</li> - </ol> - - <p> - That is all you need. For example, if you only need the date in the bar: - </p> - - <pre><code>while :; do date; done | bar &amp;</code></pre> - - <p> - And there you go! - You can achieve really great looking stuff with that simple - process:<br /> - <br /> - <a class='a_img' href='/img/2013-10-28-bar.jpg'> - <img class='a_img' src='/img/thumb/2013-10-28-bar.jpg' alt='bar screenshot'/> - </a> - <span class="caption">You can also choose to put your status bar - within a terminal multiplexer status bar, <a - href="http://calummacrae.blogspot.fr/2012/12/dropping-status-bars-for-tmux-as-im.html">as phyrne suggested</a> in - one of his blog post</span> - </p> - - <hr/> - <h3 id="setup">Integration</h3> - <p> - Now that we potentially have a working desktop, let make it spawn - correctly, using ONLY one file: <code>~/.xinitrc</code>. - <br /> - That magical file is simply a shell script that is called by default - with <code>startx</code>. - In fact, when you proceed this command, it does the following: - </p> - - <pre><code>$ startx ~/.xinitrc -- :0</code></pre> - - <p> - It source your ~/.xinitrc, and launch it on the Xorg server number - 0. - To launch your wm of choice from the xinitrc, just add the command - to launch it in the file, preceded by 'exec'. It will replace the - current process (your shell) by the window manager, so that the - session will terminate with your WM.<br /> - </p> - <p> - Okay, now you have the theory. Before starting to pratice, I'll give - you a few hints for a "good" xinitrc (yeah, I love making lists): - </p> - <ul> - <li>Launch ONLY session related commands</li> - <li>Make it evolutive, so that you can spawn multiple X sessions - at the same time</li> - <li>Fork every command, except those that are dependent, to speed - up the desktop spawning</li> - </ul> - - <p> - Finally, here is my own xinitrc - </p> - - <pre><code>xinitrc - -<span class="Comment">#!/bin/bash</span> -<span class="Comment">#</span> -<span class="Comment"># ~/.xinitrc</span> -<span class="Comment">#</span> - -<span class="Comment"># load nvidia config</span> -nvidia-settings <span class="Special">-l</span> - -<span class="Comment"># Set wallpaper</span> -hsetroot <span class="Special">-tile</span> ~/usr/img/<span class="Statement">bg</span>/stripes.png &amp; - -<span class="Comment"># default cursor</span> -xsetroot <span class="Special">-cursor_name</span> left_ptr &amp; - -<span class="Function">function</span> <span class="Function">wm() {</span> - <span class="Comment"># Load X resources</span> - xrdb <span class="Special">-load</span> ~/.Xresources <span class="Statement">&amp;</span> - - <span class="Comment"># personnal bindings</span> - xbindkeys - - <span class="Comment"># set WM name</span> - xsetroot <span class="Special">-name</span> <span class="PreProc">$1</span> - - <span class="Comment">#status bar</span> - ~/bin/bar/status.sh <span class="Statement">&amp;</span> <span class="Comment"># it acts kinda weirdly</span> - - <span class="Comment"># Compositing</span> - <span class="Comment"># enable RGBA module for GTK</span> - <span class="Statement">export</span><span class="Identifier"> GTK_MODULES=</span>rgba - - <span class="Comment">#compton -cCb -t-5 -l-5 -r4.2 -o.4</span> - compton <span class="Special">-cb</span> <span class="Special">-o0</span> - - <span class="Comment"># spawn window manager</span> - <span class="Statement">exec</span> <span class="PreProc">$1</span> -<span class="Function">}</span> - -<span class="Special">[[</span> <span class="Statement">-z</span> <span class="PreProc">$1</span> <span class="Special">]]</span> &amp;&amp; wm cwm - -wm <span class="PreProc">$1</span></code></pre> - - <p> - <a class='a_img' href='/img/2013-10-28-final.jpg'> - <img class='a_img' src='/img/thumb/2013-10-28-final.jpg' alt='final screenshot'/> - </a> - <span class="caption">That shot show off the whole setup, with - prompt, bar, applications, etc... - I hope you will like it! - </span> - </p> - - <hr/> - <h3 id="end">Conclusion</h3> - <p> - The end, finally. That is a damn long article. I have deliberately - not expanded some point by lack of "space". I want this article to - end someday.<br /> - It will give you a good start to tweak your own setup, and make it - look like what you want it to look.<br /> - <br /> - <strong>Make your environment yours, and have fun doing so!</strong> - </p> - - </article> - </section> - </div> - <!-- footer {{{ --> - <footer> - <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->// - <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->// - <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->// - <a href='http://z3bra.org'>root</a> <!-- &#9774; -->// - <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; --> - </footer> - <!-- }}} --> - </body> -</html> -<!-- vim: set sw=2 et ai fdm=marker ft=html: --> diff --git a/2013/10/home-sweet-home.md b/2013/10/home-sweet-home.md @@ -1,454 +0,0 @@ -# [Home, sweet home](#) -## &mdash; 28 October, 2013 - -### Summary - -Yes, a summary, because that's gonna be a LONG article. - -* [Introduction](#intro) -* [Window manager](#wm) -* [Terminal](#term) -* [Shell](#sh) -* [CLI tools](#cli) -* [Status bar](#bar) -* [Integration](#setup) - -### Introduction - -Okay, so you have finally installed your distro of choice, cleaned -the whole setup, installed X.org, xterm and vim... - -**And now, what?!** - -I've asked myself this question more than I should (probably because -I liking tweaking my desktop, but that's not the point here). -And I bet that you did too ! - -In this post, I'll go through all the mandatory tweak that should be -done to a clean base system. YOUR system, 'cause there is no place -like home. -Once standing in your ~, starring at your shell prompt, you should -be like <q>Uuuh that is life, eh!</q> - -I'll not wait more to give you my secrets, but please, keep in mind -that these are _MY OPINIONS_ and I'm not asking you to agree -with me. If you feel uncomfortable with some points, just avoid -them. You're not here to feel bad, but to find advices on -**setting up your home!** - -### Window manager - -This is the most important part of your future environment. It is -the god that will tell all your windows where to go, how to move, -etc.. So you can take a little time to choose a WM, it totally -understandable. - -There are three types of window managers: - -* **Floating** &mdash; windows overlaps -* **Tilling** &mdash; windows are arranged in tiles (kinda like a grid) -* **Dynamics** &mdash; both floating and tilling are possible -* **Aliens** &mdash; Go home WM, you're drunk. - -Floating management is the management style we're all used to, -windows are independent and you can resize/move them freely around -your desktop. -Tilled window managers arrange the windows depending on what is -currently on your desktop. The windows _CAN'T_ overlap. When -you create a new window, the whole set of window is rearranging to -let the new window find a place (Not always in fact, but that's the -idea behind tilling). -Finally, dynamic WM can switch between the two managment styles -(most of the time, at cost of complexity and binary size, but that's -just my opinion). Note that most tilling WM are, in fact, dynamic -WM. But the way they manage floating windows is just so poor... - -Oh, and for the alien part, keep in mind that some WM just don't -manage windows like that. But their behaviors are to specific to be -described here. Just RTFM 'em. - -FYI, here is a non-exhaustive list of window managers I like (F = -floating, T = tilling, D = dynamic... U DON'T SAY!) - -* cwm &mdash; Calm Window Manager (F) -* Ratpoison (A) -* ctwm (F) -* herbstluftwm (T) (<q>Hebrstrutoflutudobleyouhem</q>) -* evilwm (F) -* xmonad (D) -* spectrwm (T) -* ... - -Note that I _DIDN'T_ mentioned AwesomeWM or openbox. beuâh. - -Once you have chosen your WM, go through its manpage/doc, set it up -to look the way you want. Use stuff like [librgba](http://gnome-look.org/content/show.php/Another+Gtk+RGBA+module+?content=100968), -[compton](https://github.com/chjj/compton) to make it -even prettier! - -[![cwm screenshot](/img/thumb/2013-10-28-cwm.jpg)](/img/2013-10-28-cwm.jpg) -Here is a quick CWM setup, using compton and librgba - -Oh! A last advice, **do not bind applications through your WM**. Using an -application like [xbindkeys](http://www.nongnu.org/xbindkeys/xbindkeys.html) to -do that is a better idea, as it follow the -[UNIX philosophy](http://www.faqs.org/docs/artu/ch01s06.html), and it will help -you a lot if you want to try another WM. - -### Terminal - -Here we are. The terminal. The central part of the whole setup! - -As an advanced user, you spend a lot of time within the terminal, so it is -important to keep your terminal a pleasant place for your eyes. -There are, in fact, only two ways to tweak your terminal: **colors and font**. -The goal is to find the best readability/usability/awesomeness ratio. -I'd recommend that you start from a dark scheme, as it's better for your eyes -by night (But that's just my opinion, light colorschemes can look pretty -good!). Terminals usually manage up to 256 colors, but you will use only 16 -of them: - -&rarr; [0-7] for normal text -&rarr; [8-15] for bold text -Here is the color chart: - -<table> - <tr> - <th></th> - <th>black</th> - <th>red</th> - <th>green</th> - <th>yellow</th> - <th>blue</th> - <th>magenta</th> - <th>cyan</th> - <th>white</th> - </tr> - <tr> - <th>dark</th> - <td>00</td> - <td>01</td> - <td>02</td> - <td>03</td> - <td>04</td> - <td>05</td> - <td>06</td> - <td>07</td> - </tr> - <tr> - <th>light</th> - <td>08</td> - <td>09</td> - <td>10</td> - <td>11</td> - <td>12</td> - <td>13</td> - <td>14</td> - <td>15</td> - </tr> -</table> - -Now, just tweak each color to fit your perfect theme! -To do so, refer to the manual of your terminal. - -If you don't have one, here is a list of terminal you can use: - -* [rxvt-unicode](http://software.schmorp.de/pkg/rxvt-unicode.html) -* [termite](https://github.com/thestinger/termite/) -* [evilvte](http://www.calno.com/evilvte/) -* [aterm](http://www.afterstep.org/aterm.php) -* [mterm](http://freecode.com/projects/mterm) - -I have stick with rxvt-unicode (urxvt) personnally. I find it pretty -powerfull, light and fast. Also, it can be extended in perl, which -is great (muh URL selection). - -Back to terminal colors! The best way I know to change the terminal -colorscheme, is using the X server resource database (xrdb). But it -does not work with every terminal (it works, at least, with xterm and -urxvt). -All you have to do, is configure your colors in a file called -`~/.Xresources`, and source it with the command: - - xrdb -load ~/.Xresources - -For example, here is mine (screenshot at the end of the section): - - Xresources - - *background:#222222 - *foreground:#e8e9ca - - *color0: #222222 - *color1: #8b3e2f - *color2: #526f33 - *color3: #665847 - *color4: #4a708b - *color5: #7a378b - *color6: #528b8b - *color7: #999999 - - *color8: #4c4c4c - *color9: #d75f00 - *color10: #cee318 - *color11: #eee685 - *color12: #9ac0cd - *color13: #9f79ee - *color14: #79cdcd - *color15: #e8e9ca - -For the font, it's quite the same, but I suggest that you search for -the terms _xft font_, _bitmap fonts_ and _X -resources_ cause it can be a little tricky to understand. - -Quickly, there are two way to draw fonts in your terminal, with, and -without xft. XFT allows you to draw nice fonts and scale them the -way you want, like BitStream Vera Sans, Monospace, etc... But these -are "slow" to draw. -The other method is the one used by TTY, bitmap fonts. Those are -fixed pixeled font that can look odd, but draw fastly. -Just make a choice. -To declare a XFT font: - - xft:<font name>:size=<size> - -Bitmap font are declared like this (taken from xfontsel -print, thanks to -[Gnu42](http://www.reddit.com/r/unixporn/comments/1pf6p4/howto_build_your_graphical_environment_piece_by/cd200mg) -for the package). You can then use the xfontsel package, or look for a file -named fonts.dir in your font directory. - - -fndry-fmly-wght-slant-sWdth-astyl-pxlsz-ptSz-resx-resy-spc-avgWdth-rgstry-encdng - -Here is a small example: - - Xresources - - *font: xft:monospace:size=10 - *font: -misc-tamsyn-medium-*-*--14-101-*-*-*-*-* - -So, we have seen how to tweak the terminal, let's see what it looks like! -I wrote a small script for the purpose: - -[![term screenshot](/img/thumb/2013-10-28-term.jpg)](/img/2013-10-28-term.jpg) -A terminal running the script [info.sh](http://git.z3bra.org/cgit.cgi/scripts/tree/info.sh) -that dump 16 colors along system informations - -### Shell - -right after seeing the terminal, you can't avoid it's main program: **the shell**. -If you don't know this already, the shell is the link between the user and the -programs. It's a program you will communicate with to manipulate your system. -An important program tough. Choose it carefully then. Here is the main shell -list: - -* sh &mdash; The historical shell -* bash &mdash; Improved shell, based on sh -* zsh &mdash; An extremly powerfull shell with a great completion system -* fish &mdash; A user friendly shell, really different from the above -* csh &mdash; The Berkeley UNIX shell -* tcsh &mdash; An improvement of csh - -I personnaly used zsh a lot because it has a feature I like, -the right prompt. also, it's completion system is really great -(argument completion is a good thing to have, trust me..). But I now -use bash again because I don't need much of the features zsh -provide, so that was kinda like using a chainsaw to cut a thin rope. - -Anyway, I'll treat here only the "standard shell": bash - -The first thing you will see from the shell is its prompt. The -prompt is a set of characters that gives info to the user, and -invite him to input commands. Basically, it looks like this: - - $ - -Fancy huh ? -The prompt chars are contained in the variable PS1 for -sh/bash, and PROMPT/RPROMPT for zsh. - - $ PS1='z3bra-$ ' - z3bra-$ - -(You don't have to issue the two command to make it works.) -Take a look at the bash manpage, section "Prompting" for more info -on how to tweak it. -Here is my personnal prompt: - - bashrc - - # Fancy prompt - fg=('\[\e[0;30m\]' '\[\e[0;31m\]' '\[\e[0;32m\]' '\[\e[0;33m\]' - '\[\e[0;34m\]' '\[\e[0;35m\]' '\[\e[0;36m\]' '\[\e[0;37m\]' - '\[\e[1;30m\]' '\[\e[1;31m\]' '\[\e[1;32m\]' '\[\e[1;33m\]' - '\[\e[1;34m\]' '\[\e[1;35m\]' '\[\e[1;36m\]' '\[\e[1;37m\]') - nofg='\[\e[0m\]' - - PS1='';[ -n "$SSH_CLIENT" ] &amp;&amp; PS1="${fg[8]}$(hostname|cut -b-2) " - export PS1=" ${PS1}${fg[11]}──── ${nofg}" - -And my old zsh prompt: - - zshrc - - PROMPT=" %{$fg_bold[yellow]%} » " - RPROMPT="%{$fg[black]%}%M:%{$fg_bold[yellow]%}%~%{$reset_color%} " - -[![shell screenshot](/img/thumb/2013-10-28-shell.jpg)](/img/2013-10-28-shell.jpg) -A few different prompts, from top to bottom: -sh, zsh, bash, zsh - -### CLI tools - -The shell is the core of a UNIX/Linux based system. So having a -bunch of fast, light and efficient CLI tools is a must. There are -applications for (almost) everything you do on a daily basis with -you computer: IRC clients, Text editor, Video games, Web browsers, -image viewer, ... - -Okay, I agree that some of them are not really practical to use -everyday. Mostly when it involve images (web lurking, image -processing, gaming, ...). -But when you don't need images, **unleash your -shell!** -Use CLI based app for text-based task. It has many advantages: - -* ALWAYS fit your colorscheme (see [Terminal](#terminal)) -* Focus on usability -* Integrate well with your whole setup -* This is fast as hell -* This is powerfull as hell -* You look like a hacker - -I personnaly use [vim](http://vim.org), [irssi](http://irssi.org) and -[mutt](http://mutt.org) on a daily basis. -As an alternative, take a look at [emacs](https://www.gnu.org/software/emacs/), -[weechat](http://weechat.org/) and -[Alpine](http://sourceforge.net/projects/re-alpine/). - -[![cwm screenshot](/img/thumb/2013-10-28-cli.jpg)](/img/2013-10-28-cli.jpg) - -Mandatory screenshot of the setup with those apps (and custom themes). -top-left: **vim** -top-right: **mutt** -bottom-left: **tmux** -bottom-right: **irssi** - -### Status bar - -All of this is great, but I think that if you want to check the -time, you're not willing to open a terminal, and type: - - date +%H:%M - -It's not really practical most of the time. The same can apply to -the amount of free space, to current volume level or the number of -unread mails you have. -That's what status bar are made for. They pick infos for you and -display them in a thin bar on an edge of your screen. - -My bar of choice is, by far, -[bar ain't recursive](https://github.com/LemonBoy/bar), by Lemon Boy. -It is light, fast and simple. Exactly how I like it! the purpose is simple: - -1. Write a script that output a bunch of informations -2. Pipe that script into the bar -3. Run them within an infinite loop! - -That is all you need. For example, if you only need the date in the bar: - - while :; do date; done | bar &amp; - -And there you go! You can achieve really great looking stuff with that simple -process: - -[![bar screenshot](/img/thumb/2013-10-28-bar.jpg)](/img/2013-10-28-bar.jpg) -You can also choose to put your status bar within a terminal multiplexer status bar, -[as phyrne suggested](http://calummacrae.blogspot.fr/2012/12/dropping-status-bars-for-tmux-as-im.html) -in one of his blog post - -### Integration - -Now that we potentially have a working desktop, let make it spawn -correctly, using ONLY one file: `~/.xinitrc`. - -That magical file is simply a shell script that is called by default -with `startx`. In fact, when you proceed this command, it does the following: - - $ startx ~/.xinitrc -- :0 - -It source your ~/.xinitrc, and launch it on the Xorg server number -0. -To launch your wm of choice from the xinitrc, just add the command -to launch it in the file, preceded by 'exec'. It will replace the -current process (your shell) by the window manager, so that the -session will terminate with your WM. - -Okay, now you have the theory. Before starting to pratice, I'll give -you a few hints for a "good" xinitrc (yeah, I love making lists): - -* Launch ONLY session related commands -* Make it evolutive, so that you can spawn multiple X sessions at the same time -* Fork every command, except those that are dependent, to speed up the desktop - spawning - -Finally, here is my own xinitrc - - xinitrc - - #!/bin/bash - # - # ~/.xinitrc - # - - # load nvidia config - nvidia-settings -l - - # Set wallpaper - hsetroot -tile ~/usr/img/bg/stripes.png &amp; - - # default cursor - xsetroot -cursor_name left_ptr &amp; - - function wm() { - # Load X resources - xrdb -load ~/.Xresources &amp; - - # personnal bindings - xbindkeys - - # set WM name - xsetroot -name $1 - - #status bar - ~/bin/bar/status.sh &amp; # it acts kinda weirdly - - # Compositing - # enable RGBA module for GTK - export GTK_MODULES=rgba - - #compton -cCb -t-5 -l-5 -r4.2 -o.4 - compton -cb -o0 - - # spawn window manager - exec $1 - } - - [[ -z $1 ]] &amp;&amp; wm cwm - - wm $1 - -[![final screenshot](/img/thumb/2013-10-28-final.jpg)](/img/2013-10-28-final.jpg) -That shot show off the whole setup, with -prompt, bar, applications, etc... -I hope you will like it! - -### Conclusion - -The end, finally. That is a damn long article. I have deliberately not expanded -some point by lack of "space". I want this article to end someday. It will -give you a good start to tweak your own setup, and make it look like -what you want it to look. - -**Make your environment yours, and have fun doing so!** - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/10/home-sweet-home.txt b/2013/10/home-sweet-home.txt @@ -0,0 +1,454 @@ +# [Home, sweet home](#) +## &mdash; 28 October, 2013 + +### Summary + +Yes, a summary, because that's gonna be a LONG article. + +* [Introduction](#intro) +* [Window manager](#wm) +* [Terminal](#term) +* [Shell](#sh) +* [CLI tools](#cli) +* [Status bar](#bar) +* [Integration](#setup) + +### Introduction + +Okay, so you have finally installed your distro of choice, cleaned +the whole setup, installed X.org, xterm and vim... + +**And now, what?!** + +I've asked myself this question more than I should (probably because +I liking tweaking my desktop, but that's not the point here). +And I bet that you did too ! + +In this post, I'll go through all the mandatory tweak that should be +done to a clean base system. YOUR system, 'cause there is no place +like home. +Once standing in your ~, starring at your shell prompt, you should +be like <q>Uuuh that is life, eh!</q> + +I'll not wait more to give you my secrets, but please, keep in mind +that these are _MY OPINIONS_ and I'm not asking you to agree +with me. If you feel uncomfortable with some points, just avoid +them. You're not here to feel bad, but to find advices on +**setting up your home!** + +### Window manager + +This is the most important part of your future environment. It is +the god that will tell all your windows where to go, how to move, +etc.. So you can take a little time to choose a WM, it totally +understandable. + +There are three types of window managers: + +* **Floating** &mdash; windows overlaps +* **Tilling** &mdash; windows are arranged in tiles (kinda like a grid) +* **Dynamics** &mdash; both floating and tilling are possible +* **Aliens** &mdash; Go home WM, you're drunk. + +Floating management is the management style we're all used to, +windows are independent and you can resize/move them freely around +your desktop. +Tilled window managers arrange the windows depending on what is +currently on your desktop. The windows _CAN'T_ overlap. When +you create a new window, the whole set of window is rearranging to +let the new window find a place (Not always in fact, but that's the +idea behind tilling). +Finally, dynamic WM can switch between the two managment styles +(most of the time, at cost of complexity and binary size, but that's +just my opinion). Note that most tilling WM are, in fact, dynamic +WM. But the way they manage floating windows is just so poor... + +Oh, and for the alien part, keep in mind that some WM just don't +manage windows like that. But their behaviors are to specific to be +described here. Just RTFM 'em. + +FYI, here is a non-exhaustive list of window managers I like (F = +floating, T = tilling, D = dynamic... U DON'T SAY!) + +* cwm &mdash; Calm Window Manager (F) +* Ratpoison (A) +* ctwm (F) +* herbstluftwm (T) (<q>Hebrstrutoflutudobleyouhem</q>) +* evilwm (F) +* xmonad (D) +* spectrwm (T) +* ... + +Note that I _DIDN'T_ mentioned AwesomeWM or openbox. beuâh. + +Once you have chosen your WM, go through its manpage/doc, set it up +to look the way you want. Use stuff like [librgba](http://gnome-look.org/content/show.php/Another+Gtk+RGBA+module+?content=100968), +[compton](https://github.com/chjj/compton) to make it +even prettier! + +[![cwm screenshot](/img/thumb/2013-10-28-cwm.jpg)](/img/2013-10-28-cwm.jpg) +Here is a quick CWM setup, using compton and librgba + +Oh! A last advice, **do not bind applications through your WM**. Using an +application like [xbindkeys](http://www.nongnu.org/xbindkeys/xbindkeys.html) to +do that is a better idea, as it follow the +[UNIX philosophy](http://www.faqs.org/docs/artu/ch01s06.html), and it will help +you a lot if you want to try another WM. + +### Terminal + +Here we are. The terminal. The central part of the whole setup! + +As an advanced user, you spend a lot of time within the terminal, so it is +important to keep your terminal a pleasant place for your eyes. +There are, in fact, only two ways to tweak your terminal: **colors and font**. +The goal is to find the best readability/usability/awesomeness ratio. +I'd recommend that you start from a dark scheme, as it's better for your eyes +by night (But that's just my opinion, light colorschemes can look pretty +good!). Terminals usually manage up to 256 colors, but you will use only 16 +of them: + +&rarr; [0-7] for normal text +&rarr; [8-15] for bold text +Here is the color chart: + +<table> + <tr> + <th></th> + <th>black</th> + <th>red</th> + <th>green</th> + <th>yellow</th> + <th>blue</th> + <th>magenta</th> + <th>cyan</th> + <th>white</th> + </tr> + <tr> + <th>dark</th> + <td>00</td> + <td>01</td> + <td>02</td> + <td>03</td> + <td>04</td> + <td>05</td> + <td>06</td> + <td>07</td> + </tr> + <tr> + <th>light</th> + <td>08</td> + <td>09</td> + <td>10</td> + <td>11</td> + <td>12</td> + <td>13</td> + <td>14</td> + <td>15</td> + </tr> +</table> + +Now, just tweak each color to fit your perfect theme! +To do so, refer to the manual of your terminal. + +If you don't have one, here is a list of terminal you can use: + +* [rxvt-unicode](http://software.schmorp.de/pkg/rxvt-unicode.html) +* [termite](https://github.com/thestinger/termite/) +* [evilvte](http://www.calno.com/evilvte/) +* [aterm](http://www.afterstep.org/aterm.php) +* [mterm](http://freecode.com/projects/mterm) + +I have stick with rxvt-unicode (urxvt) personnally. I find it pretty +powerfull, light and fast. Also, it can be extended in perl, which +is great (muh URL selection). + +Back to terminal colors! The best way I know to change the terminal +colorscheme, is using the X server resource database (xrdb). But it +does not work with every terminal (it works, at least, with xterm and +urxvt). +All you have to do, is configure your colors in a file called +`~/.Xresources`, and source it with the command: + + xrdb -load ~/.Xresources + +For example, here is mine (screenshot at the end of the section): + + Xresources + + *background:#222222 + *foreground:#e8e9ca + + *color0: #222222 + *color1: #8b3e2f + *color2: #526f33 + *color3: #665847 + *color4: #4a708b + *color5: #7a378b + *color6: #528b8b + *color7: #999999 + + *color8: #4c4c4c + *color9: #d75f00 + *color10: #cee318 + *color11: #eee685 + *color12: #9ac0cd + *color13: #9f79ee + *color14: #79cdcd + *color15: #e8e9ca + +For the font, it's quite the same, but I suggest that you search for +the terms _xft font_, _bitmap fonts_ and _X +resources_ cause it can be a little tricky to understand. + +Quickly, there are two way to draw fonts in your terminal, with, and +without xft. XFT allows you to draw nice fonts and scale them the +way you want, like BitStream Vera Sans, Monospace, etc... But these +are "slow" to draw. +The other method is the one used by TTY, bitmap fonts. Those are +fixed pixeled font that can look odd, but draw fastly. +Just make a choice. +To declare a XFT font: + + xft:<font name>:size=<size> + +Bitmap font are declared like this (taken from xfontsel -print, thanks to +[Gnu42](http://www.reddit.com/r/unixporn/comments/1pf6p4/howto_build_your_graphical_environment_piece_by/cd200mg) +for the package). You can then use the xfontsel package, or look for a file +named fonts.dir in your font directory. + + -fndry-fmly-wght-slant-sWdth-astyl-pxlsz-ptSz-resx-resy-spc-avgWdth-rgstry-encdng + +Here is a small example: + + Xresources + + *font: xft:monospace:size=10 + *font: -misc-tamsyn-medium-*-*--14-101-*-*-*-*-* + +So, we have seen how to tweak the terminal, let's see what it looks like! +I wrote a small script for the purpose: + +[![term screenshot](/img/thumb/2013-10-28-term.jpg)](/img/2013-10-28-term.jpg) +A terminal running the script [info.sh](http://git.z3bra.org/cgit.cgi/scripts/tree/info.sh) +that dump 16 colors along system informations + +### Shell + +right after seeing the terminal, you can't avoid it's main program: **the shell**. +If you don't know this already, the shell is the link between the user and the +programs. It's a program you will communicate with to manipulate your system. +An important program tough. Choose it carefully then. Here is the main shell +list: + +* sh &mdash; The historical shell +* bash &mdash; Improved shell, based on sh +* zsh &mdash; An extremly powerfull shell with a great completion system +* fish &mdash; A user friendly shell, really different from the above +* csh &mdash; The Berkeley UNIX shell +* tcsh &mdash; An improvement of csh + +I personnaly used zsh a lot because it has a feature I like, +the right prompt. also, it's completion system is really great +(argument completion is a good thing to have, trust me..). But I now +use bash again because I don't need much of the features zsh +provide, so that was kinda like using a chainsaw to cut a thin rope. + +Anyway, I'll treat here only the "standard shell": bash + +The first thing you will see from the shell is its prompt. The +prompt is a set of characters that gives info to the user, and +invite him to input commands. Basically, it looks like this: + + $ + +Fancy huh ? +The prompt chars are contained in the variable PS1 for +sh/bash, and PROMPT/RPROMPT for zsh. + + $ PS1='z3bra-$ ' + z3bra-$ + +(You don't have to issue the two command to make it works.) +Take a look at the bash manpage, section "Prompting" for more info +on how to tweak it. +Here is my personnal prompt: + + bashrc + + # Fancy prompt + fg=('\[\e[0;30m\]' '\[\e[0;31m\]' '\[\e[0;32m\]' '\[\e[0;33m\]' + '\[\e[0;34m\]' '\[\e[0;35m\]' '\[\e[0;36m\]' '\[\e[0;37m\]' + '\[\e[1;30m\]' '\[\e[1;31m\]' '\[\e[1;32m\]' '\[\e[1;33m\]' + '\[\e[1;34m\]' '\[\e[1;35m\]' '\[\e[1;36m\]' '\[\e[1;37m\]') + nofg='\[\e[0m\]' + + PS1='';[ -n "$SSH_CLIENT" ] &amp;&amp; PS1="${fg[8]}$(hostname|cut -b-2) " + export PS1=" ${PS1}${fg[11]}──── ${nofg}" + +And my old zsh prompt: + + zshrc + + PROMPT=" %{$fg_bold[yellow]%} » " + RPROMPT="%{$fg[black]%}%M:%{$fg_bold[yellow]%}%~%{$reset_color%} " + +[![shell screenshot](/img/thumb/2013-10-28-shell.jpg)](/img/2013-10-28-shell.jpg) +A few different prompts, from top to bottom: +sh, zsh, bash, zsh + +### CLI tools + +The shell is the core of a UNIX/Linux based system. So having a +bunch of fast, light and efficient CLI tools is a must. There are +applications for (almost) everything you do on a daily basis with +you computer: IRC clients, Text editor, Video games, Web browsers, +image viewer, ... + +Okay, I agree that some of them are not really practical to use +everyday. Mostly when it involve images (web lurking, image +processing, gaming, ...). +But when you don't need images, **unleash your +shell!** +Use CLI based app for text-based task. It has many advantages: + +* ALWAYS fit your colorscheme (see [Terminal](#terminal)) +* Focus on usability +* Integrate well with your whole setup +* This is fast as hell +* This is powerfull as hell +* You look like a hacker + +I personnaly use [vim](http://vim.org), [irssi](http://irssi.org) and +[mutt](http://mutt.org) on a daily basis. +As an alternative, take a look at [emacs](https://www.gnu.org/software/emacs/), +[weechat](http://weechat.org/) and +[Alpine](http://sourceforge.net/projects/re-alpine/). + +[![cwm screenshot](/img/thumb/2013-10-28-cli.jpg)](/img/2013-10-28-cli.jpg) + +Mandatory screenshot of the setup with those apps (and custom themes). +top-left: **vim** +top-right: **mutt** +bottom-left: **tmux** +bottom-right: **irssi** + +### Status bar + +All of this is great, but I think that if you want to check the +time, you're not willing to open a terminal, and type: + + date +%H:%M + +It's not really practical most of the time. The same can apply to +the amount of free space, to current volume level or the number of +unread mails you have. +That's what status bar are made for. They pick infos for you and +display them in a thin bar on an edge of your screen. + +My bar of choice is, by far, +[bar ain't recursive](https://github.com/LemonBoy/bar), by Lemon Boy. +It is light, fast and simple. Exactly how I like it! the purpose is simple: + +1. Write a script that output a bunch of informations +2. Pipe that script into the bar +3. Run them within an infinite loop! + +That is all you need. For example, if you only need the date in the bar: + + while :; do date; done | bar &amp; + +And there you go! You can achieve really great looking stuff with that simple +process: + +[![bar screenshot](/img/thumb/2013-10-28-bar.jpg)](/img/2013-10-28-bar.jpg) +You can also choose to put your status bar within a terminal multiplexer status bar, +[as phyrne suggested](http://calummacrae.blogspot.fr/2012/12/dropping-status-bars-for-tmux-as-im.html) +in one of his blog post + +### Integration + +Now that we potentially have a working desktop, let make it spawn +correctly, using ONLY one file: `~/.xinitrc`. + +That magical file is simply a shell script that is called by default +with `startx`. In fact, when you proceed this command, it does the following: + + $ startx ~/.xinitrc -- :0 + +It source your ~/.xinitrc, and launch it on the Xorg server number +0. +To launch your wm of choice from the xinitrc, just add the command +to launch it in the file, preceded by 'exec'. It will replace the +current process (your shell) by the window manager, so that the +session will terminate with your WM. + +Okay, now you have the theory. Before starting to pratice, I'll give +you a few hints for a "good" xinitrc (yeah, I love making lists): + +* Launch ONLY session related commands +* Make it evolutive, so that you can spawn multiple X sessions at the same time +* Fork every command, except those that are dependent, to speed up the desktop + spawning + +Finally, here is my own xinitrc + + xinitrc + + #!/bin/bash + # + # ~/.xinitrc + # + + # load nvidia config + nvidia-settings -l + + # Set wallpaper + hsetroot -tile ~/usr/img/bg/stripes.png &amp; + + # default cursor + xsetroot -cursor_name left_ptr &amp; + + function wm() { + # Load X resources + xrdb -load ~/.Xresources &amp; + + # personnal bindings + xbindkeys + + # set WM name + xsetroot -name $1 + + #status bar + ~/bin/bar/status.sh &amp; # it acts kinda weirdly + + # Compositing + # enable RGBA module for GTK + export GTK_MODULES=rgba + + #compton -cCb -t-5 -l-5 -r4.2 -o.4 + compton -cb -o0 + + # spawn window manager + exec $1 + } + + [[ -z $1 ]] &amp;&amp; wm cwm + + wm $1 + +[![final screenshot](/img/thumb/2013-10-28-final.jpg)](/img/2013-10-28-final.jpg) +That shot show off the whole setup, with +prompt, bar, applications, etc... +I hope you will like it! + +### Conclusion + +The end, finally. That is a damn long article. I have deliberately not expanded +some point by lack of "space". I want this article to end someday. It will +give you a good start to tweak your own setup, and make it look like +what you want it to look. + +**Make your environment yours, and have fun doing so!** + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/11/plain-old-mails.html b/2013/11/plain-old-mails.html @@ -1,276 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset='utf-8'/> - <link rel='stylesheet' href='/css/monochrome.css'/> - <link rel='stylesheet' href='/css/code.css'/> - <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/> - <title>z3bra.org - monochromatic blog</title> - </head> - <body> - <header> - <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2> - </header> - <div id='wrapper'> - <section> - <h1> - <a href='#'>Plain old mails</a> - </h1> - <h2> - &mdash; 04 November, 2013 - </h2> - <article> - <p> - On my way to meet the default UNIX tools, I ran into a simple one: - <code>mail</code>, that was sitting in the corner of my system - playing with.. Nothing in fact.<br /> - <code>mail</code> mail is one of that small utilities that have - been forgotten and replaced by more "moderns" tools like mutt, - alpine or even thunderbird. But it is worth knowing about ! - </p> - - <p> - <code>mail</code> can manipulate a mail box in either mbox or - Maildir format, and is intelligent enough to know the difference - between the two of them.<br /> - It can also handle IMAP mail boxes, but for this post, I'll assume - you use a local mail directory under - <code>$HOME/var/mail/INBOX/</code> - </p> - - <p> - Because we all need that bearded touch, we will use - <code>mail</code> as our <strong>main mail user agent</strong>. - </p> - - <h3>The environment</h3> - <p> - As any of the standard UNIX tool, <code>mail</code> integrates well - in a UNIX environment, and is able to interact with external tools - to perform specific action (assume it, you love that huh?). - </p> - - <p> - Here is the set of variable <code>mail</code> is going to use: - <ul> - <li><code>MAIL</code>: The default mail box</li> - <li><code>EDITOR</code>: The default editor to use</li> - <li><code>VISUAL</code>: The default visual editor to use</li> - </ul> - And that all ! We will not need more to get a running set up (For - more infos, you can check the mail(1) manpage). - <br /> - So here we go. Make sure those two variables are exported: - - <pre><code>$ export MAIL=$HOME/var/mail/INBOX -$ export EDITOR=ed -$ export VISUAL=vim</code></pre> - - Now, we will create the most basic directory tree needed by the - setup (We will improve it later) - - <pre><code>$ tree $HOME/var/mail -/home/z3bra/var/mail/ -└── INBOX - ├── cur - ├── new - └── tmp - -4 directories, 0 files</code></pre> - - <p> - Ok, now the mail environment is set up. You can try the - <code>mail</code> command at this point, but an empty mail tree will - only result in the following message: - </p> - - <pre><code>No mail for z3bra</code></pre> - - <p> - For future convenience, copy your <code>/etc/mail.rc</code> to - <code>~/.mailrc</code>, so we will be able to edit it later. - </p> - - <p> - Before continuing with <code>mail</code>, we will take a look at two - mail related programs, <a href="http://fdm.sourceforge.net/">fdm</a> - and <a href="http://msmtp.sourceforge.net/">msmtp</a>, that we - will use to fetch and deliver emails. - </p> - </article> - - <article> - <h3>Fetching mails</h3> - <p> - <code>FDM</code> stands for <q>Fetch and Deliver Mails</q>, so - it basically get mails from a server, and place them in your local - filesystem based on regex rules.<br /> - If you want a great tutorial for fdm, check out the <a - href="http://fdm.sourceforge.net">FDM Quick start guide</a>. I'll - just give you my own(simplified) config file: - </p> - - <pre><code>action "INBOX" maildir "%h/var/mail/INBOX" - -account &quot;&lt;account-name&gt;&quot; - pop3s - server &quot;&lt;pop3-server&gt;&quot; - new-only - cache &quot;~/var/mail/.cache&quot; - keep # Keeps mails on the server - -match all action "INBOX"</code></pre> - - <p> - <code>FDM</code> can get infos from your <code>~/.netrc</code> file, - which looks like this: - </p> - - <pre><code>machine &lt;pop3-server&gt; -login &lt;email@domain.tld&gt; -password &lt;password&gt;</code></pre> - - <p> - check that mail fetching works with <code>fdm -kv fetch</code>. - If it works, you could place <code>fdm fetch</code> in your cron - entries. - </p> - </article> - - <article> - <h3>Sending mails</h3> - <p> - <code>MSMTP</code> is as simple to use as <code>fdm</code>. Check - its <a href="http://msmtp.sourceforge.net/documentation.html"> - documentation</a> - Here is a simplified config file: - </p> - - <pre><code>defaults -auth on - -account &lt;account-name&gt; -user &lt;email@domain.tld&gt; -from &lt;email@domain.tld&gt; -host &lt;stmp-server&gt; -port 25 - -account default : &lt;account-name&gt;</code></pre> - - <p> - <code>msmtp</code> will also read your <code>~/.netrc</code> file to - get your password. - </p> - - <p> - by default, <code>mail</code> uses <code>sendmail</code> (guess what - it does...). Add the following at the end of your - <code>~/.mailrc</code>: - </p> - - <pre><code>~/.mailrc -... -# use msmtp instead of sendmail -set sendmail=&quot;/usr/bin/msmtp&quot;</code></pre > - - </article> - <article> - <h3>Writing a new mail</h3> - <p> - Back to the topic!<br /> - Now that tools we are going to interact with are set up, let's write - and send out first mail. - We will send this mail to ourselves, so let's go like this: - </p> - - <pre><code>$ mail email@domain.tld -Subject: Testing a new MUA -Here is the top of the mail. -You are actually typing like in ed's insert mode. - -To stop typing, just type a dot on its own line -. -EOT</code></pre> - - <p> - This will send a mail to the given address. Nothing more. Nothing - less.<br /> - You can give multiple address to send the mail to multiple contacts. - <br /> - If you need more flexibility (e.g. using your own editor, or input - the text dynamically within a script, keep in mind that you can do - the following: - </p> - - <pre><code>$ echo &quot;&lt;E-mail body goes here&gt;&quot; | mail -s &quot;&lt;subject&gt;&quot; &lt;email@domain.tld&gt; -$ vim /tmp/body.txt -$ mail -s &quot;&lt;subject&gt;&quot; &lt;email@domain.tld&gt; &lt; /tmp/body.txt</code></pre> - - <p> - As you might guess, the <code>-s</code> can be used to specify the - subject. There are also <code>-c &lt;CC-field&gt;</code>, <code>-b - &lt;BCC-field&gt;</code> for copy/carbin copy, and so on. Just - read the manpage for more options. - </p> - - <h3>Reading your mails</h3> - <p> - To read your mail, it's quite simple. Just type <code>mail</code> to - get an output like: - </p> - - <pre><code>$ mail -mail version v14.4.4. Type ? for help. -&quot;/home/z3bra/var/mail/INBOX&quot;: 4 messages 1 unread -O 1 contact@domain.tld Thu Jan 1 01:00 140/5273 Blah blah, subject -A 2 me@mail.domain.tld Thu Jan 1 01:00 95/5869 RE: Previous subject -A 3 NEWS GROUPS Thu Jan 1 01:00 222/15606 TR: Check this ous! -&gt;U 4 willy@mailoo.org Thu Jan 1 01:00 104/4146 &gt;Testing a new MUA -? </code></pre> - - <p> - The <code>?</code> at the end is a prompt. You can input commands - like <code>print &lt;num&gt;</code> to display the content of the - mail number "num".<br /> - You can use abbreviations for commands: "p" is the same as "print". - "e" means "edit", "v" means "visual". - - There are A LOT of commands (to delete mails, encrypt/decrypt, copy - to folders, manage aliases, ...)<br /> - <br /> - You can even define macros, to make action like, add sender to - aliases, mark as read, copy to another folder and delete the current - mail. - </p> - - <p> - Today, I discovered <code>mail</code> which does anything I need to - manage my e-mails. I'll probably make the switch from mutt on all my - machines once I'll be used to it.<br /> - <br /> - This little discovery reminded me that UNIX was and still is a great - operating system, regardless of all the tools that have been - developped since its birth. - </p> - <p> - I hope you (re)learnt something with this article. I don't hear - about <code>mail</code> that much nowadays, although it's really - usable and functionnal. I feel like a pokemon hunter. Aware that - there are many, many tools out there, of different forms, with - different purpose... I'll probably never use them all. But I'll try! - </p> - </article> - </section> - </div> - <!-- footer {{{ --> - <footer> - <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->// - <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->// - <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->// - <a href='http://z3bra.org'>root</a> <!-- &#9774; -->// - <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; --> - </footer> - <!-- }}} --> - </body> -</html> -<!-- vim: set sw=2 et ai fdm=marker ft=html: --> diff --git a/2013/11/plain-old-mails.md b/2013/11/plain-old-mails.md @@ -1,187 +0,0 @@ -# [Plain old mails](#) -## &mdash; 04 November, 2013 - -On my way to meet the default UNIX tools, I ran into a simple one: `mail`, that -was sitting in the corner of my system playing with.. Nothing in fact. -`mail` is one of that small utilities that have been forgotten and replaced by -more "moderns" tools like mutt, alpine or even thunderbird. But it is worth -knowing about ! - -`mail` can manipulate a mail box in either mbox or Maildir format, and is -intelligent enough to know the difference between the two of them. -It can also handle IMAP mail boxes, but for this post, I'll assume you use a -local mail directory under `$HOME/var/mail/INBOX/` - -Because we all need that bearded touch, we will use `mail` as our **main mail -user agent**. - -### The environment - -As any of the standard UNIX tool, `mail` integrates well in a UNIX environment, -and is able to interact with external tools to perform specific action (assume -it, you love that huh?). - -Here is the set of variable `mail` is going to use: - -* `MAIL`: The default mail box -* `EDITOR`: The default editor to use -* `VISUAL`: The default visual editor to use - -And that all ! We will not need more to get a running set up (For -more infos, you can check the mail(1) manpage). - -So here we go. Make sure those two variables are exported: - - $ export MAIL=$HOME/var/mail/INBOX - $ export EDITOR=ed - $ export VISUAL=vim - -Now, we will create the most basic directory tree needed by the -setup (We will improve it later) - - $ tree $HOME/var/mail - /home/z3bra/var/mail/ - └── INBOX - ├── cur - ├── new - └── tmp - - 4 directories, 0 files - -Ok, now the mail environment is set up. You can try the `mail` command at this -point, but an empty mail tree will only result in the following message: - - No mail for z3bra - -For future convenience, copy your /etc/mail.rc to -~/.mailrc, so we will be able to edit it later. - - -Before continuing with mail, we will take a look at two mail related programs, -[fdm](http://fdm.sourceforge.net/) and [msmtp](http://msmtp.sourceforge.net/), -that we will use to fetch and deliver emails. - -### Fetching mails - -FDM stands for <q>Fetch and Deliver Mails</q>, so it basically get mails from a -server, and place them in your local filesystem based on regex rules. -If you want a great tutorial for fdm, check out the -[FDM Quick start guide](http://fdm.sourceforge.net). I'll just give you my -own (simplified) config file: - - action "INBOX" maildir "%h/var/mail/INBOX" - - account "<account-name>" - pop3s - server "<pop3-server>" - new-only - cache "~/var/mail/.cache" - keep # Keeps mails on the server - - match all action "INBOX" - -`FDM` can get infos from your `~/.netrc` file, which looks like this: - - machine <pop3-server> - login <email@domain.tld> - password <password> - -check that mail fetching works with `fdm -kv fetch`. -If it works, you could place `fdm fetch` in your cron entries. - -### Sending mails - -`MSMTP` is as simple to use as `fdm`. Check its -[documentation](http://msmtp.sourceforge.net/documentation.html). -Here is a simplified config file: - - defaults - auth on - - account <account-name> - user <email@domain.tld> - from <email@domain.tld> - host <stmp-server> - port 25 - - account default : <account-name> - - -`msmtp` will also read your `~/.netrc` file to get your password. - -by default, `mail` uses `sendmail` (guess what it does...). Add the following -at the end of your `~/.mailrc`: - - ~/.mailrc - ... - # use msmtp instead of sendmail - set sendmail="/usr/bin/msmtp" - -### Writing a new mail - -Back to the topic! -Now that tools we are going to interact with are set up, let's write -and send out first mail. -We will send this mail to ourselves, so let's go like this: - - $ mail email@domain.tld - Subject: Testing a new MUA - Here is the top of the mail. - You are actually typing like in ed's insert mode. - - To stop typing, just type a dot on its own line - . - EOT - -This will send a mail to the given address. Nothing more. Nothing less. -You can give multiple address to send the mail to multiple contacts. - -If you need more flexibility (e.g. using your own editor, or input -the text dynamically within a script, keep in mind that you can do -the following: - - $ echo "<E-mail body goes here>" | mail -s "<subject>" <email@domain.tld> - $ vim /tmp/body.txt - $ mail -s "<subject>" <email@domain.tld> < /tmp/body.txt - - -As you might guess, the `-s` can be used to specify the subject. There are also -`-c <CC-field>`, `-b <BCC-field></code> for copy/carbin copy, and so on. Just -read the manpage for more options. - -### Reading your mails - -To read your mail, it's quite simple. Just type `mail` to get an output like: - - $ mail - mail version v14.4.4. Type ? for help. - "/home/z3bra/var/mail/INBOX": 4 messages 1 unread - O 1 contact@domain.tld Thu Jan 1 01:00 140/5273 Blah blah, subject - A 2 me@mail.domain.tld Thu Jan 1 01:00 95/5869 RE: Previous subject - A 3 NEWS GROUPS Thu Jan 1 01:00 222/15606 TR: Check this out! - >U 4 willy@mailoo.org Thu Jan 1 01:00 104/4146 >Testing a new MUA - ? - -The `?` at the end is a prompt. You can input commands like `print <num>` to -display the content of the mail number "num". -You can use abbreviations for commands: "p" is the same as "print". "e" means -"edit", "v" means "visual". - -There are A LOT of commands (to delete mails, encrypt/decrypt, copy to folders, -manage aliases, ...) - -You can even define macros, to make action like, add sender to aliases, mark as -read, copy to another folder and delete the current mail. - -Today, I discovered `mail` which does anything I need to manage my e-mails. I'll -probably make the switch from mutt on all my machines once I'll be used to it. - -This little discovery reminded me that UNIX was and still is a great operating -system, regardless of all the tools that have been developped since its birth. - -I hope you (re)learnt something with this article. I don't hear about `mail` -that much nowadays, although it's really usable and functionnal. I feel like a -pokemon hunter. Aware that there are many, many tools out there, of different -forms, with different purpose... I'll probably never use them all. But I'll try! - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/11/plain-old-mails.txt b/2013/11/plain-old-mails.txt @@ -0,0 +1,187 @@ +# [Plain old mails](#) +## &mdash; 04 November, 2013 + +On my way to meet the default UNIX tools, I ran into a simple one: `mail`, that +was sitting in the corner of my system playing with.. Nothing in fact. +`mail` is one of that small utilities that have been forgotten and replaced by +more "moderns" tools like mutt, alpine or even thunderbird. But it is worth +knowing about ! + +`mail` can manipulate a mail box in either mbox or Maildir format, and is +intelligent enough to know the difference between the two of them. +It can also handle IMAP mail boxes, but for this post, I'll assume you use a +local mail directory under `$HOME/var/mail/INBOX/` + +Because we all need that bearded touch, we will use `mail` as our **main mail +user agent**. + +### The environment + +As any of the standard UNIX tool, `mail` integrates well in a UNIX environment, +and is able to interact with external tools to perform specific action (assume +it, you love that huh?). + +Here is the set of variable `mail` is going to use: + +* `MAIL`: The default mail box +* `EDITOR`: The default editor to use +* `VISUAL`: The default visual editor to use + +And that all ! We will not need more to get a running set up (For +more infos, you can check the mail(1) manpage). + +So here we go. Make sure those two variables are exported: + + $ export MAIL=$HOME/var/mail/INBOX + $ export EDITOR=ed + $ export VISUAL=vim + +Now, we will create the most basic directory tree needed by the +setup (We will improve it later) + + $ tree $HOME/var/mail + /home/z3bra/var/mail/ + └── INBOX + ├── cur + ├── new + └── tmp + + 4 directories, 0 files + +Ok, now the mail environment is set up. You can try the `mail` command at this +point, but an empty mail tree will only result in the following message: + + No mail for z3bra + +For future convenience, copy your /etc/mail.rc to +~/.mailrc, so we will be able to edit it later. + + +Before continuing with mail, we will take a look at two mail related programs, +[fdm](http://fdm.sourceforge.net/) and [msmtp](http://msmtp.sourceforge.net/), +that we will use to fetch and deliver emails. + +### Fetching mails + +FDM stands for <q>Fetch and Deliver Mails</q>, so it basically get mails from a +server, and place them in your local filesystem based on regex rules. +If you want a great tutorial for fdm, check out the +[FDM Quick start guide](http://fdm.sourceforge.net). I'll just give you my +own (simplified) config file: + + action "INBOX" maildir "%h/var/mail/INBOX" + + account "<account-name>" + pop3s + server "<pop3-server>" + new-only + cache "~/var/mail/.cache" + keep # Keeps mails on the server + + match all action "INBOX" + +`FDM` can get infos from your `~/.netrc` file, which looks like this: + + machine <pop3-server> + login <email@domain.tld> + password <password> + +check that mail fetching works with `fdm -kv fetch`. +If it works, you could place `fdm fetch` in your cron entries. + +### Sending mails + +`MSMTP` is as simple to use as `fdm`. Check its +[documentation](http://msmtp.sourceforge.net/documentation.html). +Here is a simplified config file: + + defaults + auth on + + account <account-name> + user <email@domain.tld> + from <email@domain.tld> + host <stmp-server> + port 25 + + account default : <account-name> + + +`msmtp` will also read your `~/.netrc` file to get your password. + +by default, `mail` uses `sendmail` (guess what it does...). Add the following +at the end of your `~/.mailrc`: + + ~/.mailrc + ... + # use msmtp instead of sendmail + set sendmail="/usr/bin/msmtp" + +### Writing a new mail + +Back to the topic! +Now that tools we are going to interact with are set up, let's write +and send out first mail. +We will send this mail to ourselves, so let's go like this: + + $ mail email@domain.tld + Subject: Testing a new MUA + Here is the top of the mail. + You are actually typing like in ed's insert mode. + + To stop typing, just type a dot on its own line + . + EOT + +This will send a mail to the given address. Nothing more. Nothing less. +You can give multiple address to send the mail to multiple contacts. + +If you need more flexibility (e.g. using your own editor, or input +the text dynamically within a script, keep in mind that you can do +the following: + + $ echo "<E-mail body goes here>" | mail -s "<subject>" <email@domain.tld> + $ vim /tmp/body.txt + $ mail -s "<subject>" <email@domain.tld> < /tmp/body.txt + + +As you might guess, the `-s` can be used to specify the subject. There are also +`-c <CC-field>`, `-b <BCC-field></code> for copy/carbin copy, and so on. Just +read the manpage for more options. + +### Reading your mails + +To read your mail, it's quite simple. Just type `mail` to get an output like: + + $ mail + mail version v14.4.4. Type ? for help. + "/home/z3bra/var/mail/INBOX": 4 messages 1 unread + O 1 contact@domain.tld Thu Jan 1 01:00 140/5273 Blah blah, subject + A 2 me@mail.domain.tld Thu Jan 1 01:00 95/5869 RE: Previous subject + A 3 NEWS GROUPS Thu Jan 1 01:00 222/15606 TR: Check this out! + >U 4 willy@mailoo.org Thu Jan 1 01:00 104/4146 >Testing a new MUA + ? + +The `?` at the end is a prompt. You can input commands like `print <num>` to +display the content of the mail number "num". +You can use abbreviations for commands: "p" is the same as "print". "e" means +"edit", "v" means "visual". + +There are A LOT of commands (to delete mails, encrypt/decrypt, copy to folders, +manage aliases, ...) + +You can even define macros, to make action like, add sender to aliases, mark as +read, copy to another folder and delete the current mail. + +Today, I discovered `mail` which does anything I need to manage my e-mails. I'll +probably make the switch from mutt on all my machines once I'll be used to it. + +This little discovery reminded me that UNIX was and still is a great operating +system, regardless of all the tools that have been developped since its birth. + +I hope you (re)learnt something with this article. I don't hear about `mail` +that much nowadays, although it's really usable and functionnal. I feel like a +pokemon hunter. Aware that there are many, many tools out there, of different +forms, with different purpose... I'll probably never use them all. But I'll try! + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/12/love-me-some-latex.html b/2013/12/love-me-some-latex.html @@ -1,400 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset='utf-8'/> - <link rel='stylesheet' href='/css/monochrome.css'/> - <link rel='stylesheet' href='/css/code.css'/> - <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/> - <title>z3bra.org - monochromatic blog</title> - </head> - <body> - <header> - <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2> - </header> - <div id='wrapper'> - <section> - <h1> - <a href='#'>Love me some LaTeX</a> - </h1> - <h2> - &mdash; 06 December, 2013 - </h2> - <article> - <p> - I am now in my last year of engineering school, and this imply that - I will have to write a report for the last 3 years I spent in my - company, as an apprentice. As a fellow Linux user, I don't want to - use that <span class='strike'>fucking</span> text processor. I love my vim - setup, and I want to use it to write that report. - </p> - <h3>Introduction</h3> - <p> - So i came to <a href="http://www.latex-project.org/">LaTeX</a>.<br/> - Latex (side note: I will not write "LaTeX" everytime in this post. - I'm too lazy for that) is a kind of markup language that you can use - to write scientific reports, or anything you want in fact.<br/> - <br /> - It is intelligent in the sense that, you don't have to bother about - the formatting on the document, latex will do that for you, and - probably better than you. So you can just <strong>focus on what your - are typing</strong>. - </p> - <p> - Seems interresting huh? So basically, what does it look like? Here's - a simple document (download/view it - <a href="http://raw.z3bra.org/null/la.pdf">HERE</a>) - </p> - - <pre><code>la.tex - -<span class="Statement">\documentclass</span><span class="Special">[</span><span class="Constant">9pt</span><span class="Special">]{</span><span class="PreProc">report</span><span class="Special">}</span> <span class="Comment">% Start of document</span> - -<span class="Statement">\usepackage</span><span class="Special">[</span><span class="Constant">utf8</span><span class="Special">]</span><span class="Special">{</span><span class="Special">inputenc</span><span class="Special">}</span> <span class="Comment">% Write text unsing UTF-8 encoding</span> -<span class="Statement">\usepackage</span><span class="Special">{</span><span class="Special">graphicx</span><span class="Special">}</span> <span class="Comment">% Use graphics for diagrams and such</span> - -<span class="PreProc">\title{</span><span class="Statement">\LaTeX</span> exemple<span class="PreProc">}</span> -<span class="PreProc">\author{</span>z3bra, the cool guy<span class="PreProc">}</span> -<span class="Statement">\date</span><span class="Special">{</span><span class="Statement">\today</span><span class="Special">}</span> - -<span class="PreProc">\begin{document}</span> - -<span class="Statement">\maketitle</span> -<span class="Statement">\tableofcontents</span> -<span class="Statement">\listoftables</span> -<span class="Statement">\listoffigures</span> -<span class="Statement">\newpage</span> - -<span class="PreProc">\chapter</span><span class="Special">{</span>Introduction<span class="Special">}</span> - -<span class="PreProc">\section</span><span class="Special">{</span><span class="Statement">\LaTeX</span> is fun<span class="Special">}</span> -Bla bla, latex is cool, and not only in bed. -See that explanatory figure to figure out why: - -<span class="Statement">\begin</span><span class="Special">{</span><span class="PreProc">figure</span><span class="Special">}[</span>h!<span class="Special">]</span> - <span class="Statement">\centering</span> - <span class="Statement">\includegraphics</span><span class="Special">[</span><span class="Constant">width=\textwidth</span><span class="Special">]</span><span class="Special">{</span><span class="Special">figure</span><span class="Special">}</span> - <span class="Statement">\caption</span><span class="Special">{</span>Figure caption<span class="Special">}</span> - <span class="Statement">\label{</span><span class="Special">fig:figure</span><span class="Statement">}</span> -<span class="Statement">\end</span><span class="Special">{</span><span class="PreProc">figure</span><span class="Special">}</span> - -that might not be the good figure. Anyway... - -<span class="PreProc">\subsection</span><span class="Special">{</span>Love?<span class="Special">}</span> -Do you love me some <span class="Statement">\LaTeX</span>? - -<span class="PreProc">\subsection</span><span class="Special">{</span>Llorem ipsum<span class="Special">}</span> -My money's in that office, right? If she start giving me some bullshit about it -ain't there, and we got to go someplace else and get it, I'm gonna shoot you in -the head then and there. Then I'm gonna shoot that bitch in the kneecaps, find -out where my goddamn money is. She gonna tell me too. Hey, look at me when I'm -talking to you, motherfucker. You listen: we go in there, and that nigga Winston -or anybody else is in there, you the first motherfucker to get shot. You -understand? - -Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is -advertised as the most popular gun in American crime. Do you believe that shit? -It actually says that in the little book that comes with it: the most popular -gun in American crime. Like they're actually proud of that shit. - -Now that we know who you are, I know who I am. I'm not a mistake! It all makes -sense! In a comic, you know how you can tell who the arch-villain's going to be? -He's the exact opposite of the hero. And most times they're friends, like you -and me! I should've known way back when... You know why, David? Because of the -kids. They called me Mr Glass. - -<span class="Statement">\appendix</span> -<span class="PreProc">\chapter</span><span class="Special">{</span>Appendix<span class="Special">}</span> - -<span class="PreProc">\section</span><span class="Special">{</span>Oh! A table!<span class="Special">}</span> -<span class="Statement">\begin</span><span class="Special">{</span><span class="PreProc">table</span><span class="Special">}[</span>h!<span class="Special">]</span> - <span class="Statement">\begin</span><span class="Special">{</span><span class="PreProc">tabular</span><span class="Special">}</span><span class="Special">{</span> | l | l | p<span class="Special">{</span><span class="Constant">5cm</span><span class="Special">}</span> | <span class="Special">}</span> - <span class="Comment">% pretty that shit with !column -t -s \&amp; -o \&amp;</span> - <span class="Statement">\hline</span> - COLUMN <span class="Special">&amp;</span> COLUMN 3 HEADER <span class="Special">&amp;</span> DESCRIPTION <span class="Special">\\</span> <span class="Statement">\hline</span> <span class="Statement">\hline</span> - column <span class="Special">&amp;</span> name of something <span class="Special">&amp;</span> Description of that, eeh <span class="Special">\\</span> <span class="Statement">\hline</span> - column <span class="Special">&amp;</span> name of something <span class="Special">&amp;</span> Description of that, eeh <span class="Special">\\</span> <span class="Statement">\hline</span> - column <span class="Special">&amp;</span> name of something <span class="Special">&amp;</span> Description of that, eeh <span class="Special">\\</span> <span class="Statement">\hline</span> - column <span class="Special">&amp;</span> name of something <span class="Special">&amp;</span> Description of that, eeh <span class="Special">\\</span> <span class="Statement">\hline</span> - column <span class="Special">&amp;</span> name of something <span class="Special">&amp;</span> Description of that, eeh <span class="Special">\\</span> <span class="Statement">\hline</span> - column <span class="Special">&amp;</span> name of something <span class="Special">&amp;</span> Description of that, eeh <span class="Special">\\</span> <span class="Statement">\hline</span> <span class="Statement">\hline</span> - FOOTER <span class="Special">&amp;</span> NAME OF FOOTER <span class="Special">&amp;</span> WHO CARES WHAT'S HERE? <span class="Special">\\</span> <span class="Statement">\hline</span> - <span class="Statement">\end</span><span class="Special">{</span><span class="PreProc">tabular</span><span class="Special">}</span> - <span class="Statement">\caption</span><span class="Special">{</span>Exemple of a table<span class="Special">}</span> - <span class="Statement">\label{</span><span class="Special">tab:table</span><span class="Statement">}</span> -<span class="Statement">\end</span><span class="Special">{</span><span class="PreProc">table</span><span class="Special">}</span> - -<span class="PreProc">\end{document}</span> -<span class="Comment">% vim&#0058; ft=tex tw=80 cc=81 nowrap fdm=marker :</span></code></pre> - - <p> - Wooow ! That's so many tags for such a simple thing!<br/> - In fact, once you get used to those tags, they are no more a - problem. Also, The more text you have, the less you'll see the tags. - </p> - <p> - So, now you know HOW latex looks like. But you don't know HOW to - write it, and what to do with that file.<br/> - Don't worry, that ain't difficult. - </p> - - <h3>Writing latex</h3> - <p> - Latex files basically looks like any source file. First come the - definitions, and then the source (document) itself.<br/> - The definitions are importants because that will tell latex HOW to - create the document. - </p> - <p> - Latex tags are only a \ followed by a command. If that keyword needs - an argument, that argument is given within {}. If that command needs - an option, that option is given within []. Seems hard ? It is not. - Take a look at this: - </p> - - - <pre><code><span class="Statement">\command</span><span - class="Special">[</span><span class="Constant">option</span><span - class="Special">]{</span><span - class="PreProc">argument</span><span class="Special">}</span> <span - class="Comment">% comments are from % 'til EOL</span></code></pre> - - <p> - Do you get it now ? Then, move on. - </p> - <p> - The simplest header would be: - </p> - <pre><code><span class="Statement">\documentclass</span><span class="Special">{</span><span class="PreProc">report</span><span class="Special">}</span></code></pre> - - <p> - This will tell to latex that you want to write a report. Latex knows - what a report is, so it will apply a set of rules (margin, font - size, numerotation of chapters/section, and so on). So you will ONLY - have to rewrite the rules you don't like, or that are missing. - I'll not cover that in this post, because there are too many way - to do so, and you are tall enough to find infos by yourself - <span class='smiley'>;)</span>. Latex has a huge wiki, which is - great. Use it! - </p> - <p> - Now, the body. Here to, I will give you the most basic body (eg, not - covering figures, or table. The wiki is better than me to that). - So, the most simple body is the following: - </p> - - - <pre><code><span class="PreProc">\begin{document}</span> - -<span class="PreProc">\chapter</span><span class="Special">{</span>First chapter<span class="Special">}</span> - -<span class="PreProc">\section</span><span class="Special">{</span><span class="Statement">\LaTeX</span> is fun<span class="Special">}</span> -My money's in that office, right? If she start giving me some bullshit about it -ain't there, and we got to go someplace else and get it, I'm gonna shoot you in -the head then and there. Then I'm gonna shoot that bitch in the kneecaps, find -out where my goddamn money is. She gonna tell me too. Hey, look at me when I'm -talking to you, motherfucker. You listen: we go in there, and that nigga Winston -or anybody else is in there, you the first motherfucker to get shot. You -understand? - -<span class="PreProc">\section</span><span class="Special">{</span>Middle section<span class="Special">}</span> -Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is -advertised as the most popular gun in American crime. Do you believe that shit? -It actually says that in the little book that comes with it: the most popular -gun in American crime. Like they're actually proud of that shit. - - -<span class="PreProc">\chapter</span><span class="Special">{</span>Last chapter<span class="Special">}</span> - -<span class="PreProc">\section</span><span class="Special">{</span>Last section<span class="Special">}</span> -Now that we know who you are, I know who I am. I'm not a mistake! It all makes -sense! In a comic, you know how you can tell who the arch-villain's going to be? -He's the exact opposite of the hero. And most times they're friends, like you -and me! I should've known way back when... You know why, David? Because of the -kids. They called me Mr Glass. - -<span class="PreProc">\end{document}</span></code></pre> - - <p> - You're still there ? Fine. Now, what should we do with that file ? - </p> - - <h3>Compilation</h3> - <p> - Yeah, you read it right. You compile a Latex file, because it has to - generate many other files in order to understand your whole - document.<br /> - It will have to count yur chapters, sections, subsection, and so on. - Then, create a output file which will be formatted, and correctly - numeroted, linked to your figures, tables, etc.. - </p> - <p> - So, how does it works ? Taht's easy, just call <code>latex</code> on - your file to have it compiled. - - </p> - <pre><code>latex file.tex</code></pre> - - <p> - - This command will create a <strong>dvi</strong> file. If you want - another format, you you be able to use any other tool to convert it - to the fomat you want: - </p> - - <pre><code>dvips file.dvi -dvipdf file.dvi</code></pre> - - <p> - This will create two files: <code>file.ps</code>, and - <code>file.pdf</code> (U DONT SAY?!), that you will be able to view - in your prefered PDF viewer. (I suggest - <a href="http://pwmt.org/projects/zathura/">zathura</a>, which is - able to reload automatically your file if the timestamp have - changed) - </p> - <p> - I here someone in the audience whispering: - <q>But, That's a pain !</q>. You are not wrong ! That's why my - favorite tool comes to the rescue: <code>make</code>. - Yes ! Each time you hear or read the word <em>compilation</em>, you - should instantly think <em>Makefile</em>. That's what I did, and it - has saved me a lot of time!<br/> - I could leave it to you as an exercise, but I know that some of you - are just lazy. So here is the makefile I came with: - </p> - - <pre><code><span class="Comment"># File name</span> -<span class="Identifier">BASE </span>= la - -<span class="Comment"># How to view output files</span> -<span class="Identifier">VIEWER </span>= zathura - -<span class="Comment"># Files used for diagrams (umlet file)</span> -<span class="Identifier">uxffiles</span>=<span class="Identifier">$(</span><span class="Statement">wildcard</span><span class="Identifier"> fig/*.uxf)</span> - -<span class="Comment"># Those files, with the correct extension for LaTeX</span> -<span class="Identifier">figures</span>=<span class="Identifier">$(</span><span class="Statement">patsubst</span><span class="Identifier"> %.uxf,%.eps,${uxffiles})</span> - -<span class="Statement">.SUFFIXES:</span> -<span class="Statement">.SUFFIXES:</span>.ps .pdf .dvi .tex .uxf .eps .toc .lof .lot - -<span class="Statement">.PHONY:</span> default all dvi ps pdf eps view view-ps view-pdf clean mrproper - -<span class="Comment"># What should 'make' run by default ?</span> -<span class="Function">default:</span> ps - -<span class="Comment"># build everything</span> -<span class="Function">all:</span> ps pdf view-ps - -<span class="Comment"># The output files</span> -<span class="Function">dvi:</span> <span class="Identifier">${BASE}</span>.dvi -<span class="Function">ps:</span> <span class="Identifier">${BASE}</span>.ps -<span class="Function">pdf:</span> <span class="Identifier">${BASE}</span>.pdf -<span class="Function">eps:</span> <span class="Identifier">${figures}</span> - -<span class="Comment"># Default view</span> -<span class="Function">view:</span> view-ps - -<span class="Comment"># --- DVI ---------------------------------------</span> -<span class="Identifier">${BASE}</span>.dvi: <span class="Identifier">${figures}</span> <span class="Identifier">${BASE}</span>.toc <span class="Identifier">${BASE}</span>.tex -<span class="Special"> @</span>echo <span class="String">&quot;TEX </span><span class="Identifier">${BASE}</span><span class="String">.tex&quot;</span> -<span class="Special"> @</span>latex <span class="Identifier">${BASE}</span>.tex &gt;/dev/null - -<span class="Comment"># --- TOC ---------------------------------------</span> -<span class="Identifier">${BASE}</span>.toc: <span class="Identifier">${figures}</span> <span class="Identifier">${BASE}</span>.tex -<span class="Special"> @</span>echo <span class="String">&quot;TOC </span><span class="Identifier">${BASE}</span><span class="String">.tex&quot;</span> -<span class="Special"> @</span>latex -draftmode <span class="Identifier">${BASE}</span>.tex &gt;/dev/null - -<span class="Comment"># --- EPS ---------------------------------</span> -<span class="Function">.uxf.eps:</span> -<span class="Special"> @</span><span class="Constant">echo </span><span class="String">&quot;EPS </span><span class="Identifier">$&lt;</span><span class="String">&quot;</span> -<span class="Special"> @</span><span class="Constant">umlet -action=convert -format=eps -filename=</span><span class="Identifier">$&lt;</span><span class="Constant"> &gt;/dev/null</span> - -<span class="Comment"># --- PS ----------------------------------------</span> -<span class="Function">.dvi.ps:</span> -<span class="Special"> @</span><span class="Constant">echo </span><span class="String">&quot;PS </span><span class="Identifier">$&lt;</span><span class="String">&quot;</span> -<span class="Special"> @</span><span class="Constant">dvips -q </span><span class="Identifier">$&lt;</span> - -<span class="Comment"># --- PDF ---------------------------------------</span> -<span class="Function">.dvi.pdf:</span> -<span class="Special"> @</span><span class="Constant">echo </span><span class="String">&quot;PDF </span><span class="Identifier">$&lt;</span><span class="String">&quot;</span> -<span class="Special"> @</span><span class="Constant">dvipdf -q </span><span class="Identifier">$&lt;</span> - -<span class="Comment"># --- OTHER -------------------------------------</span> -<span class="Function">view-%:</span> <span class="Identifier">${BASE}</span>.<span class="Identifier">%</span> -<span class="Constant"> </span><span class="Identifier">${VIEWER}</span><span class="Constant"> </span><span class="Identifier">$&lt;</span> - -<span class="Function">clean:</span> -<span class="Constant"> rm -f *.aux</span> -<span class="Constant"> rm -f *.log</span> -<span class="Constant"> rm -f *.dvi</span> -<span class="Constant"> rm -f *.lof</span> -<span class="Constant"> rm -f *.lot</span> -<span class="Constant"> rm -f *.toc</span> - -<span class="Function">mrproper:</span> clean -<span class="Constant"> rm -f fig/*.eps</span> -<span class="Constant"> rm -f *.pdf</span> -<span class="Constant"> rm -f *.ps</span></code></pre> - - <p> - Easy to use! - </p> - - <pre><code>make [dvi|ps|pdf|eps] # build either the dvi/ps/pdf files, or the eps files -make [view-ps|view-pdf] # calls ${VIEWER} on either the ps or pdf file</code></pre> - - <p> - Maybe... To get the "eps" part, see the <a href="#tips">tips - section</a> - </p> - - <h3>Enjoy !</h3> - <p> - There you go, you are now ready to write your own latex documents, - and browser the web to find help about what is not explained in - this post (there is <strong>A LOT</strong> things about latex..) - </p> - <p> - Before to unleash you, here are just a few tips, from my experience - with latex (particularly images). - </p> - - <ul id='tips'> - <li> - Read other documents, there are goldmine out there, and that - will help you a lot - </li> - <li> - Write the skeleton of your file BEFORE the text itself, so you - can focus on what you type. - </li> - <li> - DVI format only support EPS files to render figures, now you're - warned.. - </li> - <li> - <a href="http://umlet.com/">UMLet</a> is a great tool to create - diagrams and such. It also include a cli routine to export files - to format like pdf/jpg/eps (see the Makefile above) - </li> - <li> - Latex can also write letter! That's cool isn't it? - </li> - </ul> - - </article> - </section> - </div> - <!-- footer {{{ --> - <footer> - <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->// - <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->// - <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->// - <a href='http://z3bra.org'>root</a> <!-- &#9774; -->// - <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; --> - </footer> - <!-- }}} --> - </body> -</html> -<!-- vim: set sw=2 et ai fdm=marker ft=html: --> diff --git a/2013/12/love-me-some-latex.md b/2013/12/love-me-some-latex.md @@ -1,330 +0,0 @@ -# [Love me some LaTeX](#) -## &mdash; 06 December, 2013 - - -I am now in my last year of engineering school, and this imply that -I will have to write a report for the last 3 years I spent in my -company, as an apprentice. As a fellow Linux user, I don't want to -use that fucking text processor. I love my vim -setup, and I want to use it to write that report. - -### Introduction - -So i came to [LaTeX](http://www.latex-project.org/). -Latex (side note: I will not write "LaTeX" everytime in this post. -I'm too lazy for that) is a kind of markup language that you can use -to write scientific reports, or anything you want in fact. - -It is intelligent in the sense that, you don't have to bother about -the formatting on the document, latex will do that for you, and -probably better than you. So you can just **focus on what your -are typing**. - -Seems interresting huh? So basically, what does it look like? Here's -a simple document (download/view it -[HERE](http://raw.z3bra.org/null/la.pdf)) - - la.tex - - \documentclass[9pt]{report} % Start of document - - \usepackage[utf8]{inputenc} % Write text unsing UTF-8 encoding - \usepackage{graphicx} % Use graphics for diagrams and such - - \title{\LaTeX exemple} - \author{z3bra, the cool guy} - \date{\today} - - \begin{document} - - \maketitle - \tableofcontents - \listoftables - \listoffigures - \newpage - - \chapter{Introduction} - - \section{\LaTeX is fun} - Bla bla, latex is cool, and not only in bed. - See that explanatory figure to figure out why: - - \begin{figure}[h!] - \centering - \includegraphics[width=\textwidth]{figure} - \caption{Figure caption} - \label{fig:figure} - \end{figure} - - that might not be the good figure. Anyway... - - \subsection{Love?} - Do you love me some \LaTeX? - - \subsection{Llorem ipsum} - My money's in that office, right? If she start giving me some bullshit about it - ain't there, and we got to go someplace else and get it, I'm gonna shoot you in - the head then and there. Then I'm gonna shoot that bitch in the kneecaps, find - out where my goddamn money is. She gonna tell me too. Hey, look at me when I'm - talking to you, motherfucker. You listen: we go in there, and that nigga Winston - or anybody else is in there, you the first motherfucker to get shot. You - understand? - - Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is - advertised as the most popular gun in American crime. Do you believe that shit? - It actually says that in the little book that comes with it: the most popular - gun in American crime. Like they're actually proud of that shit. - - Now that we know who you are, I know who I am. I'm not a mistake! It all makes - sense! In a comic, you know how you can tell who the arch-villain's going to be? - He's the exact opposite of the hero. And most times they're friends, like you - and me! I should've known way back when... You know why, David? Because of the - kids. They called me Mr Glass. - - \appendix - \chapter{Appendix} - - \section{Oh! A table!} - \begin{table}[h!] - \begin{tabular}{ | l | l | p{5cm} | } - % pretty that shit with !column -t -s \&amp; -o \&amp; - \hline - COLUMN &amp; COLUMN 3 HEADER &amp; DESCRIPTION \\ \hline \hline - column &amp; name of something &amp; Description of that, eeh \\ \hline - column &amp; name of something &amp; Description of that, eeh \\ \hline - column &amp; name of something &amp; Description of that, eeh \\ \hline - column &amp; name of something &amp; Description of that, eeh \\ \hline - column &amp; name of something &amp; Description of that, eeh \\ \hline - column &amp; name of something &amp; Description of that, eeh \\ \hline \hline - FOOTER &amp; NAME OF FOOTER &amp; WHO CARES WHAT'S HERE? \\ \hline - \end{tabular} - \caption{Exemple of a table} - \label{tab:table} - \end{table} - - \end{document} - % vim&#0058; ft=tex tw=80 cc=81 nowrap fdm=marker : - - -Wooow ! That's so many tags for such a simple thing! -In fact, once you get used to those tags, they are no more a -problem. Also, The more text you have, the less you'll see the tags. - - -So, now you know HOW latex looks like. But you don't know HOW to -write it, and what to do with that file. -Don't worry, that ain't difficult. - - -### Writing latex - -Latex files basically looks like any source file. First come the -definitions, and then the source (document) itself. -The definitions are importants because that will tell latex HOW to -create the document. - -Latex tags are only a \ followed by a command. If that keyword needs -an argument, that argument is given within {}. If that command needs -an option, that option is given within []. Seems hard ? It is not. -Take a look at this: - - \command[option]{argument} - % comments are from % 'til EOL - -Do you get it now ? Then, move on. - -The simplest header would be: - - \documentclass{report} - - -This will tell to latex that you want to write a report. Latex knows -what a report is, so it will apply a set of rules (margin, font -size, numerotation of chapters/section, and so on). So you will ONLY -have to rewrite the rules you don't like, or that are missing. -I'll not cover that in this post, because there are too many way -to do so, and you are tall enough to find infos by yourself -;). Latex has a huge wiki, which is -great. Use it! - - -Now, the body. Here to, I will give you the most basic body (eg, not -covering figures, or table. The wiki is better than me to that). -So, the most simple body is the following: - - \begin{document} - - \chapter{First chapter} - - \section{\LaTeX is fun} - My money's in that office, right? If she start giving me some bullshit about it - ain't there, and we got to go someplace else and get it, I'm gonna shoot you in - the head then and there. Then I'm gonna shoot that bitch in the kneecaps, find - out where my goddamn money is. She gonna tell me too. Hey, look at me when I'm - talking to you, motherfucker. You listen: we go in there, and that nigga Winston - or anybody else is in there, you the first motherfucker to get shot. You - understand? - - \section{Middle section} - Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is - advertised as the most popular gun in American crime. Do you believe that shit? - It actually says that in the little book that comes with it: the most popular - gun in American crime. Like they're actually proud of that shit. - - - \chapter{Last chapter} - - \section{Last section} - Now that we know who you are, I know who I am. I'm not a mistake! It all makes - sense! In a comic, you know how you can tell who the arch-villain's going to be? - He's the exact opposite of the hero. And most times they're friends, like you - and me! I should've known way back when... You know why, David? Because of the - kids. They called me Mr Glass. - - \end{document} - - -You're still there ? Fine. Now, what should we do with that file ? - - -### Compilation - -Yeah, you read it right. You compile a Latex file, because it has to -generate many other files in order to understand your whole -document. -It will have to count yur chapters, sections, subsection, and so on. -Then, create a output file which will be formatted, and correctly -numeroted, linked to your figures, tables, etc.. - - -So, how does it works ? Taht's easy, just call `latex` on your file to have it -compiled. - - latex file.tex - -This command will create a **dvi** file. If you want -another format, you you be able to use any other tool to convert it -to the fomat you want: - - dvips file.dvi - dvipdf file.dvi - -This will create two files: `file.ps`, and `file.pdf` (U DONT SAY?!), that you -will be able to view in your prefered PDF viewer. (I suggest -[zathura](http://pwmt.org/projects/zathura/), which is able to reload -automatically your file if the timestamp have changed) - - -I here someone in the audience whispering: -<q>But, That's a pain !</q>. You are not wrong ! That's why my -favorite tool comes to the rescue: `make`. -Yes ! Each time you hear or read the word _compilation_, you -should instantly think _Makefile_. That's what I did, and it -has saved me a lot of time! -I could leave it to you as an exercise, but I know that some of you -are just lazy. So here is the makefile I came with: - - # File name - BASE = la - - # How to view output files - VIEWER = zathura - - # Files used for diagrams (umlet file) - uxffiles=$(wildcard fig/*.uxf) - - # Those files, with the correct extension for LaTeX - figures=$(patsubst %.uxf,%.eps,${uxffiles}) - - .SUFFIXES: - .SUFFIXES:.ps .pdf .dvi .tex .uxf .eps .toc .lof .lot - - .PHONY: default all dvi ps pdf eps view view-ps view-pdf clean mrproper - - # What should 'make' run by default ? - default: ps - - # build everything - all: ps pdf view-ps - - # The output files - dvi: ${BASE}.dvi - ps: ${BASE}.ps - pdf: ${BASE}.pdf - eps: ${figures} - - # Default view - view: view-ps - - # --- DVI --------------------------------------- - ${BASE}.dvi: ${figures} ${BASE}.toc ${BASE}.tex - @echo &quot;TEX ${BASE}.tex&quot; - @latex ${BASE}.tex &gt;/dev/null - - # --- TOC --------------------------------------- - ${BASE}.toc: ${figures} ${BASE}.tex - @echo &quot;TOC ${BASE}.tex&quot; - @latex -draftmode ${BASE}.tex &gt;/dev/null - - # --- EPS --------------------------------- - .uxf.eps: - @echo &quot;EPS $&lt;&quot; - @umlet -action=convert -format=eps -filename=$&lt; &gt;/dev/null - - # --- PS ---------------------------------------- - .dvi.ps: - @echo &quot;PS $&lt;&quot; - @dvips -q $&lt; - - # --- PDF --------------------------------------- - .dvi.pdf: - @echo &quot;PDF $&lt;&quot; - @dvipdf -q $&lt; - - # --- OTHER ------------------------------------- - view-%: ${BASE}.% - ${VIEWER} $&lt; - - clean: - rm -f *.aux - rm -f *.log - rm -f *.dvi - rm -f *.lof - rm -f *.lot - rm -f *.toc - - mrproper: clean - rm -f fig/*.eps - rm -f *.pdf - rm -f *.ps - -Easy to use! - - make [dvi|ps|pdf|eps] # build either the dvi/ps/pdf files, or the eps files - make [view-ps|view-pdf] # calls ${VIEWER} on either the ps or pdf file - -Maybe... To get the "eps" part, see the [tips section](#tips) - -### Enjoy ! - -There you go, you are now ready to write your own latex documents, -and browser the web to find help about what is not explained in -this post (there is **A LOT** things about latex..) - -### Tips - -Before leaving you, here are just a few tips, from my experience -with latex (particularly images). - -* Read other documents, there are goldmine out there, and that - will help you a lot -* Write the skeleton of your file BEFORE the text itself, so you - can focus on what you type. -* DVI format only support EPS files to render figures, now you're - warned.. -* [UMLet](http://umlet.com/) is a great tool to create - diagrams and such. It also include a cli routine to export files - to format like pdf/jpg/eps (see the Makefile above) -* Latex can also write letter! That's cool isn't it? - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2013/12/love-me-some-latex.txt b/2013/12/love-me-some-latex.txt @@ -0,0 +1,330 @@ +# [Love me some LaTeX](#) +## &mdash; 06 December, 2013 + + +I am now in my last year of engineering school, and this imply that +I will have to write a report for the last 3 years I spent in my +company, as an apprentice. As a fellow Linux user, I don't want to +use that fucking text processor. I love my vim +setup, and I want to use it to write that report. + +### Introduction + +So i came to [LaTeX](http://www.latex-project.org/). +Latex (side note: I will not write "LaTeX" everytime in this post. +I'm too lazy for that) is a kind of markup language that you can use +to write scientific reports, or anything you want in fact. + +It is intelligent in the sense that, you don't have to bother about +the formatting on the document, latex will do that for you, and +probably better than you. So you can just **focus on what your +are typing**. + +Seems interresting huh? So basically, what does it look like? Here's +a simple document (download/view it +[HERE](http://raw.z3bra.org/null/la.pdf)) + + la.tex + + \documentclass[9pt]{report} % Start of document + + \usepackage[utf8]{inputenc} % Write text unsing UTF-8 encoding + \usepackage{graphicx} % Use graphics for diagrams and such + + \title{\LaTeX exemple} + \author{z3bra, the cool guy} + \date{\today} + + \begin{document} + + \maketitle + \tableofcontents + \listoftables + \listoffigures + \newpage + + \chapter{Introduction} + + \section{\LaTeX is fun} + Bla bla, latex is cool, and not only in bed. + See that explanatory figure to figure out why: + + \begin{figure}[h!] + \centering + \includegraphics[width=\textwidth]{figure} + \caption{Figure caption} + \label{fig:figure} + \end{figure} + + that might not be the good figure. Anyway... + + \subsection{Love?} + Do you love me some \LaTeX? + + \subsection{Llorem ipsum} + My money's in that office, right? If she start giving me some bullshit about it + ain't there, and we got to go someplace else and get it, I'm gonna shoot you in + the head then and there. Then I'm gonna shoot that bitch in the kneecaps, find + out where my goddamn money is. She gonna tell me too. Hey, look at me when I'm + talking to you, motherfucker. You listen: we go in there, and that nigga Winston + or anybody else is in there, you the first motherfucker to get shot. You + understand? + + Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is + advertised as the most popular gun in American crime. Do you believe that shit? + It actually says that in the little book that comes with it: the most popular + gun in American crime. Like they're actually proud of that shit. + + Now that we know who you are, I know who I am. I'm not a mistake! It all makes + sense! In a comic, you know how you can tell who the arch-villain's going to be? + He's the exact opposite of the hero. And most times they're friends, like you + and me! I should've known way back when... You know why, David? Because of the + kids. They called me Mr Glass. + + \appendix + \chapter{Appendix} + + \section{Oh! A table!} + \begin{table}[h!] + \begin{tabular}{ | l | l | p{5cm} | } + % pretty that shit with !column -t -s \&amp; -o \&amp; + \hline + COLUMN &amp; COLUMN 3 HEADER &amp; DESCRIPTION \\ \hline \hline + column &amp; name of something &amp; Description of that, eeh \\ \hline + column &amp; name of something &amp; Description of that, eeh \\ \hline + column &amp; name of something &amp; Description of that, eeh \\ \hline + column &amp; name of something &amp; Description of that, eeh \\ \hline + column &amp; name of something &amp; Description of that, eeh \\ \hline + column &amp; name of something &amp; Description of that, eeh \\ \hline \hline + FOOTER &amp; NAME OF FOOTER &amp; WHO CARES WHAT'S HERE? \\ \hline + \end{tabular} + \caption{Exemple of a table} + \label{tab:table} + \end{table} + + \end{document} + % vim&#0058; ft=tex tw=80 cc=81 nowrap fdm=marker : + + +Wooow ! That's so many tags for such a simple thing! +In fact, once you get used to those tags, they are no more a +problem. Also, The more text you have, the less you'll see the tags. + + +So, now you know HOW latex looks like. But you don't know HOW to +write it, and what to do with that file. +Don't worry, that ain't difficult. + + +### Writing latex + +Latex files basically looks like any source file. First come the +definitions, and then the source (document) itself. +The definitions are importants because that will tell latex HOW to +create the document. + +Latex tags are only a \ followed by a command. If that keyword needs +an argument, that argument is given within {}. If that command needs +an option, that option is given within []. Seems hard ? It is not. +Take a look at this: + + \command[option]{argument} + % comments are from % 'til EOL + +Do you get it now ? Then, move on. + +The simplest header would be: + + \documentclass{report} + + +This will tell to latex that you want to write a report. Latex knows +what a report is, so it will apply a set of rules (margin, font +size, numerotation of chapters/section, and so on). So you will ONLY +have to rewrite the rules you don't like, or that are missing. +I'll not cover that in this post, because there are too many way +to do so, and you are tall enough to find infos by yourself +;). Latex has a huge wiki, which is +great. Use it! + + +Now, the body. Here to, I will give you the most basic body (eg, not +covering figures, or table. The wiki is better than me to that). +So, the most simple body is the following: + + \begin{document} + + \chapter{First chapter} + + \section{\LaTeX is fun} + My money's in that office, right? If she start giving me some bullshit about it + ain't there, and we got to go someplace else and get it, I'm gonna shoot you in + the head then and there. Then I'm gonna shoot that bitch in the kneecaps, find + out where my goddamn money is. She gonna tell me too. Hey, look at me when I'm + talking to you, motherfucker. You listen: we go in there, and that nigga Winston + or anybody else is in there, you the first motherfucker to get shot. You + understand? + + \section{Middle section} + Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is + advertised as the most popular gun in American crime. Do you believe that shit? + It actually says that in the little book that comes with it: the most popular + gun in American crime. Like they're actually proud of that shit. + + + \chapter{Last chapter} + + \section{Last section} + Now that we know who you are, I know who I am. I'm not a mistake! It all makes + sense! In a comic, you know how you can tell who the arch-villain's going to be? + He's the exact opposite of the hero. And most times they're friends, like you + and me! I should've known way back when... You know why, David? Because of the + kids. They called me Mr Glass. + + \end{document} + + +You're still there ? Fine. Now, what should we do with that file ? + + +### Compilation + +Yeah, you read it right. You compile a Latex file, because it has to +generate many other files in order to understand your whole +document. +It will have to count yur chapters, sections, subsection, and so on. +Then, create a output file which will be formatted, and correctly +numeroted, linked to your figures, tables, etc.. + + +So, how does it works ? Taht's easy, just call `latex` on your file to have it +compiled. + + latex file.tex + +This command will create a **dvi** file. If you want +another format, you you be able to use any other tool to convert it +to the fomat you want: + + dvips file.dvi + dvipdf file.dvi + +This will create two files: `file.ps`, and `file.pdf` (U DONT SAY?!), that you +will be able to view in your prefered PDF viewer. (I suggest +[zathura](http://pwmt.org/projects/zathura/), which is able to reload +automatically your file if the timestamp have changed) + + +I here someone in the audience whispering: +<q>But, That's a pain !</q>. You are not wrong ! That's why my +favorite tool comes to the rescue: `make`. +Yes ! Each time you hear or read the word _compilation_, you +should instantly think _Makefile_. That's what I did, and it +has saved me a lot of time! +I could leave it to you as an exercise, but I know that some of you +are just lazy. So here is the makefile I came with: + + # File name + BASE = la + + # How to view output files + VIEWER = zathura + + # Files used for diagrams (umlet file) + uxffiles=$(wildcard fig/*.uxf) + + # Those files, with the correct extension for LaTeX + figures=$(patsubst %.uxf,%.eps,${uxffiles}) + + .SUFFIXES: + .SUFFIXES:.ps .pdf .dvi .tex .uxf .eps .toc .lof .lot + + .PHONY: default all dvi ps pdf eps view view-ps view-pdf clean mrproper + + # What should 'make' run by default ? + default: ps + + # build everything + all: ps pdf view-ps + + # The output files + dvi: ${BASE}.dvi + ps: ${BASE}.ps + pdf: ${BASE}.pdf + eps: ${figures} + + # Default view + view: view-ps + + # --- DVI --------------------------------------- + ${BASE}.dvi: ${figures} ${BASE}.toc ${BASE}.tex + @echo &quot;TEX ${BASE}.tex&quot; + @latex ${BASE}.tex &gt;/dev/null + + # --- TOC --------------------------------------- + ${BASE}.toc: ${figures} ${BASE}.tex + @echo &quot;TOC ${BASE}.tex&quot; + @latex -draftmode ${BASE}.tex &gt;/dev/null + + # --- EPS --------------------------------- + .uxf.eps: + @echo &quot;EPS $&lt;&quot; + @umlet -action=convert -format=eps -filename=$&lt; &gt;/dev/null + + # --- PS ---------------------------------------- + .dvi.ps: + @echo &quot;PS $&lt;&quot; + @dvips -q $&lt; + + # --- PDF --------------------------------------- + .dvi.pdf: + @echo &quot;PDF $&lt;&quot; + @dvipdf -q $&lt; + + # --- OTHER ------------------------------------- + view-%: ${BASE}.% + ${VIEWER} $&lt; + + clean: + rm -f *.aux + rm -f *.log + rm -f *.dvi + rm -f *.lof + rm -f *.lot + rm -f *.toc + + mrproper: clean + rm -f fig/*.eps + rm -f *.pdf + rm -f *.ps + +Easy to use! + + make [dvi|ps|pdf|eps] # build either the dvi/ps/pdf files, or the eps files + make [view-ps|view-pdf] # calls ${VIEWER} on either the ps or pdf file + +Maybe... To get the "eps" part, see the [tips section](#tips) + +### Enjoy ! + +There you go, you are now ready to write your own latex documents, +and browser the web to find help about what is not explained in +this post (there is **A LOT** things about latex..) + +### Tips + +Before leaving you, here are just a few tips, from my experience +with latex (particularly images). + +* Read other documents, there are goldmine out there, and that + will help you a lot +* Write the skeleton of your file BEFORE the text itself, so you + can focus on what you type. +* DVI format only support EPS files to render figures, now you're + warned.. +* [UMLet](http://umlet.com/) is a great tool to create + diagrams and such. It also include a cli routine to export files + to format like pdf/jpg/eps (see the Makefile above) +* Latex can also write letter! That's cool isn't it? + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2014/01/images-in-terminal.html b/2014/01/images-in-terminal.html @@ -1,273 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset='utf-8'/> - <link rel='stylesheet' href='/css/monochrome.css'/> - <link rel='stylesheet' href='/css/code.css'/> - <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/> - <title>z3bra.org - monochromatic blog</title> - </head> - <body> - <header> - <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2> - </header> - <div id='wrapper'> - <section> - <h1> - <a href='#'>Images in terminal</a> - </h1> - <h2> - &mdash; 28 January, 2014 - </h2> - <article> - <p> - I am a huge fan of the terminal. Really. 90% of the magic I realize - on my computer is through a terminal: IRC, text editing, ,e-mails, - file managing, package managing, developpement, even web browsing - sometimes ! - <br /> - But the terminal lack one thing: <strong>image rendering</strong>. - </p> - <p> - I have search a way to display images in the terminal for a - looooong time now, and after digging through fbi, fbterm, and - obscure graphical drivers, I finally found my goldmine.. I stumbled - upon <a - href='http://www.nongnu.org/ranger/screenshots/w3mimgpreview.png'>this picture</a> - taken from <a href='http://www.nongnu.org/ranger/'>this website</a>. - Ranger. It's a text-based file manager (that's cool bro'), but the - interesting point sits in the "dependencies" section: - </p> - - <blockquote> - <cite>&bull; w3m for previewing images in "true color".</cite> - </blockquote> - - <p> - <a href='http://w3m.sourceforge.net'>w3m</a>. That was my - answer. - </p> - - <h3>the package</h3> - <p> - w3m is a text-based web browser. It means that you can use it to - browse the web from within your terminal (good stuff!). There are - many like it (lynx, links, elinks, edbrowse,..), but this one is - different, as it acts more like a point'n'click software than a CLI - app. - </p> - - <p> - w3m uses gpm, a tool that let you use your terminal cursor like a - mouse, moving it character by character.<br /> - Anyway, that's not the point here. Let's go back to image viewing! - w3m has the particularity to render images in your terminal, and it - is pretty good at it! The problem was to find out - <strong>HOW</strong>. I browsed the manpage many, many times, - searching for keywords like <q>image</q>, <q>preview</q>, <q>gimme - my f**cking image rendering, damn software!</q>. Every usefull - keyword I could find. <strong>Nothing</strong>. - </p> - - <h3>the pursuit</h3> - <p> - A few minutes (when all the buckets were fullfilled with my tears), - I finally tough: <q>Use the source, z3bra</q>.<br /> That's how I - installed ranger. - </p> - - <p> - Ranger is written in python. And if it uses w3m to render images, I - would find the tool it uses to do so. Here is how I managed to find - it: - </p> - - <pre><code>$ pacman -Ql ranger | grep -E 'image|img|w3m|picture|preview' -ranger /usr/lib/python3.3/site-packages/ranger/ext/__pycache__/img_display.cpython-33.pyc -ranger /usr/lib/python3.3/site-packages/ranger/ext/__pycache__/img_display.cpython-33.pyo -ranger /usr/lib/python3.3/site-packages/ranger/ext/img_display.py - -$ grep 'w3m' /usr/lib/python3.3/site-packages/ranger/ext/img_display.py - ... -W3MIMGDISPLAY_PATH = '/usr/lib/w3m/w3mimgdisplay' - ...</code></pre> - - <p> - <strong>HOORAY!</strong> A binary ! Next step will be to understand - how to make it render images in the terminal.. - </p> - <h3>the trials</h3> - <p> - Obviously, running <code>w3mimgdisplay --help</code> would've been - too easy.. But I finally managed to understand a few things using - the ranger source I just found, and - <a href='https://www.mail-archive.com/mutt-users@mutt.org/msg34447.html'>this thread</a>. - Here is the idea: w3mimgdisplay reads commands from stdin, and draws - something on your terminal, pixel by pixel. - </p> - <p> - w3mimgdisplay commands are numbers from 0 to 6, and some commands - take additionnal parameters.<br /> - In the w3m tarball, you can find this: - </p> - - <pre><code>w3mimgdisplay.c - -/* - * w3mimg protocol - * 0 1 2 .... - * +--+--+--+--+ ...... +--+--+ - * |op|; |args |\n| - * +--+--+--+--+ .......+--+--+ - * - * args is separeted by ';' - * op args - * 0; params draw image - * 1; params redraw image - * 2; -none- terminate drawing - * 3; -none- sync drawing - * 4; -none- nop, sync communication - * response '\n' - * 5; path get size of image, - * response &quot;&lt;width&gt; &lt;height&gt;\n&quot; - * 6; params(6) clear image - * - * params - * &lt;n&gt;;&lt;x&gt;;&lt;y&gt;;&lt;w&gt;;&lt;h&gt;;&lt;sx&gt;;&lt;sy&gt;;&lt;sw&gt;;&lt;sh&gt;;&lt;path&gt; - * params(6) - * &lt;x&gt;;&lt;y&gt;;&lt;w&gt;;&lt;h&gt; - * - */</code></pre> - - <p> - Here is the <em>params</em> interpreted on the mutt mail list: - </p> - - <pre><code>&gt; n - This is used when displaying multiple images -&gt; x - x coordinate to draw the image at (top left corner) -&gt; y - y coordinate to draw the image at (top left corner) -&gt; w - width to draw the image -&gt; h - height to draw the image -&gt; sx - x offset to draw the image -&gt; xy - y offset to draw the image -&gt; sw - width of the original (source) image -&gt; sh - height of the original (source) image</code></pre> - - <p> - I now have a better idea on how the protocol works.<br /> - Now, by crossing it with the ranger source, I ended up with this - line: - </p> - - <pre><code>echo -e '0;1;0;0;200;160;;;;;ant.jpg\n4;\n3;' | /usr/lib/w3m/w3mimgdisplay </code></pre> - - <p> - <strong>BOOM !</strong> - <a href='http://chezmoicamarche.com'>It works!</a><br /> - <a class='a_img' href='/img/w3mimgdisplay-crap.jpg'> - <img class='a_img' src='/img/thumb/w3mimgdisplay-crap.jpg' - alt='Fucked up w3mimgdisplay trial'/> - </a> - <span class='caption'> - The result of the previous command. Our - picture drawn in 200x100px, at offset +0+0 in the terminal. - <br />I'm sure you're already trying it - <span class='smiley'>;)</span> - </span> - </p> - - <h3>the wrapping</h3> - <p> - Okay, we can now display an image in the terminal, at the offset - and size we want. Let's wrap it up in a script, to be more adaptive! - We will need some tools to help us here. Feel free to search by - yourself, as an exercise. Here is the script I came with: - </p> - - <pre><code><span class="Comment">#!/bin/bash</span> -<span class="Comment">#</span> -<span class="Comment"># z3bra -- 2014-01-21</span> - -<span class="Statement">test</span> <span class="Special">-z</span> <span class="Statement">&quot;</span><span class="PreProc">$1</span><span class="Statement">&quot;</span> &amp;&amp; <span class="Statement">exit</span> - -<span class="Identifier">W3MIMGDISPLAY</span>=<span class="Statement">&quot;</span><span class="String">/usr/lib/w3m/w3mimgdisplay</span><span class="Statement">&quot;</span> -<span class="Identifier">FILENAME</span>=<span class="PreProc">$1</span> -<span class="Identifier">FONTH</span>=<span class="Constant">14</span> <span class="Comment"># Size of one terminal row</span> -<span class="Identifier">FONTW</span>=<span class="Constant">8</span> <span class="Comment"># Size of one terminal column</span> -<span class="Identifier">COLUMNS</span>=<span class="Special">`tput cols`</span> -<span class="Identifier">LINES</span>=<span class="Special">`tput lines`</span> - -<span class="Statement">read</span> width height <span class="Statement">&lt;&lt;&lt;</span> <span class="Special">`</span><span class="Statement">echo</span><span class="String"> -e </span><span class="Statement">&quot;</span><span class="String">5;</span><span class="PreProc">$FILENAME</span><span class="Statement">&quot;</span><span class="String"> </span><span class="Special">| </span><span class="PreProc">$W3MIMGDISPLAY</span><span class="Special">`</span> - -<span class="Identifier">max_width</span>=<span class="PreProc">$((</span><span class="PreProc">$FONTW</span><span class="Special"> * </span><span class="PreProc">$COLUMNS</span><span class="PreProc">))</span> -<span class="Identifier">max_height</span>=<span class="PreProc">$((</span><span class="PreProc">$FONTH</span><span class="Special"> * </span><span class="PreProc">$((</span><span class="PreProc">$LINES</span><span class="Special"> - </span><span class="Constant">2</span><span class="PreProc">))))</span> <span class="Comment"># substract one line for prompt</span> - -<span class="Statement">if </span><span class="Statement">test</span> <span class="PreProc">$width</span> <span class="Statement">-gt</span> <span class="PreProc">$max_width</span>; <span class="Statement">then</span> - <span class="Identifier">height</span>=<span class="PreProc">$((</span><span class="PreProc">$height</span><span class="Special"> * </span><span class="PreProc">$max_width</span><span class="Special"> / </span><span class="PreProc">$width</span><span class="PreProc">))</span> - <span class="Identifier">width</span>=<span class="PreProc">$max_width</span> -<span class="Statement">fi</span> -<span class="Statement">if </span><span class="Statement">test</span> <span class="PreProc">$height</span> <span class="Statement">-gt</span> <span class="PreProc">$max_height</span>; <span class="Statement">then</span> - <span class="Identifier">width</span>=<span class="PreProc">$((</span><span class="PreProc">$width</span><span class="Special"> * </span><span class="PreProc">$max_height</span><span class="Special"> / </span><span class="PreProc">$height</span><span class="PreProc">))</span> - <span class="Identifier">height</span>=<span class="PreProc">$max_height</span> -<span class="Statement">fi</span> - -<span class="Identifier">w3m_command</span>=<span class="Statement">&quot;</span><span class="String">0;1;0;0;</span><span class="PreProc">$width</span><span class="String">;</span><span class="PreProc">$height</span><span class="String">;;;;;</span><span class="PreProc">$FILENAME</span><span class="Special">\n</span><span class="String">4;</span><span class="Special">\n</span><span class="String">3;</span><span class="Statement">&quot;</span> - -tput cup <span class="PreProc">$((</span><span class="PreProc">$height</span><span class="Special">/</span><span class="PreProc">$FONTH</span><span class="PreProc">))</span> <span class="Constant">0</span> -<span class="Statement">echo</span><span class="String"> -e </span><span class="PreProc">$w3m_command</span>|<span class="PreProc">$W3MIMGDISPLAY</span></code></pre> - - <p> - Let's see the rendering...<br /> - <a class='a_img' href='/img/w3mimgdisplay-good.jpg'> - <img class='a_img' src='/img/thumb/w3mimgdisplay-good.jpg' - alt='Fucked up w3mimgdisplay trial'/> - </a> - <span class='caption'> - The script draws the image depending on the terminal size (width - AND height), and put the cursor after the image (exactly 2 lines - after).<br /> - You might want to adapt it to your own case, as the character - height and width is hardcoded. - </span><br /> - <br /> - Aaaaaaaaand it's cool ! - </p> - - <h3>the end</h3> - <p> - There you are. You have a tool to preview images in your terminal, - in an easy way. The dependency is not huge, and you can script it - the way you want.<br /> - </p> - - <p> - I hope you learnt a few things here, like tips to grok softwares, - understand libs/protocols, or at least, the w3mimg protocol.<br /> - My script is not perfect, because I have no idea how one can get the - current cursor line and such. so if you have any improvement or - idea, I'll be glad to modify my script and add your name :) - </p> - - <p> - <em>Side note:</em> w3m can't render images in urxvt, if the depth - is 32. That means that you can't render images on a transparent - background. Be sure that you comment the line <code>URxvt*depth: - 32</code> in your <code>~/.Xresources</code>. - </p> - - <h3>That's all, folks!</h3> - </article> - </section> - </div> - <!-- footer {{{ --> - <footer> - <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->// - <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->// - <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->// - <a href='http://z3bra.org'>root</a> <!-- &#9774; -->// - <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; --> - </footer> - <!-- }}} --> - </body> -</html> -<!-- vim: set sw=2 et ai fdm=marker ft=html: --> diff --git a/2014/01/images-in-terminal.md b/2014/01/images-in-terminal.md @@ -1,188 +0,0 @@ -# [Images in terminal](#) -## &mdash; 28 January, 2014 - -I am a huge fan of the terminal. Really. 90% of the magic I realize on my -computer is through a terminal: IRC, text editing, ,e-mails, file managing, -package managing, developpement, even web browsing sometimes ! - -But the terminal lack one thing: **image rendering**. - -I have search a way to display images in the terminal for a looooong time now, -and after digging through fbi, fbterm, and obscure graphical drivers, I finally -found my goldmine.. I stumbled upon -[this picture](http://www.nongnu.org/ranger/screenshots/w3mimgpreview.png) -taken from [this website](http://www.nongnu.org/ranger/). Ranger. It's a -text-based file manager (that's cool bro'), but the interesting point sits in -the "dependencies" section: - -> &bull; w3m for previewing images in "true color". - -[w3m](http://w3m.sourceforge.net). That was my answer. - -### the package - -w3m is a text-based web browser. It means that you can use it to browse the web -from within your terminal (good stuff!). There are many like it (lynx, links, -elinks, edbrowse,..), but this one is different, as it acts more like a -point'n'click software than a CLI app. - -w3m uses gpm, a tool that let you use your terminal cursor like a mouse, moving -it character by character. Anyway, that's not the point here. Let's go back to -image viewing! w3m has the particularity to render images in your terminal, -and it is pretty good at it! The problem was to find out **HOW**. I browsed the -manpage many, many times, searching for keywords like <q>image</q>, -<q>preview</q>, <q>gimme my f\*\*cking image rendering, damn software!</q>. Every -usefull keyword I could find. **Nothing**. - -### the pursuit - -A few minutes (when all the buckets were fullfilled with my tears), I finally -tough: <q>Use the source, z3bra</q>. That's how I installed ranger. - -Ranger is written in python. And if it uses w3m to render images, I would find -the tool it uses to do so. Here is how I managed to find it: - - $ pacman -Ql ranger | grep -E 'image|img|w3m|picture|preview' - ranger /usr/lib/python3.3/site-packages/ranger/ext/__pycache__/img_display.cpython-33.pyc - ranger /usr/lib/python3.3/site-packages/ranger/ext/__pycache__/img_display.cpython-33.pyo - ranger /usr/lib/python3.3/site-packages/ranger/ext/img_display.py - - $ grep 'w3m' /usr/lib/python3.3/site-packages/ranger/ext/img_display.py - ... - W3MIMGDISPLAY_PATH = '/usr/lib/w3m/w3mimgdisplay' - ... - -**HOORAY!** A binary ! Next step will be to understand how to make it render -images in the terminal.. - -### the trials - -Obviously, running `w3mimgdisplay --help` would've been too easy.. But I -finally managed to understand a few things using the ranger source I just -found, and -[this thread](https://www.mail-archive.com/mutt-users@mutt.org/msg34447.html). -Here is the idea: w3mimgdisplay reads commands from stdin, and draws something -on your terminal, pixel by pixel. - -w3mimgdisplay commands are numbers from 0 to 6, and some commands take -additionnal parameters. -In the w3m tarball, you can find this: - - w3mimgdisplay.c - - /* - * w3mimg protocol - * 0 1 2 .... - * +--+--+--+--+ ...... +--+--+ - * |op|; |args |\n| - * +--+--+--+--+ .......+--+--+ - * - * args is separeted by ';' - * op args - * 0; params draw image - * 1; params redraw image - * 2; -none- terminate drawing - * 3; -none- sync drawing - * 4; -none- nop, sync communication - * response '\n' - * 5; path get size of image, - * response "<width> <height>\n" - * 6; params(6) clear image - * - * params - * <n>;<x>;<y>;<w>;<h>;<sx>;<sy>;<sw>;<sh>;<path> - * params(6) - * <x>;<y>;<w>;<h> - * - */ - -Here is the _params_ interpreted on the mutt mail list: - - > n - This is used when displaying multiple images - > x - x coordinate to draw the image at (top left corner) - > y - y coordinate to draw the image at (top left corner) - > w - width to draw the image - > h - height to draw the image - > sx - x offset to draw the image - > xy - y offset to draw the image - > sw - width of the original (source) image - > sh - height of the original (source) image - -I now have a better idea on how the protocol works. Now, by crossing it with -the ranger source, I ended up with this line: - - echo -e '0;1;0;0;200;160;;;;;ant.jpg\n4;\n3;' | /usr/lib/w3m/w3mimgdisplay - -**BOOM !** [It works!](http://chezmoicamarche.com) -[![Fucked up w3mimgdisplay trial](/img/thumb/w3mimgdisplay-crap.jpg)](/img/w3mimgdisplay-crap.jpg) - -The result of the previous command. Our picture drawn in 200x100px, at offset -+0+0 in the terminal. I'm sure you're already trying it ;) - -### the wrapping - -Okay, we can now display an image in the terminal, at the offset and size we -want. Let's wrap it up in a script, to be more adaptive! We will need some -tools to help us here. Feel free to search by yourself, as an exercise. Here is -the script I came with: - - #!/bin/bash - # - # z3bra -- 2014-01-21 - - test -z "$1" &amp;&amp; exit - - W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay" - FILENAME=$1 - FONTH=14 # Size of one terminal row - FONTW=8 # Size of one terminal column - COLUMNS=`tput cols` - LINES=`tput lines` - - read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY` - - max_width=$(($FONTW * $COLUMNS)) - max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt - - if test $width -gt $max_width; then - height=$(($height * $max_width / $width)) - width=$max_width - fi - if test $height -gt $max_height; then - width=$(($width * $max_height / $height)) - height=$max_height - fi - - w3m_command="0;1;0;0;$width;$height;;;;;$FILENAME\n4;\n3;" - - tput cup $(($height/$FONTH)) 0 - echo -e $w3m_command|$W3MIMGDISPLAY - -Let's see the rendering... -[![Fucked up w3mimgdisplay trial](/img/thumb/w3mimgdisplay-good.jpg)](/img/w3mimgdisplay-good.jpg) - -The script draws the image depending on the terminal size (width AND height), -and put the cursor after the image (exactly 2 lines after). -You might want to adapt it to your own case, as the character height and width -is hardcoded. - -Aaaaaaaaand it's cool ! - -### the end - -There you are. You have a tool to preview images in your terminal, in an easy -way. The dependency is not huge, and you can script it the way you want. - -I hope you learnt a few things here, like tips to grok softwares, understand -libs/protocols, or at least, the w3mimg protocol. My script is not perfect, -because I have no idea how one can get the current cursor line and such. so if -you have any improvement or idea, I'll be glad to modify my script and add your -name :) - -_Side note:_ w3m can't render images in urxvt, if the depth is 32. That means -that you can't render images on a transparent background. Be sure that you -comment the line `URxvt*depth: 32` in your `~/.Xresources`. - -### That's all, folks! - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2014/01/images-in-terminal.txt b/2014/01/images-in-terminal.txt @@ -0,0 +1,188 @@ +# [Images in terminal](#) +## &mdash; 28 January, 2014 + +I am a huge fan of the terminal. Really. 90% of the magic I realize on my +computer is through a terminal: IRC, text editing, ,e-mails, file managing, +package managing, developpement, even web browsing sometimes ! + +But the terminal lack one thing: **image rendering**. + +I have search a way to display images in the terminal for a looooong time now, +and after digging through fbi, fbterm, and obscure graphical drivers, I finally +found my goldmine.. I stumbled upon +[this picture](http://www.nongnu.org/ranger/screenshots/w3mimgpreview.png) +taken from [this website](http://www.nongnu.org/ranger/). Ranger. It's a +text-based file manager (that's cool bro'), but the interesting point sits in +the "dependencies" section: + +> &bull; w3m for previewing images in "true color". + +[w3m](http://w3m.sourceforge.net). That was my answer. + +### the package + +w3m is a text-based web browser. It means that you can use it to browse the web +from within your terminal (good stuff!). There are many like it (lynx, links, +elinks, edbrowse,..), but this one is different, as it acts more like a +point'n'click software than a CLI app. + +w3m uses gpm, a tool that let you use your terminal cursor like a mouse, moving +it character by character. Anyway, that's not the point here. Let's go back to +image viewing! w3m has the particularity to render images in your terminal, +and it is pretty good at it! The problem was to find out **HOW**. I browsed the +manpage many, many times, searching for keywords like <q>image</q>, +<q>preview</q>, <q>gimme my f\*\*cking image rendering, damn software!</q>. Every +usefull keyword I could find. **Nothing**. + +### the pursuit + +A few minutes (when all the buckets were fullfilled with my tears), I finally +tough: <q>Use the source, z3bra</q>. That's how I installed ranger. + +Ranger is written in python. And if it uses w3m to render images, I would find +the tool it uses to do so. Here is how I managed to find it: + + $ pacman -Ql ranger | grep -E 'image|img|w3m|picture|preview' + ranger /usr/lib/python3.3/site-packages/ranger/ext/__pycache__/img_display.cpython-33.pyc + ranger /usr/lib/python3.3/site-packages/ranger/ext/__pycache__/img_display.cpython-33.pyo + ranger /usr/lib/python3.3/site-packages/ranger/ext/img_display.py + + $ grep 'w3m' /usr/lib/python3.3/site-packages/ranger/ext/img_display.py + ... + W3MIMGDISPLAY_PATH = '/usr/lib/w3m/w3mimgdisplay' + ... + +**HOORAY!** A binary ! Next step will be to understand how to make it render +images in the terminal.. + +### the trials + +Obviously, running `w3mimgdisplay --help` would've been too easy.. But I +finally managed to understand a few things using the ranger source I just +found, and +[this thread](https://www.mail-archive.com/mutt-users@mutt.org/msg34447.html). +Here is the idea: w3mimgdisplay reads commands from stdin, and draws something +on your terminal, pixel by pixel. + +w3mimgdisplay commands are numbers from 0 to 6, and some commands take +additionnal parameters. +In the w3m tarball, you can find this: + + w3mimgdisplay.c + + /* + * w3mimg protocol + * 0 1 2 .... + * +--+--+--+--+ ...... +--+--+ + * |op|; |args |\n| + * +--+--+--+--+ .......+--+--+ + * + * args is separeted by ';' + * op args + * 0; params draw image + * 1; params redraw image + * 2; -none- terminate drawing + * 3; -none- sync drawing + * 4; -none- nop, sync communication + * response '\n' + * 5; path get size of image, + * response "<width> <height>\n" + * 6; params(6) clear image + * + * params + * <n>;<x>;<y>;<w>;<h>;<sx>;<sy>;<sw>;<sh>;<path> + * params(6) + * <x>;<y>;<w>;<h> + * + */ + +Here is the _params_ interpreted on the mutt mail list: + + > n - This is used when displaying multiple images + > x - x coordinate to draw the image at (top left corner) + > y - y coordinate to draw the image at (top left corner) + > w - width to draw the image + > h - height to draw the image + > sx - x offset to draw the image + > xy - y offset to draw the image + > sw - width of the original (source) image + > sh - height of the original (source) image + +I now have a better idea on how the protocol works. Now, by crossing it with +the ranger source, I ended up with this line: + + echo -e '0;1;0;0;200;160;;;;;ant.jpg\n4;\n3;' | /usr/lib/w3m/w3mimgdisplay + +**BOOM !** [It works!](http://chezmoicamarche.com) +[![Fucked up w3mimgdisplay trial](/img/thumb/w3mimgdisplay-crap.jpg)](/img/w3mimgdisplay-crap.jpg) + +The result of the previous command. Our picture drawn in 200x100px, at offset ++0+0 in the terminal. I'm sure you're already trying it ;) + +### the wrapping + +Okay, we can now display an image in the terminal, at the offset and size we +want. Let's wrap it up in a script, to be more adaptive! We will need some +tools to help us here. Feel free to search by yourself, as an exercise. Here is +the script I came with: + + #!/bin/bash + # + # z3bra -- 2014-01-21 + + test -z "$1" &amp;&amp; exit + + W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay" + FILENAME=$1 + FONTH=14 # Size of one terminal row + FONTW=8 # Size of one terminal column + COLUMNS=`tput cols` + LINES=`tput lines` + + read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY` + + max_width=$(($FONTW * $COLUMNS)) + max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt + + if test $width -gt $max_width; then + height=$(($height * $max_width / $width)) + width=$max_width + fi + if test $height -gt $max_height; then + width=$(($width * $max_height / $height)) + height=$max_height + fi + + w3m_command="0;1;0;0;$width;$height;;;;;$FILENAME\n4;\n3;" + + tput cup $(($height/$FONTH)) 0 + echo -e $w3m_command|$W3MIMGDISPLAY + +Let's see the rendering... +[![Fucked up w3mimgdisplay trial](/img/thumb/w3mimgdisplay-good.jpg)](/img/w3mimgdisplay-good.jpg) + +The script draws the image depending on the terminal size (width AND height), +and put the cursor after the image (exactly 2 lines after). +You might want to adapt it to your own case, as the character height and width +is hardcoded. + +Aaaaaaaaand it's cool ! + +### the end + +There you are. You have a tool to preview images in your terminal, in an easy +way. The dependency is not huge, and you can script it the way you want. + +I hope you learnt a few things here, like tips to grok softwares, understand +libs/protocols, or at least, the w3mimg protocol. My script is not perfect, +because I have no idea how one can get the current cursor line and such. so if +you have any improvement or idea, I'll be glad to modify my script and add your +name :) + +_Side note:_ w3m can't render images in urxvt, if the depth is 32. That means +that you can't render images on a transparent background. Be sure that you +comment the line `URxvt*depth: 32` in your `~/.Xresources`. + +### That's all, folks! + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2014/03/toolbox.html b/2014/03/toolbox.html @@ -1,530 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset='utf-8'/> - <link rel='stylesheet' href='/css/monochrome.css'/> - <link rel='stylesheet' href='/css/code.css'/> - <link rel='stylesheet' href='/css/phone.css' media='screen and (max-width: 540px)'/> - <title>z3bra.org - monochromatic blog</title> - </head> - <body> - <header> - <h1><a href='/'>Monochromatic</a></h1> <h2>&mdash; <a href='/about.html'>z3bra</a>, the stripes apart</h2> - </header> - <div id='wrapper'> - <section> - <h1> - <a href='#'>Toolbox</a> - </h1> - <h2> - &mdash; 12 March, 2014 - </h2> - <article> - <p> - Please, allow me to start this one with a smart quote, to let you - know what will follow: - </p> - <blockquote> - <p> - Show me what's the output of your '<code>ls /usr/bin</code>', and - I'll tell you who you are ... - </p> - &mdash; Nobody (because that's freakin' stupid) - </blockquote> - <p> - That being said, we can move on. I'll keep this article updated in - time, because it's <em>more</em> than an article. It's a list. A - list of the tools I use (or have used maybe) daily, and that I think - are worth mentioning. You'll find tools written by me, or by other. - Shell scripts, or compiled program. Everything that I find 'nice'. - </p> - - <p> - Those tools are (most of the time) not important or complex enough - to get a dedicated post, so I'll just write a paragraph here about - them. If you feel that one of them require a bigger description, - email me and I'll consider writing an article about it. - </p> - - <p> - Let's start with my current setup ! Every tool in this list is - installed on my main computer (a desktop one). I'll avoid - mentioning server administration tools, because that's too - specific. - </p> - </article> - - <h3>Computer</h3> - <article> - <ul> - <li>CRUX 3.0</li> - <li>AMD A10-5800k</li> - <li>Nvidia GeForce GTx 650 Ti</li> - <li>Roccat Kone Pure</li> - <li>Razer Vespuala</li> - </ul> - </article> - - <h3>Tool list</h3> - <article> - <ul> - <li><a href="#2bwm">2bwm</a></li> - <li><a href="#9menu">9menu</a></li> - <li><a href="#bar">bar</a></li> - <li><a href="#dtach">dtach</a></li> - <li><a href="#fcount">fcount</a></li> - <li><a href="#hsetroot">hsetroot</a></li> - <li><a href="#ii">ii</a></li> - <li><a href="#instagram">instagram</a></li> - <li><a href="#meh">meh</a></li> - <li><a href="#popup">popup</a></li> - <li><a href="#prout">prout</a></li> - <li><a href="#ptii">ptii</a></li> - <li><a href="#skroll">skroll</a></li> - <li><a href="#thingmenu">thingmenu</a></li> - <li><a href="#wendy">wendy</a></li> - </ul> - - </article> - - <h3 id="2bwm">2bwm</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/2bwm">LINK</a> &mdash; - <a href="/img/2014-01-08-2bwm.jpg">SHOT</a> - </p> - <p> - It means <q>Two borders window manager</q>. This is my WM of choice. - It is a fork of <a href="http://hack.org/mc/hacks/mcwm/">mcwm</a>, - but the author, Venam, added so many feature that it became a new - tool. - </p> - - <p> - 2bwm is a floating WM. It means that your computer will never change - the window geometry if you don't ask him (but tilling WM will). - </p> - - <p> - With 2bwm, you can resize window horiz/vertically, or grow them - keeping aspect ratio. You can move them in any direction, or gut - them in the corners or in the middle, all that, just with your - keyboard ! - </p> - - <p> - I personnally forked it myself to add a specific feature: window - groups. It works kinda like traditionnal workspaces, except that you - can show or hide them independently, allowing you to show multiple - workspaces at the same time. See a showcase - <a href="http://raw.z3bra.org/vid/2bwm.webm">here</a>. - </p> - </article> - - <h3 id="9menu">9menu</h3> - <article> - <p> - <a href="ftp://freefriends.org/arnold/Source/">LINK</a> &mdash; - <a href="/img/2014-03-17-menus.jpg">SHOT</a> - </p> - - <p> - Here is a simple, yet powerfull menu application. 9menu allows you - to create static menus to launch your favorite applications. Users - of the *box WM, or FVWM will relate to this. - </p> - - <p> - The advantages of 9menu over other applications like - <a href='#thingmenu'>thingmenu</a> is that you can leave it running - in the background, iconify it, bring it back, and teleport it. - </p> - - <p> - Another good advantage (but you can totally live without it), is the - ability of 9menu to act as an interpreter, so that you can write - your menu using the shebang: <code>#!/usr/bin/9menu</code> - </p> - </article> - - - <h3 id="bar">bar</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/bar">LINK</a> &mdash; - <a href="/img/2014-03-13-bar.jpg">SHOT</a> - </p> - - <p> - Bar (or (b)ar (a)in't (r)ecursive) is a lightweight status bar - application written on top of XCB. You can pipe text to it, and it - will be displayed within the bar. You can also use escape sequences - to add colored backgrounds, foregrounds or underlining. - </p> - - <p> - It allow the use of <a href="http://git.z3bra.org/cgit.cgi/scripts/tree/bar/status.sh">complicated</a> - scripts to get a tons of infos within that thin, lovely bar. - </p> - - <p> - I forked it to add a little feature: change the width of the bar on - startup, allowing to use bar as a notification <a href="#popup">popup</a> - </p> - </article> - - <h3 id="dtach">dtach</h3> - <article> - <p> - <a href="http://dtach.sourceforge.net/">LINK</a> &mdash; - <a href="/img/2014-03-13-dtach.jpg">SHOT</a> - </p> - - <p> - I often see newbies asking this question: - </p> - <blockquote> - <p> - newbie &mdash; How can I move one application from one terminal to another ? - </p> - <p> - stranger1 &mdash; you need screen.<br/> - stranger2 &mdash; tmux is better !<br/> - stranger1 &mdash; How so ?<br/> - stranger3 &mdash; It has vertical splits !<br/> - stranger2 &mdash; It's scriptable<br/> - newbie &mdash; how does it works ?<br/> - stranger1 &mdash; There is a vsplit patch fro screen<br/> - stranger3 &mdash; Yes but ...<br/> - str... - </p> - </blockquote> - - <p> - The problem here, is that screen AND tmux are terminal MULTIPLEXER. - Their main job is to give access to multiple terminals within a - PHYSICAL terminal. The possibility to detach and reattach them is - just a feature. - </p> - <p> - But that feature was so good, that a small team wrote a tool with - ONLY the ability to detach an application, and reattach it somewhere - else. Here came dtach. - </p> - <p> - The advantages of dtach are its small size, (not only the code, - because it only depends on glibc), and that you don't have to - remember a million commands. There is one only bind: <code>^\</code> - to detach the process. You can also disable this key and use signals - to detach it from elsewhere. - </p> - <p> - I personnaly use it to reattach to my irssi session, as it's the - only application I need on a remote server. You will also be able to - send an application from one screen/tmux session to another. Isn't - that cool ? - </p> - </article> - - <h3 id="fcount">fcount</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/fcount">LINK</a> - </p> - - <p> - That is a tool I made. It is REALLY DUMB, but totally usefull in a - particular case.<br/> - </p> - <p> - fcount counts the number of files within a directory. NOTHING. - F**KING. MORE.<br/> - It's basically a "<code>ls -rAa1 | wc -l</code>" within one process. - </p> - <p> - I agree that you can find stupid to use a program like that, but - within a script that will be executed every second to display the - number of unread mails in a status bar, it is usefull to gain some - miliseconds.<br/> Take it or not, this is your choice. - </p> - </article> - - <h3 id="hsetroot">hsetroot</h3> - <article> - <p> - <a href="http://thegraveyard.org/hsetroot.php">LINK</a> (dead) - </p> - - <p> - I like this one. This is a tool to display images on the root window - (humans: understand "change wallpaper"). You can fit/expand/tile - images, create gradients, add tint to images... Everything you could - want to do with a wallpaper can be done with it. And it's light as - I like ! Forget that crappy feh ! You can barely get rid of the - .fehbg that pisses you off ! - </p> - </article> - - - <h3 id="ii">ii</h3> - <article> - <p> - <a href="http://tools.suckless.org/ii/">LINK</a> - </p> - - <p> - Okay, I don't use it <em>that</em> often.<br/> - II stands for Irc It, and is a filesystem based irc client. - Upon starting, ii will create a file hierarchy looking like this: - </p> - <pre><code> -$ tree irc/irc.oftc.net/ -irc/ -├── irc.oftc.net -│ ├── int -│ ├── out -│ └── #shblah -│ ├── int -│ └── out -└── irc.iotek.org - ├── in - ├── nickserv - │ ├── in - │ └── out - ├── out - └── #wizards - ├── in - └── out</code></pre> - - <p> - The first folder is the server, and the subfolders are the channels - which you are connected to. The 'in' and 'out' files are named pipes - that you can read from and write to to interact with - servers/channels.<br/> - Example: - </p> - - <pre><code> echo "Hi, people of shblah!" &gt; irc/irc.oftc.net/\#shblah/in</code></pre> - - <p> - Will effectively send a message to the channel "#shblah" on server - "irc.oftc.net". - </p> - - <p> - I agree that this is not the most practical client you've used, but - it's a simple and good unix tool. I use it within a tiny script - along with a tool of mine (<a href="#ptii">ptii</a>) to get a quick - access to the IRC without having to fire up irssi with 4 server - connection, 10 channel autojoins, and such.. - </p> - </article> - - <h3 id="instagram">instagram</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/scripts/tree/instagram">LINK</a> - </p> - - <p> - My swiss-knife for screen shots. At first, I wrote it to be able to - take a shot of only one of my two screens. It's now a script with a - lot of features, like uploading, thumbnail creation, and such. - </p> - <p> - It will also open a preview of the shot you just took, and put it in - a predifined folder. You can write your own 'upload' function to - upload the way you want - </p> - </article> - - <h3 id="meh">meh</h3> - <article> - <p> - <a href="http://www.johnhawthorn.com/meh/">LINK</a> - </p> - - <p> - I've spit on feh before (see <a href="#hsetroot">hsetroot</a>. I - have effectively some problems with it. Feh is impossible to use. it - displays the images in full size, no matter what the window size - is. And that's freaking annoying... I just want my image viewer to - display an image at the maximum size for the window, and to resize - when I change the window size. - </p> - - <p> - That is what meh does. And (almost) nothing more ! Meh take a list - of images as arguments, and fits them in its window. Meh can also - read a list from stdin. You can then cycle through images using - h,j,k,l,left,down,up,right. - </p> - - <p> - When you press &lt;enter&gt;, meh outputs the current image name to - stdout. It allows cool stuffs like <code>meh *.jpg | xargs rm</code> - to delete the images upon pressing &lt;enter&gt;. - </p> - </article> - - <h3 id="popup">popup</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/scripts/tree/popup">LINK</a> - </p> - - <p> - This is just a simple script that uses my fork of - <a href="#bar">bar</a> to display a small notification bar at the - top left hand corner of your desktop. - </p> - </article> - - - <h3 id="prout">prout</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/prout">LINK</a> - </p> - <p> - Did you notice? If you want to send a document to the printer - configured to /etc/client.conf using the <code>lp</code> command, - you need (at least, on Archlinux) to install the full cups server! - That's a shame, isn't it? - </p> - - <p> - That's the reason why I wrote prout. The only dependency is libcups. - This tool only sends a file given as argument to the default - printer. Nothing else. You can't actually send options along with - the document, but I'm not sure that I want to implement this - feature... - </p> - - <p> - Anyway, this is pretty neat to me! I hope you'll enjoy it. - </p> - </article> - - <h3 id="ptii">ptii</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/ptii">LINK</a> &mdash; - <a href="/img/2014-03-13-ptii.jpg">SHOT</a> - </p> - - <p> - Here is an <a href="#ii">ii</a> helper. Just fire it up in the ii's - directory, and you will be able to talk on multiple channels easily. - Using simple commands like <code>/cn</code>, <code>/cp</code>, - <code>/cl</code>, you will be able to list and switch between - channels. - </p> - - <p> - The interresting point of this tool is that it uses inotify to - automatically add channels to your list when ii create the folders. - </p> - </article> - - <h3 id="skroll">skroll</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/skroll">LINK</a> &mdash; - <a href="/img/2014-03-28-skroll.gif">SHOT</a> - </p> - - <p> - Here is something I wrote for fun. I don't actually need it, but - other might find it useful. Skroll takes its input from stdin, and - then makes it scroll on stdout. You can specify the scroll speed, as - well as the number of characters to be displayed. - </p> - - <p> - The best application to this I can find so far, is for some kind of - notification system. If you want to display the current playing - song in a tiny box in the upper left had-corner, you soon notice - that you <em>can't</em> adapt the notification box to the size of - the input text, because that's just too ugly. And here comes skroll - ! Just pipe your text to it with the <code>-r</code> flag (so that - there is a new line after each scroll-step), and pipe that output to - dzen2 or bar or whatever. <strong>BAM</strong> that's black magic ! - </p> - </article> - - - <h3 id="thingmenu">thingmenu</h3> - <article> - <p> - <a href="http://git.r-36.net/thingmenu/">LINK</a> &mdash; - <a href="/img/2014-03-17-menus.jpg">SHOT</a> - </p> - - <p> - Thingmenu is one of those app you've never heard of, but you use - (or have used) daily, because it was part of a WM. - </p> - - <p> - It is a simple tool that help you associate some strings with - commands, and stack them up in a menu. It comes with a nice script - that is able to deal with submenus and "back" buttons, that you can - easily improve to fit your own needs. - </p> - - <p> - Also, feel free to browse the whole git repo, it's full of good - stuff ! - </p> - </article> - - <h3 id="wendy">wendy</h3> - <article> - <p> - <a href="http://git.z3bra.org/cgit.cgi/wendy">LINK</a> &mdash; - <a href="/img/2014-03-13-wendy.jpg">SHOT</a> - </p> - - <p> - Wendy makes my life better. I first wrote it as an exercise to learn - inotify, but it turned out to be a good replacement to inotifywait. - </p> - - <p> - Wendy let you watch a directory/file and execute a command when a - watched event is received. <br/> - As an example is worth a thousand explications, there you go: - </p> - - <pre><code> -# watch mail directory for new mails and raise an alert -wendy -C ~/var/mail/INBOX/new -t 60 -e beep - -# automatic recompilation -wendy -M wendy.c -e make</code></pre> - <p> - Every inotify mask can be used, and they can be combined (eg, whatch - creation AND modification). - </p> - - <p> - I tried to make this tool the most simple possible, to extend the - possibilities. Be creative! - </p> - </article> - - </section> - </div> - <!-- footer {{{ --> - <footer> - <a href='http://www.acme.com/software/thttpd/'>thttpd</a> <!-- &hearts; -->// - <a href='http://www.wtfpl.net/about/'>wtfpl</a> <!-- &copy; -->// - <a href='mailto:willy@mailoo.org'>mail</a> <!-- &#9993; -->// - <a href='http://z3bra.org'>root</a> <!-- &#9774; -->// - <a href='http://blog.z3bra.org/rss/feed.xml'>rss</a> <!-- &#9733; --> - </footer> - <!-- }}} --> - </body> -</html> -<!-- vim: set sw=2 et ai fdm=marker ft=html: --> diff --git a/2014/03/toolbox.md b/2014/03/toolbox.md @@ -1,328 +0,0 @@ -# [Toolbox](#) -## &mdash; 12 March, 2014 - -Please, allow me to start this one with a smart quote, to let you -know what will follow: - -> Show me what's the output of your '`ls /usr/bin`', and I'll tell you who you -> are ... -> &mdash; <cite>Nobody (because that's freakin' stupid)</cite> - -That being said, we can move on. I'll keep this article updated in time, -because it's _more_ than an article. It's a list. A list of the tools I use (or -have used maybe) daily, and that I think are worth mentioning. You'll find -tools written by me, or by other. Shell scripts, or compiled program. -Everything that I find 'nice'. - -Those tools are (most of the time) not important or complex enough to get a -dedicated post, so I'll just write a paragraph here about them. If you feel -that one of them require a bigger description, email me and I'll consider -writing an article about it. - -Let's start with my current setup ! Every tool in this list is installed on my -main computer (a desktop one). I'll avoid mentioning server administration -tools, because that's too specific. - -### Computer - -* CRUX 3.0 -* AMD A10-5800k -* Nvidia GeForce GTx 650 Ti -* Roccat Kone Pure -* Razer Vespuala - -### Tool list - -* [2bwm](#2bwm) -* [9menu](#9menu) -* [bar](#bar) -* [dtach](#dtach) -* [fcount](#fcount) -* [hsetroot](#hsetroot) -* [ii](#ii) -* [instagram](#instagram) -* [meh](#meh) -* [popup](#popup) -* [prout](#prout) -* [ptii](#ptii) -* [skroll](#skroll) -* [thingmenu](#thingmenu) -* [wendy](#wendy) - -### 2bwm - -[LINK](http://git.z3bra.org/cgit.cgi/2bwm) &mdash; -[SHOT](/img/2014-01-08-2bwm.jpg) - -It means <q>Two borders window manager</q>. This is my WM of choice. It is a -fork of [mcwm](http://hack.org/mc/hacks/mcwm/), but the author, Venam, added so -many feature that it became a new tool. - -2bwm is a floating WM. It means that your computer will never change the window -geometry if you don't ask him (but tilling WM will). - -With 2bwm, you can resize window horiz/vertically, or grow them keeping aspect -ratio. You can move them in any direction, or gut them in the corners or in the -middle, all that, just with your keyboard ! - -I personnally forked it myself to add a specific feature: window groups. It -works kinda like traditionnal workspaces, except that you can show or hide them -independently, allowing you to show multiple workspaces at the same time. See a -showcase [here](http://raw.z3bra.org/vid/2bwm.webm). - -### 9menu - -[LINK](ftp://freefriends.org/arnold/Source/) &mdash; -[SHOT](/img/2014-03-17-menus.jpg) - -Here is a simple, yet powerfull menu application. 9menu allows you to create -static menus to launch your favorite applications. Users of the \*box WM, or -FVWM will relate to this. - -The advantages of 9menu over other applications like [thingmenu](#thingmenu) is -that you can leave it running in the background, iconify it, bring it back, and -teleport it. - -Another good advantage (but you can totally live without it), is the ability of -9menu to act as an interpreter, so that you can write your menu using the -shebang: `#!/usr/bin/9menu` - -### bar - -[LINK](http://git.z3bra.org/cgit.cgi/bar) &mdash; -[SHOT](/img/2014-03-13-bar.jpg) - -Bar (or (b)ar (a)in't (r)ecursive) is a lightweight status bar application -written on top of XCB. You can pipe text to it, and it will be displayed within -the bar. You can also use escape sequences to add colored backgrounds, -foregrounds or underlining. - -It allow the use of -[complicated](http://git.z3bra.org/cgit.cgi/scripts/tree/bar/status.sh) scripts -to get a tons of infos within that thin, lovely bar. - -I forked it to add a little feature: change the width of the bar on startup, -allowing to use bar as a notification [popup](#popup) - -### dtach - -[LINK](http://dtach.sourceforge.net/) &mdash; -[SHOT](/img/2014-03-13-dtach.jpg) - -I often see newbies asking this question: - -> newbie &mdash; How can I move one application from one terminal to another ? -> stranger1 &mdash; you need screen. -> stranger2 &mdash; tmux is better ! -> stranger1 &mdash; How so ? -> stranger3 &mdash; It has vertical splits ! -> stranger2 &mdash; It's scriptable -> newbie &mdash; how does it works ? -> stranger1 &mdash; There is a vsplit patch fro screen -> stranger3 &mdash; Yes but ... -> str... - -The problem here, is that screen AND tmux are terminal MULTIPLEXER. Their main -job is to give access to multiple terminals within a PHYSICAL terminal. The -possibility to detach and reattach them is just a feature. - -But that feature was so good, that a small team wrote a tool with ONLY the -ability to detach an application, and reattach it somewhere else. Here came -dtach. - -The advantages of dtach are its small size, (not only the code, because it only -depends on glibc), and that you don't have to remember a million commands. -There is one only bind: `^\` to detach the process. You can also disable this -key and use signals to detach it from elsewhere. - -I personnaly use it to reattach to my irssi session, as it's the only -application I need on a remote server. You will also be able to send an -application from one screen/tmux session to another. Isn't that cool ? - -### fcount - -[LINK](http://git.z3bra.org/cgit.cgi/fcount) - -That is a tool I made. It is REALLY DUMB, but totally usefull in a particular -case. - -fcount counts the number of files within a directory. NOTHING. -F\*\*KING. MORE. -It's basically a "`ls -rAa1 | wc -l`" within one process. - -I agree that you can find stupid to use a program like that, but within a -script that will be executed every second to display the number of unread mails -in a status bar, it is usefull to gain some miliseconds. Take it or not, this -is your choice. - -### hsetroot - -[LINK](http://thegraveyard.org/hsetroot.php) (dead) - -I like this one. This is a tool to display images on the root window (humans: -understand "change wallpaper"). You can fit/expand/tile images, create -gradients, add tint to images... Everything you could want to do with a -wallpaper can be done with it. And it's light as I like ! Forget that crappy -feh ! You can barely get rid of the .fehbg that pisses you off ! - -### ii - -[LINK](http://tools.suckless.org/ii/) - -Okay, I don't use it _that_ often. -II stands for Irc It, and is a filesystem based irc client. Upon starting, ii -will create a file hierarchy looking like this: - - $ tree irc/irc.oftc.net/ - irc/ - ├── irc.oftc.net - │ ├── int - │ ├── out - │ └── #shblah - │ ├── int - │ └── out - └── irc.iotek.org - ├── in - ├── nickserv - │ ├── in - │ └── out - ├── out - └── #wizards - ├── in - └── out - -The first folder is the server, and the subfolders are the channels which you -are connected to. The 'in' and 'out' files are named pipes that you can read -from and write to to interact with servers/channels. -Example: - - echo "Hi, people of shblah!" > irc/irc.oftc.net/\#shblah/in - -Will effectively send a message to the channel "#shblah" on server -"irc.oftc.net". - -I agree that this is not the most practical client you've used, but it's a -simple and good unix tool. I use it within a tiny script along with a tool of -mine ([ptii](#ptii)) to get a quick access to the IRC without having to fire up -irssi with 4 server connection, 10 channel autojoins, and such.. - -### instagram - -[LINK](http://git.z3bra.org/cgit.cgi/scripts/tree/instagram) - -My swiss-knife for screen shots. At first, I wrote it to be able to take a shot -of only one of my two screens. It's now a script with a lot of features, like -uploading, thumbnail creation, and such. - -It will also open a preview of the shot you just took, and put it in a -predifined folder. You can write your own 'upload' function to upload the way -you want - -### meh - -[LINK](http://www.johnhawthorn.com/meh/) - -I've spit on feh before (see [hsetroot](#hsetroot). I have effectively some -problems with it. Feh is impossible to use. it displays the images in full -size, no matter what the window size is. And that's freaking annoying... I just -want my image viewer to display an image at the maximum size for the window, -and to resize when I change the window size. - -That is what meh does. And (almost) nothing more ! Meh take a list of images as -arguments, and fits them in its window. Meh can also read a list from stdin. -You can then cycle through images using h,j,k,l,left,down,up,right. - -When you press `<enter>`, meh outputs the current image name to stdout. It -allows cool stuffs like meh \*.jpg | xargs rm to delete the images upon -pressing `<enter>`. - -### popup - -[LINK](http://git.z3bra.org/cgit.cgi/scripts/tree/popup) - -This is just a simple script that uses my fork of [bar](#bar) to display a -small notification bar at the top left hand corner of your desktop. - -### prout - -[LINK](http://git.z3bra.org/cgit.cgi/prout) - -Did you notice? If you want to send a document to the printer configured to -/etc/client.conf using the lp command, you need (at least, on Archlinux) to -install the full cups server! That's a shame, isn't it? - -That's the reason why I wrote prout. The only dependency is libcups. This tool -only sends a file given as argument to the default printer. Nothing else. You -can't actually send options along with the document, but I'm not sure that I -want to implement this feature... - -Anyway, this is pretty neat to me! I hope you'll enjoy it. - -### ptii - -[LINK](http://git.z3bra.org/cgit.cgi/ptii) &mdash; -[SHOT](/img/2014-03-13-ptii.jpg) - -Here is an [ii](#ii) helper. Just fire it up in the ii's directory, and you -will be able to talk on multiple channels easily. Using simple commands like -/cn, /cp, /cl, you will be able to list and switch between channels. - -The interresting point of this tool is that it uses inotify to automatically -add channels to your list when ii create the folders. - -### skroll - -[LINK](http://git.z3bra.org/cgit.cgi/skroll) &mdash; -[SHOT](/img/2014-03-28-skroll.gif) - -Here is something I wrote for fun. I don't actually need it, but other might -find it useful. Skroll takes its input from stdin, and then makes it scroll on -stdout. You can specify the scroll speed, as well as the number of characters -to be displayed. - -The best application to this I can find so far, is for some kind of -notification system. If you want to display the current playing song in a tiny -box in the upper left had-corner, you soon notice that you _can't_ adapt the -notification box to the size of the input text, because that's just too ugly. -And here comes skroll ! Just pipe your text to it with the -r flag (so that -there is a new line after each scroll-step), and pipe that output to dzen2 or -bar or whatever. **BAM** that's black magic ! - -### thingmenu - -[LINK](http://git.r-36.net/thingmenu/) &mdash; -[SHOT](/img/2014-03-17-menus.jpg) - -Thingmenu is one of those app you've never heard of, but you use (or have used) -daily, because it was part of a WM. - -It is a simple tool that help you associate some strings with commands, and -stack them up in a menu. It comes with a nice script that is able to deal with -submenus and "back" buttons, that you can easily improve to fit your own needs. - -Also, feel free to browse the whole git repo, it's full of good stuff ! - -### wendy - -[LINK](http://git.z3bra.org/cgit.cgi/wendy) &mdash; -[SHOT](/img/2014-03-13-wendy.jpg) - -Wendy makes my life better. I first wrote it as an exercise to learn inotify, -but it turned out to be a good replacement to inotifywait. - -Wendy let you watch a directory/file and execute a command when a watched event -is received. As an example is worth a thousand explications, there you go: - - # watch mail directory for new mails and raise an alert - wendy -C ~/var/mail/INBOX/new -t 60 -e beep - - # automatic recompilation - wendy -M wendy.c -e make - -Every inotify mask can be used, and they can be combined (eg, whatch creation -AND modification). - -I tried to make this tool the most simple possible, to extend the -possibilities. Be creative! - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2014/03/toolbox.txt b/2014/03/toolbox.txt @@ -0,0 +1,328 @@ +# [Toolbox](#) +## &mdash; 12 March, 2014 + +Please, allow me to start this one with a smart quote, to let you +know what will follow: + +> Show me what's the output of your '`ls /usr/bin`', and I'll tell you who you +> are ... +> &mdash; <cite>Nobody (because that's freakin' stupid)</cite> + +That being said, we can move on. I'll keep this article updated in time, +because it's _more_ than an article. It's a list. A list of the tools I use (or +have used maybe) daily, and that I think are worth mentioning. You'll find +tools written by me, or by other. Shell scripts, or compiled program. +Everything that I find 'nice'. + +Those tools are (most of the time) not important or complex enough to get a +dedicated post, so I'll just write a paragraph here about them. If you feel +that one of them require a bigger description, email me and I'll consider +writing an article about it. + +Let's start with my current setup ! Every tool in this list is installed on my +main computer (a desktop one). I'll avoid mentioning server administration +tools, because that's too specific. + +### Computer + +* CRUX 3.0 +* AMD A10-5800k +* Nvidia GeForce GTx 650 Ti +* Roccat Kone Pure +* Razer Vespuala + +### Tool list + +* [2bwm](#2bwm) +* [9menu](#9menu) +* [bar](#bar) +* [dtach](#dtach) +* [fcount](#fcount) +* [hsetroot](#hsetroot) +* [ii](#ii) +* [instagram](#instagram) +* [meh](#meh) +* [popup](#popup) +* [prout](#prout) +* [ptii](#ptii) +* [skroll](#skroll) +* [thingmenu](#thingmenu) +* [wendy](#wendy) + +### 2bwm + +[LINK](http://git.z3bra.org/cgit.cgi/2bwm) &mdash; +[SHOT](/img/2014-01-08-2bwm.jpg) + +It means <q>Two borders window manager</q>. This is my WM of choice. It is a +fork of [mcwm](http://hack.org/mc/hacks/mcwm/), but the author, Venam, added so +many feature that it became a new tool. + +2bwm is a floating WM. It means that your computer will never change the window +geometry if you don't ask him (but tilling WM will). + +With 2bwm, you can resize window horiz/vertically, or grow them keeping aspect +ratio. You can move them in any direction, or gut them in the corners or in the +middle, all that, just with your keyboard ! + +I personnally forked it myself to add a specific feature: window groups. It +works kinda like traditionnal workspaces, except that you can show or hide them +independently, allowing you to show multiple workspaces at the same time. See a +showcase [here](http://raw.z3bra.org/vid/2bwm.webm). + +### 9menu + +[LINK](ftp://freefriends.org/arnold/Source/) &mdash; +[SHOT](/img/2014-03-17-menus.jpg) + +Here is a simple, yet powerfull menu application. 9menu allows you to create +static menus to launch your favorite applications. Users of the \*box WM, or +FVWM will relate to this. + +The advantages of 9menu over other applications like [thingmenu](#thingmenu) is +that you can leave it running in the background, iconify it, bring it back, and +teleport it. + +Another good advantage (but you can totally live without it), is the ability of +9menu to act as an interpreter, so that you can write your menu using the +shebang: `#!/usr/bin/9menu` + +### bar + +[LINK](http://git.z3bra.org/cgit.cgi/bar) &mdash; +[SHOT](/img/2014-03-13-bar.jpg) + +Bar (or (b)ar (a)in't (r)ecursive) is a lightweight status bar application +written on top of XCB. You can pipe text to it, and it will be displayed within +the bar. You can also use escape sequences to add colored backgrounds, +foregrounds or underlining. + +It allow the use of +[complicated](http://git.z3bra.org/cgit.cgi/scripts/tree/bar/status.sh) scripts +to get a tons of infos within that thin, lovely bar. + +I forked it to add a little feature: change the width of the bar on startup, +allowing to use bar as a notification [popup](#popup) + +### dtach + +[LINK](http://dtach.sourceforge.net/) &mdash; +[SHOT](/img/2014-03-13-dtach.jpg) + +I often see newbies asking this question: + +> newbie &mdash; How can I move one application from one terminal to another ? +> stranger1 &mdash; you need screen. +> stranger2 &mdash; tmux is better ! +> stranger1 &mdash; How so ? +> stranger3 &mdash; It has vertical splits ! +> stranger2 &mdash; It's scriptable +> newbie &mdash; how does it works ? +> stranger1 &mdash; There is a vsplit patch fro screen +> stranger3 &mdash; Yes but ... +> str... + +The problem here, is that screen AND tmux are terminal MULTIPLEXER. Their main +job is to give access to multiple terminals within a PHYSICAL terminal. The +possibility to detach and reattach them is just a feature. + +But that feature was so good, that a small team wrote a tool with ONLY the +ability to detach an application, and reattach it somewhere else. Here came +dtach. + +The advantages of dtach are its small size, (not only the code, because it only +depends on glibc), and that you don't have to remember a million commands. +There is one only bind: `^\` to detach the process. You can also disable this +key and use signals to detach it from elsewhere. + +I personnaly use it to reattach to my irssi session, as it's the only +application I need on a remote server. You will also be able to send an +application from one screen/tmux session to another. Isn't that cool ? + +### fcount + +[LINK](http://git.z3bra.org/cgit.cgi/fcount) + +That is a tool I made. It is REALLY DUMB, but totally usefull in a particular +case. + +fcount counts the number of files within a directory. NOTHING. +F\*\*KING. MORE. +It's basically a "`ls -rAa1 | wc -l`" within one process. + +I agree that you can find stupid to use a program like that, but within a +script that will be executed every second to display the number of unread mails +in a status bar, it is usefull to gain some miliseconds. Take it or not, this +is your choice. + +### hsetroot + +[LINK](http://thegraveyard.org/hsetroot.php) (dead) + +I like this one. This is a tool to display images on the root window (humans: +understand "change wallpaper"). You can fit/expand/tile images, create +gradients, add tint to images... Everything you could want to do with a +wallpaper can be done with it. And it's light as I like ! Forget that crappy +feh ! You can barely get rid of the .fehbg that pisses you off ! + +### ii + +[LINK](http://tools.suckless.org/ii/) + +Okay, I don't use it _that_ often. +II stands for Irc It, and is a filesystem based irc client. Upon starting, ii +will create a file hierarchy looking like this: + + $ tree irc/irc.oftc.net/ + irc/ + ├── irc.oftc.net + │ ├── int + │ ├── out + │ └── #shblah + │ ├── int + │ └── out + └── irc.iotek.org + ├── in + ├── nickserv + │ ├── in + │ └── out + ├── out + └── #wizards + ├── in + └── out + +The first folder is the server, and the subfolders are the channels which you +are connected to. The 'in' and 'out' files are named pipes that you can read +from and write to to interact with servers/channels. +Example: + + echo "Hi, people of shblah!" > irc/irc.oftc.net/\#shblah/in + +Will effectively send a message to the channel "#shblah" on server +"irc.oftc.net". + +I agree that this is not the most practical client you've used, but it's a +simple and good unix tool. I use it within a tiny script along with a tool of +mine ([ptii](#ptii)) to get a quick access to the IRC without having to fire up +irssi with 4 server connection, 10 channel autojoins, and such.. + +### instagram + +[LINK](http://git.z3bra.org/cgit.cgi/scripts/tree/instagram) + +My swiss-knife for screen shots. At first, I wrote it to be able to take a shot +of only one of my two screens. It's now a script with a lot of features, like +uploading, thumbnail creation, and such. + +It will also open a preview of the shot you just took, and put it in a +predifined folder. You can write your own 'upload' function to upload the way +you want + +### meh + +[LINK](http://www.johnhawthorn.com/meh/) + +I've spit on feh before (see [hsetroot](#hsetroot). I have effectively some +problems with it. Feh is impossible to use. it displays the images in full +size, no matter what the window size is. And that's freaking annoying... I just +want my image viewer to display an image at the maximum size for the window, +and to resize when I change the window size. + +That is what meh does. And (almost) nothing more ! Meh take a list of images as +arguments, and fits them in its window. Meh can also read a list from stdin. +You can then cycle through images using h,j,k,l,left,down,up,right. + +When you press `<enter>`, meh outputs the current image name to stdout. It +allows cool stuffs like meh \*.jpg | xargs rm to delete the images upon +pressing `<enter>`. + +### popup + +[LINK](http://git.z3bra.org/cgit.cgi/scripts/tree/popup) + +This is just a simple script that uses my fork of [bar](#bar) to display a +small notification bar at the top left hand corner of your desktop. + +### prout + +[LINK](http://git.z3bra.org/cgit.cgi/prout) + +Did you notice? If you want to send a document to the printer configured to +/etc/client.conf using the lp command, you need (at least, on Archlinux) to +install the full cups server! That's a shame, isn't it? + +That's the reason why I wrote prout. The only dependency is libcups. This tool +only sends a file given as argument to the default printer. Nothing else. You +can't actually send options along with the document, but I'm not sure that I +want to implement this feature... + +Anyway, this is pretty neat to me! I hope you'll enjoy it. + +### ptii + +[LINK](http://git.z3bra.org/cgit.cgi/ptii) &mdash; +[SHOT](/img/2014-03-13-ptii.jpg) + +Here is an [ii](#ii) helper. Just fire it up in the ii's directory, and you +will be able to talk on multiple channels easily. Using simple commands like +/cn, /cp, /cl, you will be able to list and switch between channels. + +The interresting point of this tool is that it uses inotify to automatically +add channels to your list when ii create the folders. + +### skroll + +[LINK](http://git.z3bra.org/cgit.cgi/skroll) &mdash; +[SHOT](/img/2014-03-28-skroll.gif) + +Here is something I wrote for fun. I don't actually need it, but other might +find it useful. Skroll takes its input from stdin, and then makes it scroll on +stdout. You can specify the scroll speed, as well as the number of characters +to be displayed. + +The best application to this I can find so far, is for some kind of +notification system. If you want to display the current playing song in a tiny +box in the upper left had-corner, you soon notice that you _can't_ adapt the +notification box to the size of the input text, because that's just too ugly. +And here comes skroll ! Just pipe your text to it with the -r flag (so that +there is a new line after each scroll-step), and pipe that output to dzen2 or +bar or whatever. **BAM** that's black magic ! + +### thingmenu + +[LINK](http://git.r-36.net/thingmenu/) &mdash; +[SHOT](/img/2014-03-17-menus.jpg) + +Thingmenu is one of those app you've never heard of, but you use (or have used) +daily, because it was part of a WM. + +It is a simple tool that help you associate some strings with commands, and +stack them up in a menu. It comes with a nice script that is able to deal with +submenus and "back" buttons, that you can easily improve to fit your own needs. + +Also, feel free to browse the whole git repo, it's full of good stuff ! + +### wendy + +[LINK](http://git.z3bra.org/cgit.cgi/wendy) &mdash; +[SHOT](/img/2014-03-13-wendy.jpg) + +Wendy makes my life better. I first wrote it as an exercise to learn inotify, +but it turned out to be a good replacement to inotifywait. + +Wendy let you watch a directory/file and execute a command when a watched event +is received. As an example is worth a thousand explications, there you go: + + # watch mail directory for new mails and raise an alert + wendy -C ~/var/mail/INBOX/new -t 60 -e beep + + # automatic recompilation + wendy -M wendy.c -e make + +Every inotify mask can be used, and they can be combined (eg, whatch creation +AND modification). + +I tried to make this tool the most simple possible, to extend the +possibilities. Be creative! + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2014/03/unleash-your-desktop.md b/2014/03/unleash-your-desktop.md @@ -1,22 +0,0 @@ - -# [Unleash your desktop](#) -## &mdash; 31 March, 2014 - -### Introduction - -Hi everybody ! This post is more or less the continuation of my previous one: -[Home, sweet home](/2013/10/home-sweet-home.html). We will take desktop -customisations a little further here, so I'll assume that you, the reader, know -the base of linux system administration. - -Here we go! - -### Summary - -* [head-up display](#hud) -* [fetching informations](#grab) -* [listen to events](#event) -* [notification / popup](#pop) -* [automating tasks](#auto) - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/2014/03/unleash-your-desktop.txt b/2014/03/unleash-your-desktop.txt @@ -0,0 +1,22 @@ + +# [Unleash your desktop](#) +## &mdash; 31 March, 2014 + +### Introduction + +Hi everybody ! This post is more or less the continuation of my previous one: +[Home, sweet home](/2013/10/home-sweet-home.html). We will take desktop +customisations a little further here, so I'll assume that you, the reader, know +the base of linux system administration. + +Here we go! + +### Summary + +* [head-up display](#hud) +* [fetching informations](#grab) +* [listen to events](#event) +* [notification / popup](#pop) +* [automating tasks](#auto) + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/about.md b/about.md @@ -1,37 +0,0 @@ -Hi everybody ! I am Willy Goiffon (aka 'z3bra'). -I am a french student in computer science, born in the early 90's. - -### Monochromatic - -This is my online blog. Here, I'll shows you what's behind the stripes (yes, a -white skin). I created this to have a corner on the web to share anything that -bother me, mostly about computing, and particularly about linux (or GNU/Linux -for that matters). - -### Behind monochromatic - -The technology behind this blog is very simple : - -* Home server &mdash; **archlinux** -* Web server &mdash; **thttpd** -* Content &mdash; **static html** -* Site generator &mdash; **/dev/null** - -So yes, it is written entirely by hand in pure HTML. Why ? Because I can. -Because I have the time. Because I like to do stuff from scratch. Because -it's.. cool ? - -### Want some more ? - -I am on a few other places online. You want me ? Here I am : - -* [gitorious.org](http://gitorious.org/~z3bra/) &mdash; a few project I own (no more updated) -* [irc.freenode.net](https://webchat.freenode.net/) &mdash; mostly on #vim-fr and #archlinux-fr -* [unixhub.net](http://forum.unixhub.net/) &mdash; Both on the forum and IRC -* <span class='strike'>[quakelive.com](http://quakelive.com)</span> &mdash; Come on ID, bring linux support back.. -* [reddit.com](http://reddit.com/u/z-brah/) &mdash; Well.. Does it count ? - -I wish you will enjoy browsing this blog as much as I like to write it. So, -ladies and gentlemen, have a nice day ! - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/about.txt b/about.txt @@ -0,0 +1,37 @@ +Hi everybody ! I am Willy Goiffon (aka 'z3bra'). +I am a french student in computer science, born in the early 90's. + +### Monochromatic + +This is my online blog. Here, I'll shows you what's behind the stripes (yes, a +white skin). I created this to have a corner on the web to share anything that +bother me, mostly about computing, and particularly about linux (or GNU/Linux +for that matters). + +### Behind monochromatic + +The technology behind this blog is very simple : + +* Home server &mdash; **archlinux** +* Web server &mdash; **thttpd** +* Content &mdash; **static html** +* Site generator &mdash; **/dev/null** + +So yes, it is written entirely by hand in pure HTML. Why ? Because I can. +Because I have the time. Because I like to do stuff from scratch. Because +it's.. cool ? + +### Want some more ? + +I am on a few other places online. You want me ? Here I am : + +* [gitorious.org](http://gitorious.org/~z3bra/) &mdash; a few project I own (no more updated) +* [irc.freenode.net](https://webchat.freenode.net/) &mdash; mostly on #vim-fr and #archlinux-fr +* [unixhub.net](http://forum.unixhub.net/) &mdash; Both on the forum and IRC +* <span class='strike'>[quakelive.com](http://quakelive.com)</span> &mdash; Come on ID, bring linux support back.. +* [reddit.com](http://reddit.com/u/z-brah/) &mdash; Well.. Does it count ? + +I wish you will enjoy browsing this blog as much as I like to write it. So, +ladies and gentlemen, have a nice day ! + +<!-- vim: set ft=markdown ts=4 et: --> diff --git a/index.md b/index.md @@ -1,50 +0,0 @@ -# [Toolbox](/2014/03/toolbox.html) -## &mdash; 12 March, 2014 -Yeah, yet another list of unix tools. Feel free to avoid it, but you'll -probably miss some nice tools you've probably never heard of! -I'll keep this list updated, so don't forget to check it from time to time. - -# [Images in terminal](/2014/01/images-in-terminal.html) -## &mdash; 28 January, 2014 -The terminal is the heart of your linux system. You do everything -through it. Everything ? No, images are still pissing you -off... -For my next trick, I'll preview a picture of an ant, without leaving my -terminal prompt! - -# [Love me some LaTex](/2013/12/love-me-some-latex.html) -## &mdash; 06 December, 2013 -Since I'm running linux, I'm getting more and more allergic to WYSIWYG -softwares. So i searched an alternative to write documents, and I've something -way better than just an alternative. Here is LaTeX. - -# [Plain old mails](/2013/11/plain-old-mails.html) -## &mdash; 04 November, 2013 -The other day, I ran into the "mail" tool. I decided to configure and try it -out this morning, and I was really, really surprised! - -# [Home, sweet home](/2013/10/home-sweet-home.html) -## &mdash; 28 October, 2013 -There is no place like home. And this is why setting up your environment is -important! -If you want advices on how to build a cosy and nice graphical environment, take -a look here. - -# [Java without Eclipse](/2013/09/java-without-eclipse.html) -## &mdash; 8 September, 2013 -Are you disapointed to leave your perfect UNIX environnment (vim, bash, git, -...) when it comes to java ..? Have you ever tried managing a Java project by -hand ..? Trust me, it is possible ! - -# [The Hard way](/2013/08/the-hard-way.html) -## &mdash; 9 August, 2013 -Do you encounter difficulties to master a tool ? Or maybe you find that you -don't have enough free time to put yourself into learning how to do this or -that ? Here is a well-known technic, to learn stuffs quickly, and efficiently. - -# [Test your CSS !](/2013/08/test-your-css.html) -## &mdash; 8 August, 2013 -Here a simple page with a few HTML tags. It's pretty useful to test your CSS, -even if there are no 'difficult' layouts. Feel free to download and share! - -<!-- vim: set ft=markdown ts=4 et: --> diff --git a/index.txt b/index.txt @@ -0,0 +1,50 @@ +# [Toolbox](/2014/03/toolbox.html) +## &mdash; 12 March, 2014 +Yeah, yet another list of unix tools. Feel free to avoid it, but you'll +probably miss some nice tools you've probably never heard of! +I'll keep this list updated, so don't forget to check it from time to time. + +# [Images in terminal](/2014/01/images-in-terminal.html) +## &mdash; 28 January, 2014 +The terminal is the heart of your linux system. You do everything +through it. Everything ? No, images are still pissing you +off... +For my next trick, I'll preview a picture of an ant, without leaving my +terminal prompt! + +# [Love me some LaTex](/2013/12/love-me-some-latex.html) +## &mdash; 06 December, 2013 +Since I'm running linux, I'm getting more and more allergic to WYSIWYG +softwares. So i searched an alternative to write documents, and I've something +way better than just an alternative. Here is LaTeX. + +# [Plain old mails](/2013/11/plain-old-mails.html) +## &mdash; 04 November, 2013 +The other day, I ran into the "mail" tool. I decided to configure and try it +out this morning, and I was really, really surprised! + +# [Home, sweet home](/2013/10/home-sweet-home.html) +## &mdash; 28 October, 2013 +There is no place like home. And this is why setting up your environment is +important! +If you want advices on how to build a cosy and nice graphical environment, take +a look here. + +# [Java without Eclipse](/2013/09/java-without-eclipse.html) +## &mdash; 8 September, 2013 +Are you disapointed to leave your perfect UNIX environnment (vim, bash, git, +...) when it comes to java ..? Have you ever tried managing a Java project by +hand ..? Trust me, it is possible ! + +# [The Hard way](/2013/08/the-hard-way.html) +## &mdash; 9 August, 2013 +Do you encounter difficulties to master a tool ? Or maybe you find that you +don't have enough free time to put yourself into learning how to do this or +that ? Here is a well-known technic, to learn stuffs quickly, and efficiently. + +# [Test your CSS !](/2013/08/test-your-css.html) +## &mdash; 8 August, 2013 +Here a simple page with a few HTML tags. It's pretty useful to test your CSS, +even if there are no 'difficult' layouts. Feel free to download and share! + +<!-- vim: set ft=markdown ts=4 et: -->