Monochromatic

z3bra, the stripes apart

Grok that workflow

— 30 May, 2014

Introduction

A workflow consists of an orchestrated and repeatable pattern of business activity enabled by the systematic organization of resources into processes that transform materials, provide services, or process information. It can be depicted as a sequence of operations, declared as work of a person or group, an organization of staff, or one or more simple or complex mechanisms.

From our savior Wikipedia, the free encyclopedia

This has absolutely nothing to do with the subject of this post (or at least, not much..).

The workflow I'm going to discuss here is my personnal day-to-day computer workflow. In other word, how I use my desktop. I'm not going to teach any trick, script, tweak or whatever you might think of. However, I'll provide links to software I use, piece of relevant config files, and animated images to illustrate some points. Now, shall we begin ?

Summary

GNU/Linux distribution

crux

I'm a fairly new crux user. But I must say that I love it already.. Crux is the kind of distro you build with your bare hands in a whole week, while other would just it the "install" button, and watch the magic happen for an hour or so, and get the same result. You're barely helped, you do almost anything from scratch, you compile everything, and it is not even working as you want ! that's how I like my personnal desktop: raw.

Here is a typical crux workflow:

  1. Prepare your hard drive
  2. Compile your kernel
  3. Install the distro
  4. Update your packages
  5. Install package <xxx>
  6. Ah, it's not packaged..
  7. Create ports <xxx>
  8. Install package <xxx>
  9. Use package <xxx>
  10. GOTO 4

installing packages under
crux Here is a show case of a package installation under crux. prtmk is a small script I wrote that will create Pkgfiles using templates. Once the Pkgfile is created, you just need to download, compile the sources and install the package. Pretty easy :)

Managing windows

My window manager of choice is venam's 2bwm. It's a light and simple floater that comes with an impressive set of features and is configured at compile time using the special config.h file.

Here is how my keybinds are organised:

Managing windows

prefix key function
MOD4 h,j,k,l move (10px)
MOD4+SHIFT h,j,k,l move (40px)
MOD4+ALT h,j,k,l resize (10px)
MOD4+ALT+SHIFT h,j,k,l resize (40px)
MOD4 y,u,b,n put in the corner
MOD4 g put in the middle
MOD4 = maximize (horiz.)
MOD4+SHIFT = maximize (vert.)
MOD4 x maximize (full)
ALT TAB focus next window
ALT+SHIFT TAB focus prev window

managning
windows Here are the movements I use on a daily basis. There are more features, but that's the one I use the most (other are just combination of those)

Managing groups

Before using 2bwm, I was using cwm, which is itself a rewrite of evilwm. Cwm has a feature I like a lot: groups. These are basically like workspaces, with a neat-feature: you can show/hide them whenever you want. this allow grouping windows by tasks, and then raise groups depending on what you want to do. And if you wanna work on two tasks at the same time, well, just raise both tasks ! See the following animated image to get a visual idea of how it works.

When I switched to 2bwm, I missed this feature.. Because it uses only the traditionnal workspaces behavior (aka "a-single-group-shown-at-the-time"). So I forked (not maintained anymore) the whole repo and implemented this feature. It's know perfectly working (as I can't find any bug, but there might be..), and you can even switch between groups and workspaces behavior with a hotkey !

prefix key function
ALT F<x> switch to ws <x>
ALT+SHIFT F<x> send to ws <x>
ALT g change behavior

managning
groups Showing the two behavior: workspaces VS. groups. Each windows holds the number of the group it's sitting on

Scripting the shell

The shell is a really powerfull toy. Not only because it looks badass, but because you can automate boring tasks by writing shell scripts. Here are my prefered:

detach applications

Sometimes, I need to start an application, and then detach it from my current terminal (to reattach it somewhere, or later). To solve this, tmux or screen could cut it, but I decided to use dtach instead, which ONLY emulate the detach feature, without multiplexing terminal and such. I prefer it over screen or tmux because it's really lighter, and I can then move my dtach sessions between my tmux sessions.

To deal with it, I use a simple script named dm (for "dtach manager") that let me create and attach sessions easily:

─── dm -h
dm [-hl] <alias> [command]

# start a new session for IRC and fork it
─── dm irc irssi &
[1] 4379

# list existing sessions
─── dm -l
irc

# attach the "irc" session
─── dm irc

compile softwares

This one might be specific to me, but when I'm programming, I often encounter the following issue:

─── git pull
Updating 74bbe97..9b40eba
error: Your local changes to the following files would be overwritten by merge:
config.h
Please, commit your changes or stash them before you can merge.
Aborting

RRRAAAAAAHAHH ! You will have to rename the config.h to keep your changes, restore default config, pull the changes, then recover your saved config.h...

It's not much.. But it's enough to get on my nerves. I then wrote another small script to help me with the boring task of constantly switching between default and personnal file (But you can typically use it in any case you wanna switch between multiple files). It goes like this:

# check which file is in use
─── hm -c
config.h is different from stored config

# save current config
─── hm -s 2bwm/$USER.h

# list stored configs
─── hm -l 2bwm
2bwm
├── config.def.h
└── z3bra.h

# restore default config (previously store)
─── hm -r 2b/config.def.h

And now my life's much easier !

I use a few others, to get links from a youtube search, translate some text, change my speakers, volume, ... Check my whole ~/bin/ for more!

Using applications

To start my application, I used xbindkeys a lot. But I found that sxhkd is as efficient, but its config file is way more subtile and clean. I do not use my window manager to spawn applications, so that I don't have to tweak every WM config to spawn a terminal, and it even works WITHOUT a window manager :)

Anyway, I don't have many shortcuts.. Here is a table to relate:

shortcut command
MOD4 + Enter urxvt
MOD4 + m urxvt -e mail
MOD4 + w dwb
Menu ~/bin/menu
XF86Audio.. ~/bin/volume ..

I use my menu key to spawn a menu with some applications (pdf, term, web, ..), but I don't use it that often. It's nice though, so I just keep it.

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: url_select and keyboard_select. The first one let you select URLs with ALT+u and open/yank them up with Enter or y. The second let you select text and yank it using ALT+v. It's pretty nice to avoid grabbing the mouse !

Playing with the terminal

Pretty much everything I do on my desktop imply to interact with the terminal. So that's one of my most tweaked application. But before speaking about any tweak, let's see how I find my way through the file system.

$ tree -L 2 $HOME

/home/z3bra
├── bin
│   ├── backup
│   ├── [...]
│   └── ys
├── etc
│   ├── bashrc
│   ├── [...]
│   └── zshrc
├── src
│   ├── bf
│   ├── c
│   ├── cpp
│   ├── java
│   ├── pkg
│   ├── sql
│   └── www
├── tmp
├── usr
│   ├── doc
│   ├── img
│   ├── msc
│   ├── ports
│   └── vid
└── var
    ├── btp
    ├── irc
    ├── log
    ├── mail
    ├── run
    └── to

31 directories, 47 files

I try to mimic the unix filesystem:

Now that you visited my $HOME, let's see how I use it. My main shell is bash. Mostly because I don't find zsh that useful, because I don't need all those plugins. So my ~/.bashrc is pretty heavily tweaked:

$ wc ~/etc/bashrc
225  733 5291 /home/willy/etc/bashrc

The reason is that I hve many functions for everything that's to simple to put in a script or that I don't plan to run non-interactively. You could see simple monitoring function to get the top 10 processes, or memory usage. Or online pastebin.. Nothing really fancy in fact.

Then there are the aliases. Most of them are just command shortener :

# command shortner
alias g='grep'
alias v="vim"
alias t='tmux'
alias btc="btcli -d ~/var/btp"
alias csv='column -t -s\;'
alias vol="alsamixer"

So that's my config. There's not much to say after that.. I use cd -, pushd and popd to navigate the whole tree, and I start my application from the CLI, rather than menus or shortcuts (because having to remember shortcuts for the WM is enough, and it does not leave much room for any other shortcuts!).

When I have to deal wiht USB sticks, I just start ldm so that the stick mounts itself using my UID/GID. I do not start it by default because I seldom need it, and it fucks up the mounting of my / and /home on boot.

Oh, also, I'm a big fan of text files, mostly because the GNU userland (or any good user space) provides enough tools to play with them:

$ grep z3bra ~/usr/doc/contacts.txt
z3bra,          willy@mailoo.org,       http://z3bra.org

$ column -t -s, ~/usr/doc/bookmarks.txt
Arch linux forum  https://bbs.archlinux.org
Nixers forum      http://nixers.net
Ypnose blog       http://ywstd.fr/blog/
Suckless website  http://suckless.org

$ cat ~/usr/doc/todo.txt
1. polish report's appendix
2. record a video for the blog
3. publish the workflow post [URGENT]
4. buy some bananas

$ sed -i '/^[23]/d;s/^4/2/' $_

Talking about this, Reihar wrote a nice article about converting document using libreoffice. I use it from time to time to convert spreadsheets to CSV files, it's handy!

Bonus

And there ends that narcissic article. I hope you found it interesting, even if everything I present here is totally specific to me. As a bonus, to thank you for reading this, here is a small video of my day to day workflow. Enjoy!

download : ogv | mp4 | webm


That's a typical use of my desktop. IRC chat in bottom left (group 1), dev window on top left (group 3) and web session on the right for having enough space. Any other app would go on groups 4-9, and their placement would depend on my mood :)

FAQ

If I receive interesting questions by mail, I'll answer back and quote the mail here, as a reference, so don't be shy and feel free to ask !


jumpwah wrote:

The mouse always seems to be at the bottom right of the focused window, why? Is that a feature of 2bwm?

It's a feature of 2bwm that was added recently. 2bwm focuses windows by following the mouse cursor, so when you alt-tab, the cursor goes over windows to focus them. At first, it was positioned in the middle of the window, but we found that annoying so we updated the code to let the user choose where to put the cursor. mine is set to BOTTOM_RIGHT. so if you do not touch the mouse, the cursor will always be on bottom right of your current window :-)


jumpwah wrote:

At around 0:37 in the video, when you open dwb, it seems to automatically fill up the remaining space available... is this also a feature of 2bwm or did you somehow predefine the window size?

Both in fact. I configured dwb to spawn with a specific size, which fits the exact size of the left area, but a smaller height. I then pressed "mod4 + =" to maximise it vertically, to fit the remaining space


moisespedro wrote:

The way you copy those links on the pkgfile script gave me a semi. What browser/wm is that and how you do that?

The browser is dwb, and WM is 2bwm. To copy the links I press ";y" and it puts two letters above each link in the Web page. I then press the two letters corresponding to the link I wanna yank, and it's yanked. To yank the address of the current page, I just press "y"