monochromatic blog:
git clone git://
Log | Files | Refs

commit e722726500374283ce875ba652de523f84a5a10c
parent dd3ba3c1ef6806be3cdcd5f71cb8fa4f22fdc4c3
Author: z3bra <>
Date:   Tue,  1 Apr 2014 09:00:41 +0200

Converted all files to markdown

2013/08/ | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/08/ | 103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/09/ | 207+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/10/ | 454+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/11/ | 187+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2013/12/ | 330+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014/01/ | 188+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014/03/ | 328+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2014/03/ | 22++++++++++++++++++++++ | 10++++++---- | 2++
11 files changed, 1905 insertions(+), 4 deletions(-)

diff --git a/2013/08/ b/2013/08/ @@ -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/ b/2013/08/ @@ -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]( +* Switch from a desktop environnement to a standalone window manager, like + [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/ b/2013/09/ @@ -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 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 + │ └── + ├── lib + │ ├── junit-4.11.jar + │ └── log4j-1.2.12.jar + ├── src + │ └── com + │ └── irc + │ ├── client + │ │ ├── + │ │ ├── + │ │ ├── + │ │ └── + │ ├── server + │ │ ├── + │ │ ├── + │ │ └── + │ └── utils + │ ├── + │ ├── + │ ├── + │ ├── + │ └── + └── 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/ + + -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/, bin/%.class, $(S_SERVER)) + S_CLIENT= $(shell find $(source_d)/com/irc/client -regex $(MATCH)) + C_CLIENT= $(patsubst src/, bin/%.class, $(S_CLIENT)) + S_UTILS= $(shell find $(source_d)/com/irc/utils -regex $(MATCH)) + C_UTILS= $(patsubst src/, bin/%.class, $(S_UTILS)) + + .SUFFIXES: .java .class + .PHONY: default server client utils clean init all + + default: classes + + $(class_d)/%.class: $(source_d)/ + @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/ b/2013/10/ @@ -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, 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](, +[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]( to +do that is a better idea, as it follow the +[UNIX philosophy](, 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]( +* [termite]( +* [evilvte]( +* [aterm]( +* [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]( +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 []( +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](, [irssi]( and +[mutt]( on a daily basis. +As an alternative, take a look at [emacs](, +[weechat]( and +[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](, 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]( +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/ &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/ b/2013/11/ @@ -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]( and [msmtp](, +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]( 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]( +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 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/ b/2013/12/ @@ -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]( +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]( + + 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: ``, and `file.pdf` (U DONT SAY?!), that you +will be able to view in your prefered PDF viewer. (I suggest +[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: + .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 ---------------------------------------- + + @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]( 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/ b/2014/01/ @@ -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]( +taken from [this website]( 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]( 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/ + + $ grep 'w3m' /usr/lib/python3.3/site-packages/ranger/ext/ + ... + 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]( +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!]( +[![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/ b/2014/03/ @@ -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]( &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](, 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]( + +### 9menu + +[LINK]( &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]( &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]( 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]( &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]( + +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]( (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]( + +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/ + ├── + │ ├── int + │ ├── out + │ └── #shblah + │ ├── int + │ └── out + └── + ├── 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/\#shblah/in + +Will effectively send a message to the channel "#shblah" on server +"". + +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]( + +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]( + +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]( + +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]( + +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]( &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]( &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]( &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]( &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/ b/2014/03/ @@ -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/ b/ @@ -12,10 +12,10 @@ for that matters). 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__ +* 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 @@ -33,3 +33,5 @@ I am on a few other places online. You want me ? Here I am : 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/ b/ @@ -46,3 +46,5 @@ that ? Here is a well-known technic, to learn stuffs quickly, and efficiently. ## &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: -->