Posts Tagged ‘script’

surf browser hints /3

January 9, 2010

another couple of hints about surf, after my previous post.

honestly, I stopped using surf after 0.3 release. I think that the authors stripped out of the code too much sugar that, not being suckless, was nonetheless useful: a status bar showing the current URI, for example. now URI editing is done via xprop and dmenu, which is great piece of software, but not always user friendly (it does not have editing capabilities).

moreover bookmarking is a pain as it relies on external shell scripts. or does it not?

I realized that there is no need to use external shell scripts, as they can be “embedded” in C code. Here is how.

in config.h put these lines, right before the definition of keys[]:

#define BM_PICK { .v = (char *[]){ "/bin/sh", "-c", \
"xprop -id $0 -f _SURF_URI 8s -set _SURF_URI `cat ~/.surf/bookmarks | dmenu || exit 0`", \
winid, NULL } }

#define BM_ADD { .v = (char *[]){ "/bin/sh", "-c", \
"(echo `xprop -id $0 _SURF_URI | cut -d '\"' -f 2` && cat ~/.surf/bookmarks) | sort -u > ~/.surf/bookmarks_new && mv ~/.surf/bookmarks_new ~/.surf/bookmarks", \
winid, NULL } }

then inside keys[] definition, add:

{ MODKEY, GDK_b, spawn, BM_PICK },

now, recompile. in your shiny new surf, CTRL-B pops-up dmenu with the list of bookmarks and CTRL-SHIFT-B adds the current page to the bookmarks (making sure to remove duplicate entries).

no need for shell scripts!

dwm restart

January 8, 2010

dwm is a wonderful window manager for X: it’s small, fast and stable.

the only thing I missed, until today, was the possibility to restart it without losing my X session (i.e. all the open windows, etc.). restarting dwm is something you might need to do often, as it does not have config files: changes are done by recompiling the sources.

the trick is to execute dwm in background and sleep forever!

take a look at the last two lines of my .xinitrc:

dwm &

where sleeper looks like this:

while `/bin/true`; do
sleep 1000

now, if you kill dwm (usually with ALT-SHIFT-q) the windows (and X) will still be alive and you can type dwm& in any xterm to get dwm up and running again.

if you really want to quit X, you need to kill the sleeper.