Skip to content

Instantly share code, notes, and snippets.

@pablox-cl
Created September 25, 2012 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pablox-cl/3783783 to your computer and use it in GitHub Desktop.
Save pablox-cl/3783783 to your computer and use it in GitHub Desktop.
Wrapper for xmessage to prevent it from run itself if xmonad has compile errors
#!/bin/bash
#
# Author: Pablo Olmos de Aguilera C. pablo at glatelier dot org
#
# Little wrapper to prevent xmessage to pop if errors are thrown when
# (re)compiling xmonad. Of course this assumes that you should recompile it from
# the command line.
#
# Just make sure your $PATH is correctly set, before the original xmessage to
# this code run.
#
# Acknowledgements:
# * Brandon Allbery for the suggestion (http://permalink.gmane.org/gmane.comp.lang.haskell.xmonad/12794)
# * StackOverflow (once again...) for the ideas about how to know if "string contains":
# http://stackoverflow.com/questions/229551/string-contains-in-bash
# alternative using regex
if [[ "$3" =~ .*rror\ detected\ while\ loading\ xmonad\ configuration\ file:\
.*xmonad/xmonad.hs.* ]]; then
# another alternative using wildcards
#if [[ "$3" == *.xmonad/xmonad.hs* ]]
exit 0
fi
/usr/bin/xmessage "$@"
@janderholm
Copy link

Another nice trick is to use the $TERM variable. It is set to "dumb" whenever xmonad is recompiled using mod + q.
Whenever it is recompiled with xmonad --recompile $TERM will be set to whatever your terminal is, e.g. xterm-256color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment