#!/bin/sh -e

# add Russian and US keyboard layouts and toggle them with Alt + Space
setxkbmap -layout 'us,ru' -option \
	'grp:alt_space_toggle,grp_led:caps,ctrl:nocaps'

# hide X11 pointer (cursor) when it has not moved for a few seconds
unclutter -root -idle 2 -noevents &

# run xlock when idle
xidle &

# "natural" scroll for trackpad
xinput set-button-map	/dev/wsmouse0	1 2 3 5 4 7 6

# keep regular scroll and slowdown mouse, trackpoint, and trackball
xinput set-button-map	/dev/wsmouse	1 2 3 4 5 6 7

# emulate the middle button and the scroll wheel
xinput set-prop /dev/wsmouse 'Device Accel Constant Deceleration' 2
xinput set-prop /dev/wsmouse 'WS Pointer Middle Button Emulation' 1
xinput set-prop /dev/wsmouse 'WS Pointer Wheel Emulation'         1
xinput set-prop /dev/wsmouse 'WS Pointer Wheel Emulation Button'  2
xinput set-prop /dev/wsmouse 'WS Pointer Wheel Emulation Inertia' 3
xinput set-prop /dev/wsmouse 'WS Pointer Wheel Emulation Timeout' 500

# turn off the bell, make background black, and launch cwm
xset -b
xsetroot -solid black
exec cwm
