load config with c

I’m working on my little window manager and it needs to be configured, such as colors, key bindings and so on.

We usually use getopt() to set some options like -d debug, -h help and -v version. It is not graceful to add lots of settings here, human type short. Some options are easy, we can also simply pass value through environment and read with getenv(). However, key-bindings are different, data structure is relatively complex:

  • There is always more than one key binding (array)
  • Key bindings have multiple combinations (struct)

Most important, I want to parse them within very short code thus easy to review.

Needs rewrite here with codes

First, main process use pipe to generate piperw[2] and then fork another process, thus both processes could send and read message with each other. Second the child process bind its STDOUT to piprw and call exec to change itself to run shell script

#!/bin/sh
wless-bind -a -k 6 -- echo 666
wless-bind -a -k 3 -- echo 333

// TO BE CONTINUE