#!/usr/bin/env /lib/runit/invoke-run
#Copyright: 2023 Friedhelm Mehnert <friedhelm@friedhelms.net>
#           2026 Aitor <aitor@genuen.org>
#License: GPL-2.0+
#Comment: CFG parsing is from Debian's /etc/init.d/gpm

CFG=/etc/gpm.conf
cmdln=

if [ -f $CFG ]; then
  . $CFG
  if [ -n "$device" ]; then cmdln="$cmdln -m $device"; fi
  if [ -n "$type" ]; then cmdln="$cmdln -t $type"; fi
  if [ -n "$responsiveness" ]; then cmdln="$cmdln -r $responsiveness"; fi
  if [ -n "$sample_rate" ]; then cmdln="$cmdln -s $sample_rate"; fi
  if [ -n "$repeat_type" ] && [ "$repeat_type" != "none" ]; then
    cmdln="$cmdln -R$repeat_type"
  fi
  if [ -n "$append" ]; then cmdln="$cmdln $append"; fi
  if [ -n "$device2" ] && [ -n "$type2" ] ; then
    cmdln="$cmdln -M -m $device2 -t $type2"
  fi
fi

exec >/dev/null
exec 2>/dev/null
exec ##bin## -D ${cmdln:- -m /dev/input/mice -t exps2}
