[xmonad] colourful xterms
Thomas Friedrich
info at suud.de
Thu Jun 4 20:05:09 EDT 2009
I was already betting with myself, when the first Haskell solution would
be finally posted ;)
Thanks so much!
Best,
Thomas
Adam Vogt wrote:
> * 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
>>
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org
> http://www.haskell.org/mailman/listinfo/xmonad
>
More information about the xmonad
mailing list