[xmonad] colourful xterms

Adam Vogt vogt.adam at gmail.com
Thu Jun 4 20:03:11 EDT 2009


* On Thursday, June 04 2009, Bruce Stephens wrote:

>Gwern Branwen <gwern0 at gmail.com> writes:
>
>[...]
>
>> Sure, but then he'd need to scale it. $RANDOM outputs between 0 and
>> 32767, not 0-100.
>
>OK, in zsh, something like:
>
>    printf %d $((RANDOM/327.67))
>
>Of course, none of these are likely to be as good as just using python
>(or some other suitable language).  For example the zsh example's not

Haskell:

> import System.Random
> import Numeric
> import XMonad
> import Control.Monad

> randomHex :: (Integral a, Random a) => (a, a) -> IO [Char]
> randomHex = fmap (concatMap $ ensure 2 . ($ "") . showHex) . replicateM 3 . randomRIO
>     where ensure n = reverse . take n . (++repeat '0') . reverse

> randomBg :: (Int,Int) -> X ()
> randomBg x = do
>   t <- asks terminal
>   io $ spawn . ((t++" -bg '#")++) . (++"'") =<< randomHex x


More information about the xmonad mailing list