<commit_before>import XMonad
import XMonad.ManageHook
import qualified XMonad.StackSet as W
import qualified Data.Map as M

import qualified XMonad.Actions.FlexibleManipulate as Flex
import qualified XMonad.Actions.Search as S
import XMonad.Actions.WindowBringer
import XMonad.Actions.Warp
import XMonad.Actions.Search
import qualified XMonad.Actions.Submap as SM
import XMonad.Prompt
import XMonad.Prompt.AppendFile
import XMonad.Util.Run

import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.ManageHelpers

import XMonad.Layout.LayoutScreens
import XMonad.Layout.TwoPane
import XMonad.Layout.ThreeColumns
import XMonad.Layout.LayoutHints
import XMonad.Layout.Mosaic
import XMonad.Layout.NoBorders

import Data.Monoid
import System.Exit

--TODO:  XMonad.Util.NamedScratchpad

main = xmonad $ withUrgencyHook NoUrgencyHook $ XConfig
    { XMonad.borderWidth        = 2
    , XMonad.workspaces         = map show [1..9 :: Int]
    , XMonad.terminal           = "gnome-terminal" --TODO: urxvt
    , XMonad.normalBorderColor  = "#000000"
    , XMonad.focusedBorderColor = "#ff0000"
    , XMonad.focusFollowsMouse  = True
    , XMonad.numlockMask        = mod2Mask
    , XMonad.modMask            = mod4Mask
    , XMonad.handleEventHook    = const $ return (All True)
    , XMonad.logHook            = return ()
    , XMonad.startupHook        = myStartupHook
    , XMonad.layoutHook         = myLayoutHook
    , XMonad.manageHook         = myManageHook
    , XMonad.mouseBindings      = myMouseBindings
    , XMonad.keys               = myKeys
    }

phi = 0.61803

myStartupHook = do
    spawn "xmodmap .kbd && xset r 66"
    spawn "google-chrome"
    spawn "pidgin"
    runInTerm "" "runloas"
    layoutScreens 2 (TwoPane 0.5 0.5)

myLayoutHook = mosaic 2 [3,2] |||
        layoutHints (Tall 1 (3/100) phi)
    ||| layoutHints (ThreeCol 1 (3/100) phi)
    ||| noBorders Full<commit_msg>Start of xevent logging / aggregation code<commit_after>import XMonad
import XMonad.ManageHook
import qualified XMonad.StackSet as W
import qualified Data.Map as M

import qualified XMonad.Actions.FlexibleManipulate as Flex
import qualified XMonad.Actions.Search as S
import XMonad.Actions.WindowBringer
import XMonad.Actions.Warp
import XMonad.Actions.Search
import qualified XMonad.Actions.Submap as SM
import XMonad.Prompt
import XMonad.Prompt.AppendFile
import XMonad.Util.Run

import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.ManageHelpers

import XMonad.Layout.LayoutScreens
import XMonad.Layout.TwoPane
import XMonad.Layout.ThreeColumns
import XMonad.Layout.LayoutHints
import XMonad.Layout.Mosaic
import XMonad.Layout.NoBorders

import Graphics.X11.Xlib.Extras
import Graphics.X11.Xlib.Types
import Data.Monoid
import Data.IORef
import System.Exit

--TODO:  XMonad.Util.NamedScratchpad

main = do
  loggerState <- newIORef (LoggerState M.empty M.empty M.empty M.empty (0, 0))
  xmonad $ withUrgencyHook NoUrgencyHook $ XConfig
    { XMonad.borderWidth        = 2
    , XMonad.workspaces         = map show [1..9 :: Int]
    , XMonad.terminal           = "gnome-terminal" --TODO: urxvt
    , XMonad.normalBorderColor  = "#000000"
    , XMonad.focusedBorderColor = "#ff0000"
    , XMonad.focusFollowsMouse  = True
    , XMonad.numlockMask        = mod2Mask
    , XMonad.modMask            = mod4Mask
    , XMonad.handleEventHook    = myEventHook loggerState
    , XMonad.logHook            = return ()
    , XMonad.startupHook        = myStartupHook
    , XMonad.layoutHook         = myLayoutHook
    , XMonad.manageHook         = myManageHook
    , XMonad.mouseBindings      = myMouseBindings
    , XMonad.keys               = myKeys
    }

phi = 0.61803

data LoggerState = LoggerState {
    keyHist :: (M.Map KeyCode Int),
    winHist :: (M.Map String Int),
    winMotion :: (M.Map String Double),
    winClicks :: (M.Map String [(Button, Double, Double)]),
    oldPos :: (Int, Int) }

myEventHook stateRef (ButtonEvent {ev_x=x, ev_y=y, ev_window=w, ev_event_type=t}) | t == buttonPress = do
    cname <- runQuery className w
    io $ modifyIORef stateRef (\ls -> ls {
        winClicks = M.insertWith (++) cname [] $ winClicks ls })
    return (All True)
{-
myEventHook stateRef (MotionEvent {ev_x=x, ev_y=y, ev_window=w}) = do
    cname <- runQuery className w
    io $ modifyIORef stateRef (\ls -> ls {
        oldPos = (fromIntegral x, fromIntegral y),
        winMotion = M.insertWith (+) cname (mouseDist x y ls) $ winMotion ls })
    return (All True)
  where mouseDist x y (LoggerState {oldPos=(ox,oy)}) =
            sqrt $ (fromIntegral x - ox)^2 + (fromIntegral y - oy)^2
-}

myEventHook stateRef (KeyEvent {ev_keycode=k, ev_window=w}) = do
    cname <- runQuery className w
    io $ modifyIORef stateRef (\ls -> ls {
        keyHist = M.insertWith (+) k 1 $ keyHist ls,
        winHist = M.insertWith (+) cname 1 $ winHist ls })
    return (All True)

myStartupHook = do
    spawn "xmodmap .xmonad/.kbd && xset r 66"
    spawn "google-chrome"
    spawn "pidgin"
    spawn "ln -s .xmonad/.vimrc"
    layoutScreens 2 (TwoPane 0.5 0.5)

myLayoutHook =
        layoutHints (Tall 1 (3/100) phi)
    ||| layoutHints (ThreeCol 1 (3/100) phi)
    ||| noBorders Full
{'fraction_non_alphanumeric': 0.0973862536302033, 'fraction_numerical': 0.01723136495643756, 'mean_word_length': 3.0202334630350194, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3647971', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1784, 'n_words': 430}