How can I define a key combination which toggles between my default borderwidth (for example 2) and disabled borders (borderwidth=0) in xmonad. Compare this related question: Change the red border between windows in xmonad
I suppose the
XMonad.Actions.NoBorders module (in
xmonad-contrib) is helpful here (I've not tried it myself, tough(a)). It exports the
toggleBorder function, which
[toggles] the border of the currently focused window.
It's rather small and self-explanatory, so if binding
toggleBorder does not do exactly what you want, you probably can adept it to your needs.
(a) I'm not sure what you're about to achieve, but if you'd prefer not to have to press a key at all, the
XMonad.Layout.NoBorders module is great. It exports the
smartBorders layout modifier that removes the borders if it is not needed (if there's only one window and only one screen, for example).