Cleanly respawning xmobar when reload xmonad

xmonad

This is just a small annoyance, but I've made the XMonad configuration file load xmobar using this code:

xmproc <- spawnPipe "/use/bin/xmobar ~/.xmobarrc"

It works well, but it spawn a new xmobar process every time XMonad is reloaded. I wonder if there's an easy way to kill the old one?

update: As suggested by entropo, I've created a bash script like this one:

#!/bin/bash

for PID in `pgrep xmobar`; do
    kill ${PID} > /dev/null &
done

/usr/bin/xmobar &

and call that script from XMonad configuration file.

Best Answer

Not xmonad specific, but you could launch xmobar through a shell script that checks for an existing xmobar process. See, e.g., http://bash.cyberciti.biz/web-server/restart-apache2-httpd-shell-script/

Related Question