monochromatic

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

grok-that-workflow.txt (16405B)


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