tgrok-that-workflow.txt - monochromatic - monochromatic blog: http://blog.z3bra.org
 (HTM) git clone git://z3bra.org/monochromatic
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       tgrok-that-workflow.txt (16254B)
       ---
            1 # Grok that workflow
            2 
            3 30 May, 2014
            4 
            5 ## Introduction
            6 > A workflow consists of an orchestrated and repeatable pattern of business
            7 > activity enabled by the systematic organization of resources into processes
            8 > that transform materials, provide services, or process information. It can be
            9 > depicted as a sequence of operations, declared as work of a person or group,
           10 > an organization of staff, or one or more simple or complex mechanisms.
           11 >
           12 > &mdash; <cite>From our savior Wikipedia, the free encyclopedia</cite>
           13 
           14 This has absolutely nothing to do with the subject of this post (or at least,
           15 not much..).
           16 
           17 The workflow I'm going to discuss here is my **personnal day-to-day
           18 computer workflow**. In other word, how I use my desktop. I'm not going to teach
           19 any trick, script, tweak or whatever you might think of. However, I'll provide
           20 links to software I use, piece of relevant config files, and animated images to
           21 illustrate some points.
           22 Now, shall we begin ?
           23 
           24 ## Summary
           25 
           26 * [GNU/Linux distribution](#os)
           27 * [Managing windows](#wm)
           28 * [Scripting the shell](#sh)
           29 * [Using applications](#apps)
           30 * [Playing with the terminal](#term)
           31 * [FAQ](#faq)
           32 
           33 <h3 id='os'>GNU/Linux distribution</h3>
           34 ### crux
           35 I'm a fairly new [crux](http://crux.nu) user. But I must say that I love it
           36 already.. Crux is the kind of distro you build with your bare hands in a whole
           37 week, while other would just it the "*install*" button, and watch the magic
           38 happen for an hour or so, and get the same result. You're barely helped, you do
           39 almost anything from scratch, you **compile everything**, and it is not even
           40 working as you want ! that's how I like my personnal desktop: **raw**.
           41 
           42 Here is a typical crux workflow:
           43 
           44 1.  Prepare your hard drive
           45 2.  Compile your kernel
           46 3.  Install the distro
           47 4.  Update your packages
           48 5.  Install package &lt;xxx&gt;
           49 6.  Ah, it's not packaged..
           50 7.  Create ports &lt;xxx&gt;
           51 8.  Install package &lt;xxx&gt;
           52 9.  Use package &lt;xxx&gt;
           53 10. GOTO 4
           54 
           55 [![installing packages under
           56 crux](http://pub.z3bra.org/monochromatic/img/thumb/2014-05-26-prtutils.jpg)](http://pub.z3bra.org/monochromatic/img/2014-05-26-prtutils.gif)
           57 *Here is a show case of a package installation under crux.
           58 [prtmk](http://git.z3bra.org/scripts/files/prtmk.html) is a small script I
           59 wrote that will create `Pkgfile`s using templates. Once the Pkgfile is created,
           60 you just need to download, compile the sources and install the package. Pretty
           61 easy :)*
           62 
           63 <h3 id='wm'>Managing windows</h3>
           64 My window manager of choice is venam's [2bwm](https://github.com/venam/2bwm).
           65 It's a light and simple
           66 [floater](https://wiki.archlinux.org/index.php/Window_Manager#Types) that comes
           67 with an impressive set of features and is configured at compile time using the
           68 special `config.h` file.
           69 
           70 Here is how my keybinds are organised:
           71 
           72 ### Managing windows
           73 
           74 <table>
           75 <tr>  <th>prefix</th>         <th>key</th>     <th>function</th>          </tr>
           76 <tr>  <td>MOD4</td>           <td>h,j,k,l</td> <td>move (10px)</td>       </tr>
           77 <tr>  <td>MOD4+SHIFT</td>     <td>h,j,k,l</td> <td>move (40px)</td>       </tr>
           78 <tr>  <td>MOD4+ALT</td>       <td>h,j,k,l</td> <td>resize (10px)</td>     </tr>
           79 <tr>  <td>MOD4+ALT+SHIFT</td> <td>h,j,k,l</td> <td>resize (40px)</td>     </tr>
           80 <tr>  <td>MOD4</td>           <td>y,u,b,n</td> <td>put in the corner</td> </tr>
           81 <tr>  <td>MOD4</td>           <td>g</td>       <td>put in the middle</td> </tr>
           82 <tr>  <td>MOD4</td>           <td>=</td>       <td>maximize (horiz.)</td> </tr>
           83 <tr>  <td>MOD4+SHIFT</td>     <td>=</td>       <td>maximize (vert.)</td>  </tr>
           84 <tr>  <td>MOD4</td>           <td>x</td>       <td>maximize (full)</td>   </tr>
           85 <tr>  <td>ALT</td>            <td>TAB</td>     <td>focus next window</td> </tr>
           86 <tr>  <td>ALT+SHIFT</td>      <td>TAB</td>     <td>focus prev window</td> </tr>
           87 </table>
           88 
           89 [![managning
           90 windows](http://pub.z3bra.org/monochromatic/img/thumb/2014-05-27-windows.jpg)](http://pub.z3bra.org/monochromatic/img/2014-05-27-windows.gif)
           91 *Here are the movements I use on a daily basis. There are
           92 more features, but that's the one I use the most (other are just combination of
           93 those)*
           94 
           95 ### Managing groups
           96 
           97 Before using 2bwm, I was using [cwm](http://monkey.org/~marius/pages/?page=cwm),
           98 which is itself a rewrite of [evilwm](http://www.6809.org.uk/evilwm/). `Cwm` has
           99 a feature I like a lot: *groups*. These are basically like workspaces, with a
          100 neat-feature: you can show/hide them whenever you want.
          101 this allow grouping windows by tasks, and then raise groups depending on what
          102 you want to do. And if you wanna work on two tasks at the same time, well, just
          103 raise both tasks ! See the following animated image to get a visual idea of how
          104 it works.
          105 
          106 When I switched to `2bwm`, I missed this feature.. Because it uses only the
          107 traditionnal workspaces behavior (aka "*a-single-group-shown-at-the-time*"). So
          108 I [forked](git://z3bra.org/2bwm) (not maintained anymore) the whole repo and
          109 implemented this feature. It's know perfectly working (as I can't find any bug,
          110 but there might be..), and you can even switch between groups and workspaces
          111 behavior with a hotkey !
          112 
          113 <table>
          114 <tr><th>prefix</th>    <th>key</th>        <th>function</th>              </tr>
          115 <tr><td>ALT</td>       <td>F&lt;x&gt;</td> <td>switch to ws &lt;x&gt;</td></tr>
          116 <tr><td>ALT+SHIFT</td> <td>F&lt;x&gt;</td> <td>send to ws &lt;x&gt;</td>  </tr>
          117 <tr><td>ALT</td>       <td>g</td>          <td>change behavior</td>       </tr>
          118 </table>
          119 
          120 [![managning
          121 groups](http://pub.z3bra.org/monochromatic/img/thumb/2014-05-27-groups.jpg)](http://pub.z3bra.org/monochromatic/img/2014-05-27-groups.gif)
          122 *Showing the two behavior: workspaces VS. groups. Each
          123 windows holds the number of the group it's sitting on*
          124 
          125 <h3 id='sh'>Scripting the shell</h3>
          126 The shell is a really powerfull toy. Not only because it looks badass, but
          127 because you can automate boring tasks by writing shell scripts. Here are my
          128 prefered:
          129 
          130 ### detach applications
          131 Sometimes, I need to start an application, and then detach it from my current
          132 terminal (to reattach it somewhere, or later). To solve this, `tmux` or `screen`
          133 could cut it, but I decided to use [dtach](http://dtach.sourceforge.net/)
          134 instead, which *ONLY* emulate the detach feature, without multiplexing terminal
          135 and such. I prefer it over `screen` or `tmux` because it's really lighter, and I
          136 can then move my `dtach` sessions between my `tmux` sessions.
          137 
          138 To deal with it, I use a simple script named `dm` (for "*dtach manager*") that
          139 let me create and attach sessions easily:
          140 
          141     ─── dm -h
          142     dm [-hl] <alias> [command]
          143 
          144     # start a new session for IRC and fork it
          145     ─── dm irc irssi &
          146     [1] 4379
          147 
          148     # list existing sessions
          149     ─── dm -l
          150     irc
          151 
          152     # attach the "irc" session
          153     ─── dm irc
          154 
          155 ### compile softwares
          156 This one might be specific to me, but when I'm programming, I often encounter
          157 the following issue:
          158 
          159     ─── git pull
          160     Updating 74bbe97..9b40eba
          161     error: Your local changes to the following files would be overwritten by merge:
          162     config.h
          163     Please, commit your changes or stash them before you can merge.
          164     Aborting
          165 
          166 **RRRAAAAAAHAHH !** You will have to rename the config.h to keep your changes, restore default
          167 config, pull the changes, then recover your saved config.h... 
          168 
          169 It's not much.. But it's enough to get on my nerves.  I then wrote another small
          170 script to help me with the boring task of constantly switching between default
          171 and personnal file (But you can typically use it in any case you wanna switch
          172 between multiple files). It goes like this:
          173 
          174     # check which file is in use
          175     ─── hm -c
          176     config.h is different from stored config
          177 
          178     # save current config
          179     ─── hm -s 2bwm/$USER.h
          180 
          181     # list stored configs
          182     ─── hm -l 2bwm
          183     2bwm
          184     ├── config.def.h
          185     └── z3bra.h
          186 
          187     # restore default config (previously store)
          188     ─── hm -r 2b/config.def.h
          189 
          190 And now my life's much easier !
          191 
          192 I use a few others, to get links from a youtube search, translate some text,
          193 change my speakers, volume, ...  Check my whole
          194 [~/bin/](http://git.z3bra.org/scripts/files.html) for more!
          195 
          196 
          197 <h3 id='apps'>Using applications</h3>
          198 To start my application, I used `xbindkeys` a lot. But I found that `sxhkd` is
          199 as efficient, but its config file is way more subtile and clean. I do not use my
          200 window manager to spawn applications, so that I don't have to tweak every WM
          201 config to spawn a terminal, and it even works WITHOUT a window manager :)
          202 
          203 Anyway, I don't have many shortcuts.. Here is a table to relate:
          204 
          205 <table>
          206 <tr> <th>shortcut</th>      <th>command</th>        </tr>
          207 <tr> <td>MOD4 + Enter</td>  <td>urxvt</td>          </tr>
          208 <tr> <td>MOD4 + m</td>      <td>urxvt -e mail</td>  </tr>
          209 <tr> <td>MOD4 + w</td>      <td>dwb</td>            </tr>
          210 <tr> <td>Menu</td>          <td>~/bin/menu</td>     </tr>
          211 <tr> <td>XF86Audio..</td>   <td>~/bin/volume ..</td></tr>
          212 </table>
          213 
          214 I use my menu key to spawn a menu with some applications (pdf, term, web, ..),
          215 but I don't use it that often. It's nice though, so I just keep it.
          216 
          217 One interresting point, though. About the interaction between applications. I use `urxvt` as my terminal, and `dwb` as my web browser. This terminal has the powerful feature of being extensive in perl. I personnaly use two extensions:
          218 `url_select` and `keyboard_select`. The first one let you select URLs with
          219 `ALT+u` and open/yank them up with `Enter` or `y`. The second let you select
          220 text and yank it using `ALT+v`. It's pretty nice to avoid grabbing the mouse !
          221 
          222 
          223 <h3 id="term">Playing with the terminal</h3>
          224 
          225 Pretty much everything I do on my desktop imply to interact with the terminal.
          226 So that's one of my most tweaked application. But before speaking about any
          227 tweak, let's see how I find my way through the file system.
          228 
          229     $ tree -L 2 $HOME
          230 
          231     /home/z3bra
          232     ├── bin
          233     │   ├── backup
          234     │   ├── [...]
          235     │   └── ys
          236     ├── etc
          237     │   ├── bashrc
          238     │   ├── [...]
          239     │   └── zshrc
          240     ├── src
          241     │   ├── bf
          242     │   ├── c
          243     │   ├── cpp
          244     │   ├── java
          245     │   ├── pkg
          246     │   ├── sql
          247     │   └── www
          248     ├── tmp
          249     ├── usr
          250     │   ├── doc
          251     │   ├── img
          252     │   ├── msc
          253     │   ├── ports
          254     │   └── vid
          255     └── var
          256         ├── btp
          257         ├── irc
          258         ├── log
          259         ├── mail
          260         ├── run
          261         └── to
          262 
          263     31 directories, 47 files
          264 
          265 I try to mimic the unix filesystem:
          266 
          267 * `~/bin` : Holds my script and personnal binaries (it's in my $PATH, too)
          268 * `~/etc` : Where my config files are stored. They are then symlink everywhere
          269 * `~/src` : Every source of software goes there. They're sorted by language
          270 * `~/tmp` : A piece of ram used for download, it forces myself to class the
          271   files I download, as everything in this dir will be wiped on reboot
          272 * `~/usr` : User files. from documents, to images, videos or distro packages
          273 * `~/var` : For every files created by softwares. I use it to store my emails,
          274   dtach's sockets, log files, torrents, and such
          275 
          276 Now that you visited my `$HOME`, let's see how I use it. My main shell is
          277 `bash`. Mostly because I don't find `zsh` that useful, because I don't need all
          278 those plugins. So my `~/.bashrc` is pretty heavily tweaked:
          279 
          280     $ wc ~/etc/bashrc
          281     225  733 5291 /home/willy/etc/bashrc
          282 
          283 The reason is that I hve many functions for everything that's to simple to put
          284 in a script or that I don't plan to run non-interactively. You could see simple
          285 monitoring function to get the top 10 processes, or memory usage. Or online
          286 pastebin.. Nothing really fancy in fact.
          287 
          288 Then there are the aliases. Most of them are just command shortener :
          289 
          290     # command shortner
          291     alias g='grep'
          292     alias v="vim"
          293     alias t='tmux'
          294     alias btc="btcli -d ~/var/btp"
          295     alias csv='column -t -s\;'
          296     alias vol="alsamixer"
          297 
          298 So that's my config. There's not much to say after that.. I use `cd -`, `pushd`
          299 and `popd` to navigate the whole tree, and I start my application from the CLI,
          300 rather than menus or shortcuts (because having to remember shortcuts for the WM
          301 is enough, and it does not leave much room for any other shortcuts!).
          302 
          303 When I have to deal wiht USB sticks, I just start
          304 [ldm](https://github.com/LemonBoy/ldm) so that the stick mounts itself using my
          305 UID/GID. I do not start it by default because I seldom need it, and it fucks
          306 up the mounting of my `/` and `/home` on boot.
          307 
          308 Oh, also, I'm a big fan of text files, mostly because the GNU userland (or
          309 any good user space) provides enough tools to play with them:
          310 
          311     $ grep z3bra ~/usr/doc/contacts.txt
          312     z3bra,          willy@mailoo.org,       http://z3bra.org
          313 
          314     $ column -t -s, ~/usr/doc/bookmarks.txt
          315     Arch linux forum  https://bbs.archlinux.org
          316     Nixers forum      http://nixers.net
          317     Ypnose blog       http://ywstd.fr/blog/
          318     Suckless website  http://suckless.org
          319 
          320     $ cat ~/usr/doc/todo.txt
          321     1. polish report's appendix
          322     2. record a video for the blog
          323     3. publish the workflow post [URGENT]
          324     4. buy some bananas
          325 
          326     $ sed -i '/^[23]/d;s/^4/2/' $_
          327 
          328 Talking about this, Reihar wrote a nice
          329 [article](http://blag.necronomicon.fr/2013/12/21/libreoffice-batch-convert)
          330 about converting document using libreoffice. I use it from time to time to
          331 convert spreadsheets to CSV files, it's handy!
          332 
          333 ## Bonus
          334 
          335 And there ends that narcissic article. I hope you found it interesting, even if
          336 everything I present here is totally specific to me. As a bonus, to thank you
          337 for reading this, here is a small video of my day to day workflow. Enjoy!
          338 
          339 <video controls>
          340 <source src="http://pub.z3bra.org/monochromatic/vid/2014-05-30-workflow.mp4" type="video/mp4"/>
          341 <source src="http://pub.z3bra.org/monochromatic/vid/2014-05-30-workflow.webm" type="video/webm"/>
          342 <source src="http://pub.z3bra.org/monochromatic/vid/2014-05-30-workflow.ogv"  type="video/ogg"/>
          343 Your browser do not support embedded video. But you can download the files
          344 </video>
          345 
          346 <div class='center'>
          347 download : 
          348 <a href="http://pub.z3bra.org/monochromatic/vid/2014-05-30-workflow.ogv"> ogv </a> | 
          349 <a href="http://pub.z3bra.org/monochromatic/vid/2014-05-30-workflow.mp4"> mp4 </a> | 
          350 <a href="http://pub.z3bra.org/monochromatic/vid/2014-05-30-workflow.webm"> webm </a>
          351 </div><br>
          352 
          353 <div class='caption'>
          354 That's a typical use of my desktop. IRC chat in
          355 bottom left (group 1), dev window on top left (group 3) and web session on the
          356 right for having enough space. Any other app would go on groups 4-9, and their
          357 placement would depend on my mood :)</div>
          358 
          359 
          360 <h3 id='faq'>FAQ</h3>
          361 If I receive interesting questions by mail, I'll answer back and quote the mail
          362 here, as a reference, so don't be shy and [feel free to
          363 ask](mailto:contact@z3bra.org) !
          364 
          365 ---
          366 
          367 **jumpwah** wrote:
          368 > The mouse always seems to be at the bottom right of the focused window, why?
          369 > Is that a feature of 2bwm?
          370 
          371 It's a feature of 2bwm that was added recently. 2bwm focuses windows by
          372 following the mouse cursor, so when you alt-tab, the cursor goes over windows to
          373 focus them. At first, it was positioned in the middle of the window, but we
          374 found that annoying so we updated the code to let the user choose where to put
          375 the cursor. mine is set to `BOTTOM_RIGHT`. so if you do not touch the mouse, the
          376 cursor will always be on bottom right of your current window :-)
          377 
          378 ---
          379 
          380 **jumpwah** wrote:
          381 > At around 0:37 in the video, when you open dwb, it seems to automatically fill
          382 > up the remaining space available... is this also a feature of 2bwm or did you
          383 > somehow predefine the window size?
          384 
          385 Both in fact. I configured dwb to spawn with a specific size, which fits the
          386 exact size of the left area, but a smaller height. I then pressed "mod4 + =" to
          387 maximise it vertically, to fit the remaining space
          388 
          389 ---
          390 
          391 **moisespedro** wrote:
          392 > The way you copy those links on the pkgfile script gave me a semi. What
          393 > browser/wm is that and how you do that?
          394 
          395 The browser is dwb, and WM is 2bwm. To copy the links I press ";y" and it puts
          396 two letters above each link in the Web page. I then press the two letters
          397 corresponding to the link I wanna yank, and it's yanked. To yank the address of
          398 the current page, I just press "y"