diff --git a/desktop b/desktop index 14adf10..2343665 100644 --- a/desktop +++ b/desktop @@ -65,3 +65,4 @@ xclip xsel linneighborhood mktemp +gparted diff --git a/internal/rootfs/opt/retrodebian/xorg/autoconfig.sh b/internal/rootfs/opt/retrodebian/xorg/autoconfig.sh index c4b3c2a..021a514 100644 --- a/internal/rootfs/opt/retrodebian/xorg/autoconfig.sh +++ b/internal/rootfs/opt/retrodebian/xorg/autoconfig.sh @@ -29,7 +29,6 @@ logger -t retrodebian-xorg-autoconfig " Vendor : $PCI_VENDOR_NAME [$PCI_VENDOR logger -t retrodebian-xorg-autoconfig " Device : $PCI_DEVICE_NAME [$PCI_DEVICE_ID]" logger -t retrodebian-xorg-autoconfig " BusID : $XORG_BUSID" -MATCHED=0 ROOT_DIR="/opt/retrodebian/xorg" XORG_FILE_BASENAME="xorg.conf" @@ -38,6 +37,8 @@ TMP_XORG_FILE_PATH="$(mktemp)" cp "${ROOT_DIR}/${TEMPLATE_XORG_FILE}" "${TMP_XORG_FILE_PATH}" +MATCHED=0 + for module in "${ROOT_DIR}/video-detect.d/"*.sh; do [ -f "$module" ] || continue @@ -68,6 +69,28 @@ sed -i \ [ "$MATCHED" -eq 1 ] || exit 2 +MATCHED=0 + +for module in "${ROOT_DIR}/mouse-detect.d/"*.sh; do + [ -f "$module" ] || continue + + logger -t retrodebian-xorg-autoconfig "Trying module: $module" + + if "$module" "${TMP_XORG_FILE_PATH}" + then + logger -t retrodebian-xorg-autoconfig "Matched module: $module" + MATCHED=1 + break + else + rc=$? + if [ "$rc" -ne 1 ]; then + logger -p daemon.err -t retrodebian-xorg-autoconfig "ERROR: module failed: $module" + fi + fi +done + +[ "$MATCHED" -eq 1 ] || exit 2 + cp -f "${TMP_XORG_FILE_PATH}" "$DEST_XORG_CONF" rm -f "${TMP_XORG_FILE_PATH}" diff --git a/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/01000-mouse-qemu-tablet.sh b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/01000-mouse-qemu-tablet.sh new file mode 100644 index 0000000..510ae89 --- /dev/null +++ b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/01000-mouse-qemu-tablet.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# 01000-mouse-qemu-tablet.sh +# Prefer QEMU USB Tablet when present + +XORG_CONF="$1" + +[ -n "$XORG_CONF" ] || exit 2 +[ -f "$XORG_CONF" ] || exit 2 +[ -r /proc/bus/input/devices ] || exit 1 + +EVENT_DEV="$(awk ' +BEGIN { RS=""; FS="\n" } +$0 ~ /QEMU USB Tablet/ { + for (i = 1; i <= NF; i++) { + if ($i ~ /^H: Handlers=/ && match($i, /event[0-9]+/)) { + print "/dev/input/" substr($i, RSTART, RLENGTH) + exit + } + } +}' /proc/bus/input/devices)" + +[ -n "$EVENT_DEV" ] || exit 1 +[ -e "$EVENT_DEV" ] || exit 1 + +logger -t retrodebian-xorg-autoconfig "Configuring QEMU tablet mouse: $EVENT_DEV" + +sed -i \ + -e "s|{InputDeviceDriver}|evdev|g" \ + -e "s|{InputDeviceDevice}|$EVENT_DEV|g" \ + -e "s|{InputDeviceProtocol}|auto|g" \ + "$XORG_CONF" || exit 2 + +exit 0 \ No newline at end of file diff --git a/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/02000-mouse-wacom.sh b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/02000-mouse-wacom.sh new file mode 100644 index 0000000..cfc5c46 --- /dev/null +++ b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/02000-mouse-wacom.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# 02000-mouse-wacom.sh +# Prefer wacom for explicit Wacom devices + +XORG_CONF="$1" + +[ -n "$XORG_CONF" ] || exit 2 +[ -f "$XORG_CONF" ] || exit 2 +[ -r /proc/bus/input/devices ] || exit 1 + +EVENT_DEV="$(awk ' +BEGIN { RS=""; FS="\n" } +$0 ~ /Wacom/ { + for (i = 1; i <= NF; i++) { + if ($i ~ /^H: Handlers=/ && match($i, /event[0-9]+/)) { + print "/dev/input/" substr($i, RSTART, RLENGTH) + exit + } + } +}' /proc/bus/input/devices)" + +[ -n "$EVENT_DEV" ] || exit 1 +[ -e "$EVENT_DEV" ] || exit 1 + +logger -t retrodebian-xorg-autoconfig "Configuring Wacom pointer: $EVENT_DEV" + +sed -i \ + -e "s|{InputDeviceDriver}|wacom|g" \ + -e "s|{InputDeviceDevice}|$EVENT_DEV|g" \ + -e "s|{InputDeviceProtocol}|auto|g" \ + "$XORG_CONF" || exit 2 + +exit 0 \ No newline at end of file diff --git a/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/03000-mouse-synaptics.sh b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/03000-mouse-synaptics.sh new file mode 100644 index 0000000..b0c5c01 --- /dev/null +++ b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/03000-mouse-synaptics.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# 03000-mouse-synaptics.sh +# Prefer synaptics for obvious touchpads + +XORG_CONF="$1" + +[ -n "$XORG_CONF" ] || exit 2 +[ -f "$XORG_CONF" ] || exit 2 +[ -r /proc/bus/input/devices ] || exit 1 + +EVENT_DEV="$(awk ' +BEGIN { RS=""; FS="\n" } +$0 ~ /SynPS\/2/ || $0 ~ /TouchPad/ || $0 ~ /Touchpad/ || $0 ~ /ALPS/ || $0 ~ /Synaptics/ { + for (i = 1; i <= NF; i++) { + if ($i ~ /^H: Handlers=/ && match($i, /event[0-9]+/)) { + print "/dev/input/" substr($i, RSTART, RLENGTH) + exit + } + } +}' /proc/bus/input/devices)" + +[ -n "$EVENT_DEV" ] || exit 1 +[ -e "$EVENT_DEV" ] || exit 1 + +logger -t retrodebian-xorg-autoconfig "Configuring Synaptics touchpad: $EVENT_DEV" + +sed -i \ + -e "s|{InputDeviceDriver}|synaptics|g" \ + -e "s|{InputDeviceDevice}|$EVENT_DEV|g" \ + -e "s|{InputDeviceProtocol}|auto-dev|g" \ + "$XORG_CONF" || exit 2 + +exit 0 \ No newline at end of file diff --git a/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/09900-mouse-proc-handler.sh b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/09900-mouse-proc-handler.sh new file mode 100644 index 0000000..42697d7 --- /dev/null +++ b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/09900-mouse-proc-handler.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# 09900-mouse-proc-handler.sh +# prefer a direct /dev/input/mouseN handler over /dev/input/mice + +XORG_CONF="$1" + +[ -n "$XORG_CONF" ] || exit 2 +[ -f "$XORG_CONF" ] || exit 2 +[ -r /proc/bus/input/devices ] || exit 1 + +MOUSE_DEV="$(awk ' +BEGIN { RS=""; FS="\n" } +{ + for (i = 1; i <= NF; i++) { + if ($i ~ /^H: Handlers=/ && match($i, /mouse[0-9]+/)) { + print "/dev/input/" substr($i, RSTART, RLENGTH) + exit + } + } +}' /proc/bus/input/devices)" + +[ -n "$MOUSE_DEV" ] || exit 1 +[ -e "$MOUSE_DEV" ] || exit 1 + +logger -t retrodebian-xorg-autoconfig "Configuring direct mouse handler fallback: $MOUSE_DEV" + +sed -i \ + -e "s|{InputDeviceDriver}|mouse|g" \ + -e "s|{InputDeviceDevice}|$MOUSE_DEV|g" \ + -e "s|{InputDeviceProtocol}|ImPS/2|g" \ + "$XORG_CONF" || exit 2 + +exit 0 \ No newline at end of file diff --git a/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/99999-mouse-fallback.sh b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/99999-mouse-fallback.sh new file mode 100644 index 0000000..f42fbaf --- /dev/null +++ b/internal/rootfs/opt/retrodebian/xorg/mouse-detect.d/99999-mouse-fallback.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# 99999-mouse-fallback.sh +# ultimate fallback + +XORG_CONF="$1" + +[ -n "$XORG_CONF" ] || exit 2 +[ -f "$XORG_CONF" ] || exit 2 + +logger -t retrodebian-xorg-autoconfig "Configuring ultimate Mouse fallback" + +sed -i \ + -e "s|{InputDeviceDriver}|mouse|g" \ + -e "s|{InputDeviceDevice}|/dev/input/mice|g" \ + -e "s|{InputDeviceProtocol}|auto|g" \ + "$XORG_CONF" || exit 2 + +exit 0 \ No newline at end of file diff --git a/internal/rootfs/opt/retrodebian/xorg/xorg.conf.template b/internal/rootfs/opt/retrodebian/xorg/xorg.conf.template index a7a3ef8..4f57561 100644 --- a/internal/rootfs/opt/retrodebian/xorg/xorg.conf.template +++ b/internal/rootfs/opt/retrodebian/xorg/xorg.conf.template @@ -47,10 +47,10 @@ EndSection Section "InputDevice" #__TAG__AUTOCONFIG_INPUTDEVICE_MOUSE__START__ Identifier "Configured Mouse" - Driver "mouse" + Driver "{InputDeviceDriver}" Option "CorePointer" - Option "Device" "/dev/input/mice" - Option "Protocol" "ImPS/2" + Option "Device" "{InputDeviceDevice}" + Option "Protocol" "{InputDeviceProtocol}" Option "Emulate3Buttons" "true" #__TAG__AUTOCONFIG_INPUTDEVICE_MOUSE__END__ EndSection diff --git a/zzz-config-live.sh b/zzz-config-live.sh index b3bebb6..7ae9a94 100644 --- a/zzz-config-live.sh +++ b/zzz-config-live.sh @@ -42,6 +42,7 @@ update-rc.d retrodebian-fluxbox-watch-menu defaults chmod +r,ug+xw,o-w /opt/retrodebian/xorg/autoconfig.sh chmod +r,ug+xw,o-w /opt/retrodebian/xorg/video-detect.d/*.sh +chmod +r,ug+xw,o-w /opt/retrodebian/xorg/mouse-detect.d/*.sh chmod +r,ug+xw,o-w /etc/init.d/retrodebian-xorg-autoconfig update-rc.d retrodebian-xorg-autoconfig defaults