current commit
260715.2 · marge: add new machine
#!/bin/sh

# A script to re-apply X11 options whenever something changes that seems to
# cause the settings to be reset to the default.
#
# I got this idea from Codex.

apply() {
  delay=250
  rate=40
  xsetroot -cursor_name left_ptr
  # Resets keyboard map. Useful when calling
  # this idempotently.
  setxkbmap us
  setxkbmap -option terminate:ctrl_alt_bksp
  xset r rate "$delay" "$rate" >/dev/null 2>&1
  xset b 0

  case "$(myhostname)" in
    bart|maggie)
      framework-configure-touchpad
      ;;
    nas2|wiggum|otto|flanders|milhouse)
      no-blanking
      xset m 3 1
      ;;
    duff|marge)
      xset m 1 1
      xinput --set-prop 'Logitech Anywhere MX' 'libinput Accel Speed' -0.75
      xinput --set-prop 'pointer:Logitech MX Anywhere 2' 'libinput Accel Speed' -0.75
      ;;
  esac
}

apply

while true; do
  apply

  # Reapply on X input hierarchy changes, such as Bluetooth reconnects.
  timeout 300 xinput --test-xi2 --root 2>/dev/null | \
    while IFS= read -r line; do
      case "$line" in
        *HierarchyChanged*|*DeviceChanged*)
          apply
          ;;
      esac
    done
  sleep 1
done