jasonwryan.com

Miscellaneous ephemera…

Changing Keybinds in vifm

Vifm is a ncurses based file manager with vi-like keybindings; it gives you complete keyboard control over your files without having to learn a new set of commands.

Vifm

The only drawback, for me, is that as of the current version (0.5-1) you can’t map keys. While the developer has indicated it is on the todo list, he also flagged that it is some way off. If, like me, you map : ; in Vim, then not having this functionality is a minor irritant. Fortunately, it is also easily fixed. Ken Steen, the Vifm developer, was kind enough to point me in the right direction…

Download the tarball from AUR and untar it etc.,

1
$ tar -xzf vifm.tar.gz cd vifm/

Build the package

1
$ makepkg -s

Then you will need to edit the file, keys.c

1
vim src/vifm-0.5/src/keys.c

Search for the command key

1
/case ':':

In this version it is at line 982. Change the entry to your key of choice — in my case ; — and save and quit.

Recompile Vifm and you are done…

1
$ makepkg -efi

Update 18/2/10

Vifm has now been moved to Community, so you can use ABS to build the package.

Patching dwm with pertag and bstack

Over the last several months I have been using dwm as my window manager on two Arch Linux machines: my EeePC 901 and an old Dell at work.

There is a lot to like about dwm, but the most attractive qualities for me are the fact that it is under 2000 SLOC and is very configurable.

The most recent version, 5.7.2, included some changes that meant that some of the patches wouldn’t play nicely together anymore; trying to combine any of the layout patches with pertag would result in the code failing to compile.

Fortunately, there is a fix described on the mailing list. Essentially, it involves manually applying the patch to the source code.

Start with a vanilla version of the code. Move to the source directory and apply the pertag patch:

1
cd $BUILD/dwm/src/dwm-5.7.2/ patch -p1 < dwm-5.7.2-pertag.diff

Then manually add the bstack (or any of the other layout patches) to dwm.c:

Include the bstack declaring function with the others, beginning line 153. I inserted it alphabetically…

1
2
3
4
static void attachstack(Client *c);
static void bstack(Monitor *m);
static void buttonpress(XEvent *e);

And then, after the #include “config.h” declaration at 275, add in the rest of the patch. For consistency’s sake, I included it at line 415:

1
2
3
4
5
6
7
void bstack(Monitor *m) {
  int x, y, h, w, mh;
  unsigned int i, n;
  Client *c; for(n = 0, c = nexttiled(m-&gt;clients); c; c = nexttiled(c-&gt;next), n++);
  if(n == 0)
return;

Add you keybindings into your header file (config.h) and recompile:

1
makepkg -efi

Done.

The only fly in the ointment is that, for me anyway, I have been unable to get any of the other layout patches to work with this setup; either by regular patching or using the above method. YMMV.

Update

So I was wrong: you can get pertag to work with all the other patches, and it is not that difficult

dzen2 and conky-cli in dwm

I struggled over the last couple of days to pipe conky into a Dzen2 status bar alongside the default dwm bar.

Here is how I sorted it.

First, I installed conky-cli and dzen2. Conky-cli is in AUR, and dzen2 is in Community:

1
pacman -S dzen2 && yaourt conky-cli

Then it was a matter of setting up the relevant files.

.xinitrc.sh
1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh
# ~/.xinitrc
setxkbmap -option terminate:ctrl_alt_bksp &amp;
eval `cat ~/.fehbg` &amp;
numlockx &amp;
xscreensaver -no-splash &amp;
# Dzen &amp; conky
(sleep 15s &amp;&amp; conky | dzen2 -x '500' -e '' -fg '#dcdcdc' -bg '#3f3f3f' \
-w '650' -ta r -fn '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*' -p ) &amp;
# Start dwm
exec ck-launch-session ~/Scripts/dwm-start
.conkyrc .sh
1
2
3
4
5
6
7
8
background no
out_to_console yes
update_interval 2
total_run_times 0
use_spacer none
double_buffer yes
TEXT
${if_existing /sys/class/power_supply/BAT0/present}^i(/home/jason/Build/dwm/dzen/bat.xbm)…
dwm-start .sh
1
2
3
while true; do 
    dwm >/dev/null
done

The key is —and it took me a while to work it out— to delay the loading of conky until after dwm has painted it’s status bar; otherwise conky | dzen2 is obscured.

Now, the “before” shot:

…and the finished product:

Conky-cli to dzen2 in dwm on Arch