← paintstorm-distrobox-legacy

Paintstorm Distrobox Scripts merging

04a5c63d943b4a9eb341c2a7885150c5e50a6709 · ovidiucs · Jan 24, 2026 20:46

−2038 · 11 files changed

  • otd-diagnostics/README.md +0 −103
  • otd-diagnostics/TABLET-INPUT-GUIDE.md +0 −411
  • otd-diagnostics/check-which-device-used.sh +0 −223
  • otd-diagnostics/diagnose-pointer-freeze.sh +0 −164
  • otd-diagnostics/fix-pointer-freeze.sh +0 −163
  • otd-diagnostics/paintstorm-with-otd-wrapper.sh +0 −42
  • otd-diagnostics/test-paintstorm-relaunch-issue.sh +0 −222
  • otd-diagnostics/test-pressure-data.sh +0 −153
  • otd-diagnostics/test-which-device-active.sh +0 −152
  • otd-diagnostics/test-xsetwacom-compatibility.sh +0 −169
  • otd-diagnostics/track-device-state-changes.sh +0 −236
diff --git a/otd-diagnostics/README.md b/otd-diagnostics/README.md
deleted file mode 100644
index f82ad76..0000000
--- a/otd-diagnostics/README.md
+++ /dev/null
@@ -1,103 +0,0 @@
-# OpenTabletDriver Diagnostics
-
-⚠️ **WARNING: OpenTabletDriver does NOT work reliably with Paintstorm in distrobox**
-
-This folder contains diagnostic tools for troubleshooting OpenTabletDriver (OTD) issues. These tools were created during extensive testing of OTD integration.
-
-## Why This Folder Exists
-
-We attempted to make OpenTabletDriver work with Paintstorm in the distrobox container. After extensive testing and debugging, we discovered **multiple unfixable issues**:
-
-### Issue 1: Mouse Freezing
-**Symptom**: Mouse freezes while drawing with pen, unfreezes on Alt+Tab
-**Cause**: X11 pointer grabbing conflict between OTD virtual device and mouse
-**Scripts**: `diagnose-pointer-freeze.sh`, `fix-pointer-freeze.sh`
-
-### Issue 2: Second Launch Failure
-**Symptom**: Pressure works on first launch, fails on second launch
-**Cause**: Native devices get re-enabled between launches
-**Scripts**: `test-paintstorm-relaunch-issue.sh`, `track-device-state-changes.sh`
-
-### Issue 3: Device Recognition
-**Symptom**: Paintstorm doesn't recognize OTD virtual device for pressure
-**Cause**: Paintstorm expects specific device names/types
-**Scripts**: `check-which-device-used.sh`, `test-which-device-active.sh`, `test-pressure-data.sh`
-
-## Recommendation
-
-**Use native HID instead of OpenTabletDriver.**
-
-See `../native-hid-tablet-mapping/` for the working solution.
-
-Native HID provides:
-- ✅ Full pressure sensitivity (0-8191 levels)
-- ✅ Tilt support
-- ✅ Button mapping with xbindkeys
-- ✅ No mouse freezing
-- ✅ No second-launch issues
-- ✅ Reliable, stable operation
-
-## When to Use These Tools
-
-Only use these diagnostic tools if you:
-1. Want to understand why OTD doesn't work
-2. Are debugging OTD for other applications (not Paintstorm)
-3. Need to document OTD issues for bug reports
-
-**For Paintstorm use, go to `../native-hid-tablet-mapping/` instead.**
-
-## Diagnostic Tools
-
-### Device Detection & Testing
-- **`check-which-device-used.sh`** - Shows which device is active (native vs OTD virtual)
-- **`test-which-device-active.sh`** - Alternative device activity test
-- **`test-pressure-data.sh`** - Verify if OTD virtual device sends pressure data
-
-### Mouse/Pointer Issues
-- **`diagnose-pointer-freeze.sh`** - Diagnose mouse freezing issues
-- **`fix-pointer-freeze.sh`** - Interactive menu to fix pointer conflicts
-
-### Launch Issues
-- **`test-paintstorm-relaunch-issue.sh`** - Test for second-launch failures
-- **`track-device-state-changes.sh`** - Track xinput device state changes
-
-### Compatibility Testing
-- **`test-xsetwacom-compatibility.sh`** - Test if xsetwacom works with Huion
-
-### Wrappers & Guides
-- **`paintstorm-with-otd-wrapper.sh`** - Wrapper that ensures OTD config (doesn't fully fix issues)
-- **`TABLET-INPUT-GUIDE.md`** - Complete technical guide to OTD vs native HID
-
-## The Bottom Line
-
-After creating all these diagnostic tools and testing extensively:
-
-**OpenTabletDriver is NOT recommended for Paintstorm in distrobox.**
-
-The issues are fundamental to how X11, distrobox, and Paintstorm interact with input devices. No amount of configuration or scripting fully resolves them.
-
-**Use native HID** for a superior, hassle-free experience.
-
-## Technical Summary
-
-### Why OTD Fails
-
-1. **Device Grabbing**: OTD takes exclusive hidraw access, making native devices appear active but with no data
-2. **Application Recognition**: Paintstorm doesn't recognize OTD virtual devices as pressure-capable
-3. **State Persistence**: Device enable/disable states don't persist correctly across application launches
-4. **Pointer Conflicts**: X11 master pointer can't properly handle both mouse and OTD virtual device
-
-### Why Native HID Works
-
-1. **Direct HID Support**: Generic Linux HID driver provides full pressure and tilt
-2. **No Virtualization**: Applications see real hardware devices
-3. **Stable State**: No device swapping or enable/disable needed
-4. **Standard Protocol**: Uses standard X11 XInput2 protocol
-
-## Credits
-
-These diagnostics were created during an extensive effort to make OTD work with Paintstorm. While the effort was ultimately unsuccessful for this use case, the tools may be useful for understanding OTD behavior in other contexts.
-
-**For actual tablet usage with Paintstorm: Use native HID.**
-
-See: `../native-hid-tablet-mapping/`
diff --git a/otd-diagnostics/TABLET-INPUT-GUIDE.md b/otd-diagnostics/TABLET-INPUT-GUIDE.md
deleted file mode 100644
index fdae8a1..0000000
--- a/otd-diagnostics/TABLET-INPUT-GUIDE.md
+++ /dev/null
@@ -1,411 +0,0 @@
-# Tablet Input Device Guide - OTD vs Native HID
-
-## Understanding Your Tablet Setup
-
-Your diagnostic shows a **device conflict** between two input systems. This guide explains what's happening and how to fix it.
-
-## Current Situation
-
-You have discovered that:
-- ✅ **Without otd-daemon**: Pressure works perfectly
-- ❌ **With otd-daemon**: Pressure stops working
-
-### Why This Happens
-
-When you look at `xinput list`, you see TWO sets of tablet devices:
-
-```
-1. Native Huion Devices (from kernel HID driver):
-   - HUION Huion Tablet_G930L Pen stylus (id=11)
-   - HUION Huion Tablet_G930L Pen eraser (id=24)
-
-2. OpenTabletDriver Virtual Devices:
-   - OpenTabletDriver Virtual Artist Tablet stylus (id=25)
-   - OpenTabletDriver Virtual Artist Tablet eraser (id=27)
-```
-
-### The Conflict
-
-**Without OTD:**
-```
-Tablet → /dev/hidraw1-3 → Generic Linux HID driver → id=11 → Paintstorm ✓
-```
-
-**With OTD:**
-```
-Tablet → /dev/hidraw1-3 (OTD GRABS EXCLUSIVE ACCESS)
-                ↓
-         otd-daemon → id=25 (virtual device)
-                ↓
-         id=11 (DEAD - no data because OTD owns hidraw)
-                ↓
-         Paintstorm (still trying to read id=11) ✗
-```
-
-When OTD starts, it takes **exclusive control** of the hidraw devices. The native devices (id=11, id=24) remain visible in `xinput list` but **stop receiving data**. Paintstorm is still configured to read from id=11, which is why pressure breaks.
-
-## Solutions
-
-### Option 1: Use Native HID Support (Recommended if it works)
-
-**Pros:**
-- ✅ Already working perfectly
-- ✅ No configuration needed
-- ✅ Simpler setup
-- ✅ Pressure and tilt both work
-
-**Cons:**
-- ❌ No OTD-specific features (custom curves, remapping, etc.)
-- ❌ No GUI configuration (otd-gui)
-
-**How to use:**
-```bash
-# Stop OTD if running
-pkill otd-daemon
-
-# Prevent OTD from auto-starting (if it does)
-# Check your startup applications and disable OTD
-
-# Use Paintstorm normally - pressure will work
-~/paintstorm
-```
-
-### Option 2: Use OpenTabletDriver (if you need its features)
-
-**Pros:**
-- ✅ Custom pressure curves
-- ✅ Pen button remapping
-- ✅ Better tablet area configuration
-- ✅ GUI configuration (otd-gui)
-
-**Cons:**
-- ❌ Requires configuration
-- ❌ Application must use the virtual device
-- ❌ More complex setup
-
-**How to use:**
-
-#### Step 1: Configure Paintstorm to use OTD virtual device
-
-The issue is that Paintstorm is hardcoded or configured to use device id=11 (native Huion), but needs to use id=25 (OTD virtual device).
-
-Unfortunately, **Paintstorm Studio doesn't allow you to choose specific input devices** - it uses whatever X11 provides as the "core pointer" or first available tablet device.
-
-#### Step 2: Disable native Huion devices
-
-Make X11 ignore the native devices and only use OTD virtual devices:
-
-```bash
-# List current devices
-xinput list
-
-# Disable native Huion devices (when OTD is running)
-xinput disable "HUION Huion Tablet_G930L Pen stylus"
-xinput disable "HUION Huion Tablet_G930L Pen eraser"
-
-# Now only OTD virtual devices are active
-# Paintstorm should automatically use them
-```
-
-To make this permanent, create a script:
-
-```bash
-cat > ~/.config/autostart/disable-huion-native.desktop << 'EOF'
-[Desktop Entry]
-Type=Application
-Name=Disable Native Huion Devices
-Exec=sh -c "sleep 5 && xinput disable 'HUION Huion Tablet_G930L Pen stylus' && xinput disable 'HUION Huion Tablet_G930L Pen eraser'"
-Hidden=false
-NoDisplay=false
-X-GNOME-Autostart-enabled=true
-EOF
-```
-
-### Option 3: Hybrid Approach (Advanced)
-
-Only start OTD when you need its features:
-
-```bash
-# Create a wrapper script
-cat > ~/paintstorm-with-otd << 'EOF'
-#!/bin/bash
-# Start OTD
-otd-daemon &
-OTD_PID=$!
-sleep 2
-
-# Disable native devices
-xinput disable "HUION Huion Tablet_G930L Pen stylus" 2>/dev/null || true
-xinput disable "HUION Huion Tablet_G930L Pen eraser" 2>/dev/null || true
-
-# Run Paintstorm
-~/paintstorm
-
-# Cleanup: stop OTD when Paintstorm exits
-kill $OTD_PID 2>/dev/null || true
-EOF
-chmod +x ~/paintstorm-with-otd
-```
-
-Then use:
-- `~/paintstorm` - Native HID (simple, works)
-- `~/paintstorm-with-otd` - With OTD features
-
-## Which Device is Actually Sending Data?
-
-To verify which device is active, use this test:
-
-```bash
-# Monitor input events (move pen while this runs)
-xinput test "HUION Huion Tablet_G930L Pen stylus"
-
-# Or for OTD virtual device:
-xinput test "OpenTabletDriver Virtual Artist Tablet stylus"
-```
-
-If you see output like:
-```
-motion a[0]=123 a[1]=456 a[2]=4567 a[3]=5 a[4]=6
-```
-
-Where `a[2]` changes with pressure, that device is active.
-
-**Test both:**
-```bash
-# Test native device
-echo "Testing native Huion device (id=11)..."
-timeout 5 xinput test 11
-
-# Test OTD virtual device
-echo "Testing OTD virtual device (id=25)..."
-timeout 5 xinput test 25
-```
-
-Move your pen during each test. The one showing events is the active device.
-
-## Recommendation
-
-Based on your situation:
-
-### If you DON'T need OTD features:
-**Just use native HID support** (no otd-daemon):
-```bash
-pkill otd-daemon
-~/paintstorm  # Pressure works perfectly
-```
-
-This is simpler and already works.
-
-### If you DO need OTD features:
-**Disable native devices** when OTD is running:
-```bash
-otd-daemon &
-sleep 2
-xinput disable 11  # Native stylus
-xinput disable 24  # Native eraser
-~/paintstorm  # Now uses OTD virtual devices
-```
-
-## Technical Details
-
-### Why Both Devices Appear in xinput
-
-When you see both sets of devices in `xinput list` (with OTD running), it's misleading:
-
-- **Native devices (id=11, 24)**: Visible in xinput but **INACTIVE** (no data flow)
-- **Virtual devices (id=25, 27)**: Visible and **ACTIVE** (receiving OTD processed data)
-
-The native devices appear because:
-1. The kernel still detects the USB tablet
-2. The HID subsystem still creates input devices
-3. But OTD has grabbed `/dev/hidraw*` with exclusive access
-4. So the native devices get no data
-
-It's like having two phone lines but only one is connected.
-
-### Why wacom/hid_uclogic are Blacklisted
-
-Your `/etc/modprobe.d/99-opentabletdriver.conf` blacklists:
-- `wacom` - Wacom-specific kernel driver
-- `hid_uclogic` - Generic Chinese tablet driver (for Huion/XP-Pen/etc)
-
-This is correct for OTD because:
-1. Those drivers would conflict with OTD
-2. Generic HID support (not blacklisted) still works
-3. Generic HID provides basic pressure/tilt
-4. OTD provides advanced features
-
-You're using the **generic Linux HID driver** (not hid_uclogic), which is why pressure works without OTD.
-
-## Summary
-
-```
-┌─────────────────────────────────────────────────┐
-│ Without OTD (Current working state)             │
-├─────────────────────────────────────────────────┤
-│ Tablet → hidraw → Generic HID → id=11 →         │
-│ Paintstorm ✓ WORKS                              │
-└─────────────────────────────────────────────────┘
-
-┌─────────────────────────────────────────────────┐
-│ With OTD (Current broken state)                 │
-├─────────────────────────────────────────────────┤
-│ Tablet → hidraw → OTD → id=25                   │
-│                       ↘                          │
-│                         id=11 (dead)             │
-│                             ↓                    │
-│                         Paintstorm ✗ BROKEN     │
-└─────────────────────────────────────────────────┘
-
-┌─────────────────────────────────────────────────┐
-│ With OTD + disabled native (FIX)                │
-├─────────────────────────────────────────────────┤
-│ Tablet → hidraw → OTD → id=25 → Paintstorm      │
-│ (id=11 disabled via xinput)     ✓ WORKS         │
-└─────────────────────────────────────────────────┘
-```
-
-**Your choice:**
-- **Simple**: Don't use OTD, just use native HID (already works)
-- **Advanced**: Use OTD + disable native devices via xinput
-
-Choose based on whether you need OTD's features (custom curves, remapping, area config).
-
-## Known Issue: Mouse Freezing with OTD
-
-### Symptoms
-- Pen/tablet works correctly
-- Mouse freezes when you draw with the pen
-- Mouse unfreezes when you Alt+Tab or change window focus
-- This repeats every time you use the pen
-
-### Cause
-This is an X11 **pointer grabbing conflict**. When you use the pen:
-1. The tablet device grabs pointer focus
-2. X11 suppresses mouse events (thinking pen = exclusive input)
-3. Window focus change releases the grab
-4. This happens because X11 doesn't expect both devices active simultaneously
-
-### Quick Fixes
-
-#### Fix 1: Use the automated fix script
-```bash
-./fix-pointer-freeze.sh
-# Choose option 1: Disable all native Huion devices
-```
-
-#### Fix 2: Manual disable
-```bash
-# Disable native devices
-xinput disable 11  # Native stylus
-xinput disable 24  # Native eraser
-
-# Verify they're floating (disabled)
-xinput list | grep floating
-```
-
-#### Fix 3: Restart OTD daemon
-```bash
-pkill otd-daemon
-otd-daemon &
-sleep 2
-xinput disable 11
-xinput disable 24
-```
-
-#### Fix 4: Switch back to native HID
-If the freeze persists, just use native HID (it works perfectly):
-```bash
-pkill otd-daemon
-xinput enable 11
-xinput enable 24
-~/paintstorm  # Pressure works!
-```
-
-### Diagnostic Tool
-
-To diagnose the pointer freeze issue:
-```bash
-./diagnose-pointer-freeze.sh
-```
-
-This will show you:
-- Which devices are attached to the master pointer
-- Whether there are device conflicts
-- Current pointer grab status
-- Recommended fixes
-
-### Why This Happens
-
-X11 has a single "master pointer" that controls the cursor. When multiple pointer devices (mouse + tablet) are active:
-- Some applications grab the pointer exclusively when the pen is in use
-- This prevents the mouse from generating events
-- Releasing focus (Alt+Tab) releases the grab
-- This is a limitation of X11's input architecture
-
-### Permanent Solution
-
-If you need OTD and want to avoid this issue permanently:
-
-**Option A: Create a wrapper that ensures native devices stay disabled**
-```bash
-cat > ~/paintstorm-otd-fixed << 'EOF'
-#!/bin/bash
-# Ensure OTD is running
-if ! pgrep -f otd-daemon > /dev/null; then
-    otd-daemon &
-    sleep 2
-fi
-
-# Always disable native devices before launching
-xinput disable 11 2>/dev/null || true
-xinput disable 24 2>/dev/null || true
-
-# Launch Paintstorm
-~/paintstorm
-EOF
-
-chmod +x ~/paintstorm-otd-fixed
-```
-
-**Option B: Use native HID (recommended if you don't need OTD features)**
-```bash
-# Stop OTD permanently
-pkill otd-daemon
-
-# Don't start it on boot
-# Remove from startup applications if configured
-
-# Use Paintstorm with native HID
-~/paintstorm  # Works perfectly
-```
-
-### Technical Details
-
-The freeze happens because:
-1. X11 uses a "core pointer protocol" where one device controls the cursor
-2. When you have multiple pointer devices (mouse + tablet), X11 must decide which is active
-3. Applications can request "pointer grabs" for exclusive input
-4. Paintstorm (or X11) is grabbing the pointer when the pen is active
-5. This suppresses mouse events until the grab is released
-6. Alt+Tab changes window focus, which releases pointer grabs
-
-Modern Wayland compositors handle this better, but Paintstorm requires X11.
-
-## Choosing Your Configuration
-
-### Use Native HID If:
-- ✅ Pressure and tilt already work
-- ✅ You don't need custom pressure curves
-- ✅ You don't need pen button remapping
-- ✅ You want simple, trouble-free setup
-- ✅ You experience mouse freezing with OTD
-
-### Use OTD If:
-- ✅ You need custom pressure curves
-- ✅ You need pen button remapping
-- ✅ You need precise tablet area configuration
-- ✅ You're willing to disable native devices and troubleshoot pointer issues
-- ✅ You need features not available in native HID
-
-**Most users should use native HID** - it works out of the box with full pressure and tilt support.
diff --git a/otd-diagnostics/check-which-device-used.sh b/otd-diagnostics/check-which-device-used.sh
deleted file mode 100755
index ff25c39..0000000
--- a/otd-diagnostics/check-which-device-used.sh
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/bin/bash
-# Check which input device is actually receiving events
-# Usage: ./check-which-device-used.sh [--verbose]
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-BOLD='\033[1m'
-NC='\033[0m'
-
-VERBOSE=false
-if [[ "$1" == "--verbose" || "$1" == "-v" ]]; then
-    VERBOSE=true
-fi
-
-echo "=========================================="
-echo "Tablet Device Activity Test"
-echo "=========================================="
-echo ""
-
-# Get device information
-NATIVE_STYLUS=$(xinput list | grep -i "HUION.*Pen stylus" | grep -v "Virtual" | head -1)
-NATIVE_STYLUS_ID=$(echo "$NATIVE_STYLUS" | grep -o 'id=[0-9]*' | cut -d= -f2)
-NATIVE_STYLUS_NAME=$(echo "$NATIVE_STYLUS" | sed 's/.*↳ //' | sed 's/id=.*//' | xargs)
-
-VIRTUAL_STYLUS=$(xinput list | grep -i "OpenTabletDriver.*stylus" | head -1)
-VIRTUAL_STYLUS_ID=$(echo "$VIRTUAL_STYLUS" | grep -o 'id=[0-9]*' | cut -d= -f2)
-VIRTUAL_STYLUS_NAME=$(echo "$VIRTUAL_STYLUS" | sed 's/.*↳ //' | sed 's/id=.*//' | xargs)
-
-OTD_RUNNING=$(pgrep -f otd-daemon > /dev/null && echo "YES" || echo "NO")
-
-# Test devices
-echo "Testing devices (move your pen for 5 seconds)..."
-echo ""
-
-NATIVE_ACTIVE="N/A"
-NATIVE_EVENTS=0
-VIRTUAL_ACTIVE="N/A"
-VIRTUAL_EVENTS=0
-
-if [ -n "$NATIVE_STYLUS_ID" ]; then
-    echo -n "Testing native device... "
-    NATIVE_OUTPUT=$(timeout 5 xinput test "$NATIVE_STYLUS_ID" 2>&1)
-    NATIVE_EVENTS=$(echo "$NATIVE_OUTPUT" | grep -c "motion" || true)
-    NATIVE_EVENTS=${NATIVE_EVENTS:-0}
-
-    if [ "$NATIVE_EVENTS" -gt 0 ] 2>/dev/null; then
-        NATIVE_ACTIVE="ACTIVE"
-        echo -e "${GREEN}✓${NC}"
-    else
-        NATIVE_ACTIVE="INACTIVE"
-        echo -e "${RED}✗${NC}"
-    fi
-
-    if [ "$VERBOSE" = true ]; then
-        echo "  Raw output:"
-        echo "$NATIVE_OUTPUT" | head -10 | sed 's/^/    /'
-        echo ""
-    fi
-fi
-
-if [ -n "$VIRTUAL_STYLUS_ID" ]; then
-    echo -n "Testing OTD virtual device... "
-    VIRTUAL_OUTPUT=$(timeout 5 xinput test "$VIRTUAL_STYLUS_ID" 2>&1)
-    VIRTUAL_EVENTS=$(echo "$VIRTUAL_OUTPUT" | grep -c "motion" || true)
-    VIRTUAL_EVENTS=${VIRTUAL_EVENTS:-0}
-
-    if [ "$VIRTUAL_EVENTS" -gt 0 ] 2>/dev/null; then
-        VIRTUAL_ACTIVE="ACTIVE"
-        echo -e "${GREEN}✓${NC}"
-    else
-        VIRTUAL_ACTIVE="INACTIVE"
-        echo -e "${RED}✗${NC}"
-    fi
-
-    if [ "$VERBOSE" = true ]; then
-        echo "  Raw output:"
-        echo "$VIRTUAL_OUTPUT" | head -10 | sed 's/^/    /'
-        echo ""
-    fi
-fi
-
-echo ""
-echo "=========================================="
-echo "RESULTS"
-echo "=========================================="
-echo ""
-
-# Print table header
-printf "${BOLD}%-40s %-8s %-10s %-12s${NC}\n" "DEVICE" "ID" "STATUS" "EVENTS"
-printf "%-40s %-8s %-10s %-12s\n" "----------------------------------------" "--------" "----------" "------------"
-
-# Native device row
-if [ -n "$NATIVE_STYLUS_ID" ]; then
-    if [ "$NATIVE_ACTIVE" = "ACTIVE" ]; then
-        printf "${GREEN}%-40s %-8s %-10s %-12s${NC}\n" "${NATIVE_STYLUS_NAME:0:40}" "$NATIVE_STYLUS_ID" "$NATIVE_ACTIVE" "$NATIVE_EVENTS"
-    else
-        printf "${RED}%-40s %-8s %-10s %-12s${NC}\n" "${NATIVE_STYLUS_NAME:0:40}" "$NATIVE_STYLUS_ID" "$NATIVE_ACTIVE" "$NATIVE_EVENTS"
-    fi
-else
-    printf "${YELLOW}%-40s %-8s %-10s %-12s${NC}\n" "Native Huion Device" "NOT FOUND" "N/A" "N/A"
-fi
-
-# Virtual device row
-if [ -n "$VIRTUAL_STYLUS_ID" ]; then
-    if [ "$VIRTUAL_ACTIVE" = "ACTIVE" ]; then
-        printf "${GREEN}%-40s %-8s %-10s %-12s${NC}\n" "${VIRTUAL_STYLUS_NAME:0:40}" "$VIRTUAL_STYLUS_ID" "$VIRTUAL_ACTIVE" "$VIRTUAL_EVENTS"
-    else
-        printf "${RED}%-40s %-8s %-10s %-12s${NC}\n" "${VIRTUAL_STYLUS_NAME:0:40}" "$VIRTUAL_STYLUS_ID" "$VIRTUAL_ACTIVE" "$VIRTUAL_EVENTS"
-    fi
-else
-    printf "${YELLOW}%-40s %-8s %-10s %-12s${NC}\n" "OTD Virtual Device" "NOT FOUND" "N/A" "N/A"
-fi
-
-echo ""
-# If virtual device is active, OTD must be running even if pgrep doesn't find it
-if [ "$VIRTUAL_ACTIVE" = "ACTIVE" ] && [ "$OTD_RUNNING" = "NO" ]; then
-    OTD_RUNNING="YES (detected via virtual device)"
-fi
-printf "%-40s ${BOLD}%-8s${NC}\n" "otd-daemon status:" "$OTD_RUNNING"
-echo ""
-
-# Diagnosis
-echo "=========================================="
-echo "DIAGNOSIS"
-echo "=========================================="
-echo ""
-
-if [ "$NATIVE_ACTIVE" = "ACTIVE" ] && [ "$VIRTUAL_ACTIVE" != "ACTIVE" ]; then
-    echo -e "${GREEN}✓ Using Native Linux HID Driver${NC}"
-    echo ""
-    echo "Your tablet is working with the generic Linux HID driver."
-    echo "Paintstorm is reading from the native Huion device."
-    echo ""
-    echo -e "${BOLD}This is why pressure works WITHOUT otd-daemon.${NC}"
-    echo ""
-    echo "Recommendation:"
-    echo "  • If everything works, you don't need OTD"
-    echo "  • Only use OTD if you need custom curves, remapping, etc."
-    echo ""
-
-elif [ "$NATIVE_ACTIVE" != "ACTIVE" ] && [ "$VIRTUAL_ACTIVE" = "ACTIVE" ]; then
-    echo -e "${GREEN}✓ Using OpenTabletDriver Virtual Device${NC}"
-    echo ""
-    echo "OTD is running and has taken control of your tablet."
-    echo "The native device is inactive (OTD has exclusive hidraw access)."
-    echo ""
-    if [ -n "$NATIVE_STYLUS_ID" ]; then
-        echo -e "${YELLOW}⚠ PROBLEM:${NC} Native device still visible (id=$NATIVE_STYLUS_ID)"
-        echo "   Paintstorm might try to use it, causing pressure to fail."
-        echo ""
-        echo -e "${BOLD}Solution:${NC}"
-        echo "  xinput disable $NATIVE_STYLUS_ID"
-        echo "  xinput disable $(xinput list | grep -i "HUION.*Pen eraser" | grep -v "Virtual" | grep -o 'id=[0-9]*' | cut -d= -f2)"
-        echo ""
-        echo "This forces Paintstorm to use the OTD virtual device."
-    else
-        echo "Native device is properly disabled. Paintstorm should work."
-    fi
-    echo ""
-
-elif [ "$NATIVE_ACTIVE" = "ACTIVE" ] && [ "$VIRTUAL_ACTIVE" = "ACTIVE" ]; then
-    echo -e "${YELLOW}⚠ BOTH Devices Are Active (Unusual)${NC}"
-    echo ""
-    echo "This is unexpected. Normally OTD takes exclusive access"
-    echo "to hidraw devices, making the native device inactive."
-    echo ""
-    echo "Possible causes:"
-    echo "  • Multiple tablets connected"
-    echo "  • OTD not configured for this specific tablet"
-    echo "  • Unusual system configuration"
-    echo ""
-
-else
-    echo -e "${RED}✗ No Active Devices Detected${NC}"
-    echo ""
-    echo "Possible causes:"
-    echo "  • Tablet not connected"
-    echo "  • You didn't move the pen during the test"
-    echo "  • Permission issues"
-    echo ""
-    echo "Try:"
-    echo "  • Reconnect your tablet"
-    echo "  • Run this script again: $0 --verbose"
-    echo "  • Check permissions: ls -la /dev/hidraw*"
-    echo ""
-fi
-
-# Show which device Paintstorm is likely using
-echo "=========================================="
-echo "WHICH DEVICE DOES PAINTSTORM USE?"
-echo "=========================================="
-echo ""
-
-if [ "$NATIVE_ACTIVE" = "ACTIVE" ]; then
-    echo -e "Paintstorm is reading from: ${GREEN}${NATIVE_STYLUS_NAME}${NC} (id=$NATIVE_STYLUS_ID)"
-    echo ""
-    echo "This is the native Linux HID device."
-    if [ "$OTD_RUNNING" = "YES" ]; then
-        echo -e "${YELLOW}Note: OTD is running but Paintstorm is NOT using it!${NC}"
-        echo "      This might explain why OTD features don't work."
-    fi
-elif [ "$VIRTUAL_ACTIVE" = "ACTIVE" ]; then
-    echo -e "Paintstorm should be reading from: ${GREEN}${VIRTUAL_STYLUS_NAME}${NC} (id=$VIRTUAL_STYLUS_ID)"
-    echo ""
-    echo "This is the OTD virtual device."
-    if [ "$NATIVE_ACTIVE" = "INACTIVE" ]; then
-        echo "Native device is inactive, so Paintstorm has no choice."
-    else
-        echo -e "${YELLOW}Warning: Native device is still visible!${NC}"
-        echo "         Paintstorm might use that instead."
-    fi
-else
-    echo "Unable to determine which device Paintstorm uses."
-fi
-
-echo ""
-echo "=========================================="
-echo ""
-echo "Run with --verbose flag to see raw xinput output:"
-echo "  $0 --verbose"
-echo ""
diff --git a/otd-diagnostics/diagnose-pointer-freeze.sh b/otd-diagnostics/diagnose-pointer-freeze.sh
deleted file mode 100755
index 4ce1b23..0000000
--- a/otd-diagnostics/diagnose-pointer-freeze.sh
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/bin/bash
-# Diagnose and fix pointer device conflicts with OTD
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-BOLD='\033[1m'
-NC='\033[0m'
-
-echo "=========================================="
-echo "Pointer Device Conflict Diagnostic"
-echo "=========================================="
-echo ""
-
-echo "Current pointer devices:"
-echo ""
-xinput list | grep -E "(pointer|Virtual|HUION)" | nl
-
-echo ""
-echo "=========================================="
-echo "Device Roles"
-echo "=========================================="
-echo ""
-
-# Get master pointer info
-MASTER_POINTER=$(xinput list | grep "Virtual core pointer" | grep -o 'id=[0-9]*' | cut -d= -f2)
-echo "Master pointer device: id=$MASTER_POINTER"
-echo ""
-
-# Check what's attached to master pointer
-echo "Devices attached to master pointer:"
-xinput list | grep -A 20 "Virtual core pointer" | grep "↳" | grep -E "(pointer|stylus|eraser|mouse)" | sed 's/^/  /'
-
-echo ""
-echo "=========================================="
-echo "Checking for Conflicts"
-echo "=========================================="
-echo ""
-
-# Look for multiple active tablet devices
-NATIVE_COUNT=$(xinput list | grep -i "HUION" | grep -v "floating" | grep -v "OpenTabletDriver" | grep -E "(stylus|eraser)" | wc -l)
-VIRTUAL_COUNT=$(xinput list | grep -i "OpenTabletDriver" | grep -E "(stylus|eraser)" | wc -l)
-
-echo "Native Huion devices (active): $NATIVE_COUNT"
-echo "OTD virtual devices: $VIRTUAL_COUNT"
-echo ""
-
-if [ "$NATIVE_COUNT" -gt 0 ]; then
-    echo -e "${YELLOW}⚠ Native Huion devices are still attached to master pointer${NC}"
-    echo "  This can cause pointer grabbing issues"
-    echo ""
-    echo "Devices that should be disabled:"
-    xinput list | grep -i "HUION" | grep -v "floating" | grep -v "OpenTabletDriver" | sed 's/^/  /'
-    echo ""
-fi
-
-# Check for mouse devices
-MOUSE_COUNT=$(xinput list | grep -iE "(mouse|logitech|mx anywhere)" | grep "pointer" | wc -l)
-echo "Mouse devices detected: $MOUSE_COUNT"
-
-echo ""
-echo "=========================================="
-echo "Testing Pointer Grab Behavior"
-echo "=========================================="
-echo ""
-
-echo "This test will show if pointer events are being grabbed."
-echo "Move your mouse for 3 seconds..."
-echo ""
-
-MOUSE_ID=$(xinput list | grep -i "mouse" | grep "pointer" | head -1 | grep -o 'id=[0-9]*' | cut -d= -f2)
-if [ -n "$MOUSE_ID" ]; then
-    MOUSE_EVENTS=$(timeout 3 xinput test "$MOUSE_ID" 2>&1 | grep -c "motion" || true)
-    echo "Mouse events received: $MOUSE_EVENTS"
-
-    if [ "$MOUSE_EVENTS" -gt 0 ]; then
-        echo -e "${GREEN}✓ Mouse is working${NC}"
-    else
-        echo -e "${RED}✗ Mouse is not responding${NC}"
-    fi
-else
-    echo -e "${YELLOW}No mouse device found for testing${NC}"
-fi
-
-echo ""
-echo "=========================================="
-echo "DIAGNOSIS"
-echo "=========================================="
-echo ""
-
-if [ "$NATIVE_COUNT" -gt 0 ]; then
-    echo -e "${YELLOW}Issue: Native tablet devices still active${NC}"
-    echo ""
-    echo "When native devices are attached to the master pointer alongside"
-    echo "OTD virtual devices, X11 can get confused about pointer focus."
-    echo ""
-    echo "Solution: Disable native devices"
-    echo ""
-    xinput list | grep -i "HUION" | grep -v "floating" | grep -v "OpenTabletDriver" | while read line; do
-        ID=$(echo "$line" | grep -o 'id=[0-9]*' | cut -d= -f2)
-        NAME=$(echo "$line" | sed 's/.*↳ //' | sed 's/id=.*//' | xargs)
-        echo "  xinput disable $ID  # $NAME"
-    done
-    echo ""
-fi
-
-echo ""
-echo "=========================================="
-echo "Common Fixes for Pointer Freezing"
-echo "=========================================="
-echo ""
-
-echo "1. Ensure native devices are disabled (floating)"
-echo "   xinput list | grep floating"
-echo ""
-
-echo "2. Set OTD virtual device as the only active tablet"
-echo "   (Native devices should show [floating slave])"
-echo ""
-
-echo "3. Check if Paintstorm has tablet input settings"
-echo "   - Look for input device preferences"
-echo "   - Disable 'tablet mode' if it exists"
-echo "   - Try 'relative' instead of 'absolute' mode"
-echo ""
-
-echo "4. Restart X11 session (logout/login)"
-echo "   Sometimes X11 pointer state gets stuck"
-echo ""
-
-echo "5. Try disabling pen pressure in Paintstorm"
-echo "   Then re-enable it to reset the input handling"
-echo ""
-
-OTD_VID=$(xinput list | grep "OpenTabletDriver.*stylus" | grep -o 'id=[0-9]*' | cut -d= -f2 | head -1)
-if [ -n "$OTD_VID" ]; then
-    echo "6. Check OTD virtual device properties"
-    echo "   xinput list-props $OTD_VID | grep -i mode"
-    echo ""
-fi
-
-echo "=========================================="
-echo "Alternative: Use Native HID Instead"
-echo "=========================================="
-echo ""
-
-echo "If the pointer freeze persists with OTD, consider:"
-echo ""
-echo "1. Stop OTD completely:"
-echo "   pkill otd-daemon"
-echo ""
-echo "2. Re-enable native devices:"
-echo "   xinput enable 11"
-echo "   xinput enable 24"
-echo ""
-echo "3. Use Paintstorm with native HID support"
-echo "   (You mentioned pressure works without OTD)"
-echo ""
-echo "You only need OTD if you require:"
-echo "  - Custom pressure curves"
-echo "  - Pen button remapping"
-echo "  - Advanced area configuration"
-echo ""
diff --git a/otd-diagnostics/fix-pointer-freeze.sh b/otd-diagnostics/fix-pointer-freeze.sh
deleted file mode 100755
index c01621e..0000000
--- a/otd-diagnostics/fix-pointer-freeze.sh
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/bin/bash
-# Quick fixes for mouse freezing when using tablet with OTD
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-BOLD='\033[1m'
-NC='\033[0m'
-
-echo "=========================================="
-echo "Pointer Freeze Fix"
-echo "=========================================="
-echo ""
-
-echo "Choose a fix:"
-echo ""
-echo "1) Disable all native Huion devices (recommended first step)"
-echo "2) Restart X11 input subsystem (kills and restarts X11)"
-echo "3) Reset OTD (stop and restart otd-daemon)"
-echo "4) Switch to native HID (stop OTD, re-enable native devices)"
-echo "5) Show current device status"
-echo "6) Exit"
-echo ""
-read -p "Choice [1-6]: " choice
-
-case $choice in
-    1)
-        echo ""
-        echo "Disabling all native Huion devices..."
-
-        # Find and disable all Huion devices except OTD virtual ones
-        xinput list | grep -i "HUION" | grep -v "OpenTabletDriver" | while read line; do
-            ID=$(echo "$line" | grep -o 'id=[0-9]*' | cut -d= -f2)
-            NAME=$(echo "$line" | sed 's/.*↳ //' | sed 's/id=.*//' | xargs)
-
-            if [ -n "$ID" ]; then
-                xinput disable "$ID" 2>/dev/null
-                if [ $? -eq 0 ]; then
-                    echo -e "${GREEN}✓ Disabled: $NAME (id=$ID)${NC}"
-                else
-                    echo -e "${YELLOW}⚠ Already disabled or couldn't disable: $NAME${NC}"
-                fi
-            fi
-        done
-
-        echo ""
-        echo "Current status:"
-        xinput list | grep -i "HUION" | sed 's/^/  /'
-        echo ""
-        echo -e "${GREEN}Done!${NC} Try using Paintstorm now."
-        echo "If the mouse still freezes, try option 2 or 3."
-        ;;
-
-    2)
-        echo ""
-        echo -e "${YELLOW}Warning: This will restart your X11 session!${NC}"
-        echo "All applications will close. Make sure to save your work."
-        echo ""
-        read -p "Continue? [y/N]: " confirm
-
-        if [[ "$confirm" =~ ^[Yy]$ ]]; then
-            echo "Restarting X11..."
-            sudo systemctl restart display-manager
-        else
-            echo "Cancelled."
-        fi
-        ;;
-
-    3)
-        echo ""
-        echo "Restarting OpenTabletDriver..."
-
-        # Stop OTD
-        pkill -9 otd-daemon 2>/dev/null
-        pkill -9 otd 2>/dev/null
-        sleep 1
-
-        # Start OTD
-        otd-daemon &
-        OTD_PID=$!
-        sleep 2
-
-        # Verify it started
-        if ps -p $OTD_PID > /dev/null 2>&1; then
-            echo -e "${GREEN}✓ OTD restarted (PID: $OTD_PID)${NC}"
-
-            # Disable native devices again
-            echo ""
-            echo "Disabling native devices..."
-            xinput disable 11 2>/dev/null
-            xinput disable 24 2>/dev/null
-
-            echo ""
-            echo "Checking for OTD virtual devices..."
-            sleep 1
-            xinput list | grep -i "OpenTabletDriver"
-
-            echo ""
-            echo -e "${GREEN}Done!${NC} Try Paintstorm again."
-        else
-            echo -e "${RED}✗ Failed to start OTD${NC}"
-            echo "Try running: otd-daemon"
-        fi
-        ;;
-
-    4)
-        echo ""
-        echo "Switching to native HID support (stopping OTD)..."
-
-        # Stop OTD
-        pkill otd-daemon 2>/dev/null
-        pkill otd 2>/dev/null
-        sleep 1
-
-        # Re-enable native devices
-        echo "Re-enabling native Huion devices..."
-        xinput enable 11 2>/dev/null && echo -e "${GREEN}✓ Enabled stylus (id=11)${NC}"
-        xinput enable 24 2>/dev/null && echo -e "${GREEN}✓ Enabled eraser (id=24)${NC}"
-
-        echo ""
-        echo "Current status:"
-        xinput list | grep -i "HUION"
-
-        echo ""
-        echo -e "${GREEN}Done!${NC} You're now using native Linux HID support."
-        echo "Pressure and tilt should work in Paintstorm."
-        echo ""
-        echo "To go back to OTD, run: otd-daemon &"
-        ;;
-
-    5)
-        echo ""
-        echo "Current device status:"
-        echo ""
-        echo "OTD daemon:"
-        if pgrep -f otd-daemon > /dev/null; then
-            echo -e "  ${GREEN}RUNNING${NC}"
-        else
-            echo -e "  ${RED}NOT RUNNING${NC}"
-        fi
-
-        echo ""
-        echo "Input devices:"
-        xinput list | grep -E "(HUION|OpenTabletDriver|Virtual core pointer)" | sed 's/^/  /'
-
-        echo ""
-        echo "Disabled devices (floating):"
-        xinput list | grep "floating" | grep -i "HUION" | sed 's/^/  /'
-        ;;
-
-    6)
-        echo "Exiting."
-        exit 0
-        ;;
-
-    *)
-        echo "Invalid choice."
-        exit 1
-        ;;
-esac
-
-echo ""
diff --git a/otd-diagnostics/paintstorm-with-otd-wrapper.sh b/otd-diagnostics/paintstorm-with-otd-wrapper.sh
deleted file mode 100755
index 5d2b9cf..0000000
--- a/otd-diagnostics/paintstorm-with-otd-wrapper.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-# Paintstorm launcher wrapper that ensures OTD configuration stays correct
-# This fixes the "second launch doesn't work" issue
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-NC='\033[0m'
-
-# Ensure OTD is running
-if ! pgrep -f otd-daemon > /dev/null; then
-    echo -e "${YELLOW}Starting OpenTabletDriver...${NC}"
-    otd-daemon &
-    sleep 2
-fi
-
-# ALWAYS disable native devices before launch
-# This prevents them from interfering even if they got re-enabled
-echo -e "${BLUE}Configuring tablet devices...${NC}"
-xinput disable 11 2>/dev/null || true  # Native stylus
-xinput disable 24 2>/dev/null || true  # Native eraser
-
-# Verify OTD virtual device exists
-if ! xinput list | grep -q "OpenTabletDriver"; then
-    echo -e "${RED}ERROR: OTD virtual device not found!${NC}"
-    echo "OTD might not have detected your tablet."
-    echo "Try: otd detect"
-    exit 1
-fi
-
-# Show status
-echo -e "${GREEN}✓ Native devices disabled${NC}"
-echo -e "${GREEN}✓ OTD virtual device active${NC}"
-echo ""
-
-# Launch Paintstorm
-~/paintstorm "$@"
-
-# Note: We don't re-enable native devices after exit
-# If you want to use native HID, stop OTD first:
-# pkill otd-daemon && xinput enable 11 && xinput enable 24
diff --git a/otd-diagnostics/test-paintstorm-relaunch-issue.sh b/otd-diagnostics/test-paintstorm-relaunch-issue.sh
deleted file mode 100755
index 075be87..0000000
--- a/otd-diagnostics/test-paintstorm-relaunch-issue.sh
+++ /dev/null
@@ -1,222 +0,0 @@
-#!/bin/bash
-# Automated test to reproduce the second-launch issue
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-BOLD='\033[1m'
-NC='\033[0m'
-
-echo "=========================================="
-echo "Paintstorm Relaunch Issue Test"
-echo "=========================================="
-echo ""
-
-check_device_state() {
-    local when="$1"
-
-    echo -e "${BOLD}=== Device State: $when ===${NC}"
-
-    # Check OTD
-    if pgrep -f otd-daemon > /dev/null; then
-        echo -e "OTD daemon: ${GREEN}RUNNING${NC}"
-    else
-        echo -e "OTD daemon: ${RED}STOPPED${NC}"
-    fi
-
-    # Check native devices
-    echo ""
-    echo "Native devices:"
-    for id in 11 24; do
-        if xinput list | grep -q "id=$id"; then
-            state=$(xinput list | grep "id=$id")
-            if echo "$state" | grep -q "floating"; then
-                echo -e "  id=$id: ${GREEN}DISABLED (floating)${NC}"
-            else
-                echo -e "  id=$id: ${YELLOW}ENABLED (attached)${NC}"
-                echo "    $state"
-            fi
-        else
-            echo "  id=$id: NOT FOUND"
-        fi
-    done
-
-    # Check virtual devices
-    echo ""
-    echo "OTD virtual devices:"
-    if xinput list | grep -q "OpenTabletDriver"; then
-        xinput list | grep "OpenTabletDriver" | while read line; do
-            echo -e "  ${GREEN}$line${NC}"
-        done
-    else
-        echo -e "  ${RED}NOT FOUND${NC}"
-    fi
-
-    # Quick activity test
-    echo ""
-    echo -n "Quick activity test (move pen now, 2 seconds)... "
-
-    native_events=0
-    virtual_events=0
-
-    if xinput list | grep -q "id=11"; then
-        native_events=$(timeout 2 xinput test 11 2>&1 | grep -c "motion" || echo "0")
-    fi
-
-    virtual_id=$(xinput list | grep "OpenTabletDriver.*stylus" | head -1 | grep -o 'id=[0-9]*' | cut -d= -f2)
-    if [ -n "$virtual_id" ]; then
-        virtual_events=$(timeout 2 xinput test "$virtual_id" 2>&1 | grep -c "motion" || echo "0")
-    fi
-
-    echo "Done"
-    echo "  Native (id=11) events: $native_events"
-    echo "  Virtual (id=$virtual_id) events: $virtual_events"
-
-    if [ "$virtual_events" -gt 0 ]; then
-        echo -e "  ${GREEN}✓ Using OTD virtual device${NC}"
-    elif [ "$native_events" -gt 0 ]; then
-        echo -e "  ${YELLOW}⚠ Using native device (might be a problem)${NC}"
-    else
-        echo -e "  ${RED}✗ No activity detected${NC}"
-    fi
-
-    echo ""
-    echo "=========================================="
-    echo ""
-}
-
-echo "This script will help diagnose why Paintstorm works the first"
-echo "time you launch it but not the second time."
-echo ""
-echo "The test will:"
-echo "1. Check device state now"
-echo "2. Wait for you to launch Paintstorm (first time)"
-echo "3. Check device state after you close it"
-echo "4. Wait for you to launch Paintstorm (second time)"
-echo "5. Compare states to find what changed"
-echo ""
-read -p "Press Enter to start the test..."
-
-echo ""
-echo "=========================================="
-echo "Step 1: Initial State"
-echo "=========================================="
-echo ""
-
-check_device_state "Before first launch"
-
-echo ""
-echo "=========================================="
-echo "Step 2: First Launch"
-echo "=========================================="
-echo ""
-echo "Now launch Paintstorm and test that pressure works."
-echo "Then CLOSE Paintstorm and come back here."
-echo ""
-read -p "Press Enter after you've closed Paintstorm from first launch..."
-
-echo ""
-check_device_state "After first launch (closed)"
-
-# Save state for comparison
-native_state_after_first=$(xinput list | grep "id=11" | grep -o '\[.*\]')
-virtual_state_after_first=$(xinput list | grep "OpenTabletDriver.*stylus" | head -1 | grep -o '\[.*\]')
-
-echo ""
-echo "=========================================="
-echo "Step 3: Second Launch"
-echo "=========================================="
-echo ""
-echo "Now launch Paintstorm AGAIN (second time)."
-echo "Test if pressure works."
-echo "Then CLOSE Paintstorm and come back here."
-echo ""
-read -p "Press Enter after you've closed Paintstorm from second launch..."
-
-echo ""
-check_device_state "After second launch (closed)"
-
-# Save state for comparison
-native_state_after_second=$(xinput list | grep "id=11" | grep -o '\[.*\]')
-virtual_state_after_second=$(xinput list | grep "OpenTabletDriver.*stylus" | head -1 | grep -o '\[.*\]')
-
-echo ""
-echo "=========================================="
-echo "ANALYSIS"
-echo "=========================================="
-echo ""
-
-echo "Device state comparison:"
-echo ""
-printf "%-30s %-25s %-25s\n" "Device" "After 1st Launch" "After 2nd Launch"
-printf "%-30s %-25s %-25s\n" "------------------------------" "-------------------------" "-------------------------"
-printf "%-30s %-25s %-25s\n" "Native device (id=11)" "$native_state_after_first" "$native_state_after_second"
-printf "%-30s %-25s %-25s\n" "Virtual device" "$virtual_state_after_first" "$virtual_state_after_second"
-
-echo ""
-
-if [ "$native_state_after_first" != "$native_state_after_second" ]; then
-    echo -e "${YELLOW}⚠ PROBLEM DETECTED:${NC} Native device state changed!"
-    echo ""
-    echo "The native device state is different between the two launches."
-
-    if echo "$native_state_after_second" | grep -q "slave.*pointer"; then
-        echo ""
-        echo -e "${RED}✗ Native device got RE-ENABLED after first launch!${NC}"
-        echo ""
-        echo "This is the bug. Something is re-enabling the native device,"
-        echo "which causes Paintstorm to use it on the second launch."
-        echo "But the native device is DEAD (OTD has exclusive hidraw access),"
-        echo "so pressure doesn't work."
-        echo ""
-        echo "SOLUTION: Ensure native devices stay disabled"
-        echo ""
-        echo "Option A: Disable them before each launch:"
-        echo "  xinput disable 11 && xinput disable 24 && ~/paintstorm"
-        echo ""
-        echo "Option B: Use the wrapper script:"
-        echo "  ./fix-pointer-freeze.sh and create the wrapper"
-        echo ""
-        echo "Option C: Just use native HID (stop OTD):"
-        echo "  pkill otd-daemon"
-        echo "  xinput enable 11 && xinput enable 24"
-        echo "  ~/paintstorm"
-    fi
-else
-    echo -e "${GREEN}✓ Device states are consistent${NC}"
-    echo ""
-    echo "The native device state didn't change between launches."
-    echo "The problem might be something else."
-    echo ""
-    echo "Possible causes:"
-    echo "- Paintstorm is caching device preferences"
-    echo "- X11 input focus issues"
-    echo "- Application-level device selection"
-    echo ""
-    echo "Try: Clear Paintstorm's preferences/cache and test again"
-fi
-
-echo ""
-echo "=========================================="
-echo "NEXT STEPS"
-echo "=========================================="
-echo ""
-
-echo "1. Run this test again to confirm the behavior"
-echo ""
-echo "2. If native devices are being re-enabled:"
-echo "   Create a wrapper script that force-disables them:"
-echo ""
-echo "   cat > ~/paintstorm-safe << 'EOF'"
-echo "   #!/bin/bash"
-echo "   xinput disable 11 2>/dev/null || true"
-echo "   xinput disable 24 2>/dev/null || true"
-echo "   ~/paintstorm"
-echo "   EOF"
-echo "   chmod +x ~/paintstorm-safe"
-echo ""
-echo "3. Or just use native HID (simpler):"
-echo "   pkill otd-daemon"
-echo "   ~/paintstorm"
-echo ""
diff --git a/otd-diagnostics/test-pressure-data.sh b/otd-diagnostics/test-pressure-data.sh
deleted file mode 100755
index ea90084..0000000
--- a/otd-diagnostics/test-pressure-data.sh
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/bin/bash
-# Test if pressure data is actually being sent by the OTD virtual device
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-BOLD='\033[1m'
-NC='\033[0m'
-
-echo "=========================================="
-echo "Pressure Data Test"
-echo "=========================================="
-echo ""
-
-# Find OTD virtual device
-VIRTUAL_ID=$(xinput list | grep "OpenTabletDriver.*stylus" | head -1 | grep -o 'id=[0-9]*' | cut -d= -f2)
-
-if [ -z "$VIRTUAL_ID" ]; then
-    echo -e "${RED}ERROR: OTD virtual device not found${NC}"
-    echo ""
-    echo "Make sure otd-daemon is running:"
-    echo "  otd-daemon &"
-    exit 1
-fi
-
-echo -e "Testing device: ${BOLD}OpenTabletDriver Virtual Artist Tablet stylus${NC}"
-echo "Device ID: $VIRTUAL_ID"
-echo ""
-
-echo "Press your pen on the tablet with varying pressure for 10 seconds..."
-echo "Watch for lines with 'a[2]=' - this is the pressure value"
-echo ""
-echo "Expected pressure range: 0 (no pressure) to 8191 (max pressure)"
-echo ""
-echo "=========================================="
-echo "Starting test..."
-echo "=========================================="
-echo ""
-
-# Capture xinput test output
-OUTPUT=$(timeout 10 xinput test "$VIRTUAL_ID" 2>&1)
-
-# Check if we got any events
-if ! echo "$OUTPUT" | grep -q "motion"; then
-    echo -e "${RED}✗ NO EVENTS DETECTED${NC}"
-    echo ""
-    echo "The OTD virtual device is not receiving any input!"
-    echo ""
-    echo "Troubleshooting:"
-    echo "1. Make sure otd-daemon is running: pgrep -fa otd-daemon"
-    echo "2. Check if OTD detected your tablet: otd detect"
-    echo "3. Verify hidraw devices are accessible: ls -la /dev/hidraw*"
-    exit 1
-fi
-
-# Extract pressure values
-PRESSURE_VALUES=$(echo "$OUTPUT" | grep "motion" | grep -o 'a\[2\]=[0-9]*' | cut -d= -f2 | sort -n | uniq)
-
-if [ -z "$PRESSURE_VALUES" ]; then
-    echo -e "${RED}✗ NO PRESSURE DATA FOUND${NC}"
-    echo ""
-    echo "The device is sending motion events, but NO pressure data (a[2]=)!"
-    echo ""
-    echo "Sample output:"
-    echo "$OUTPUT" | head -10 | sed 's/^/  /'
-    echo ""
-    echo "This means:"
-    echo "- The OTD virtual device is working"
-    echo "- But it's not reporting pressure values"
-    echo "- This could be an OTD configuration issue"
-    echo ""
-    echo "Try:"
-    echo "1. Check OTD settings in otd-gui"
-    echo "2. Restart OTD: pkill otd-daemon && otd-daemon &"
-    echo "3. Use native HID instead (it has pressure)"
-    exit 1
-fi
-
-# Analyze pressure range
-MIN_PRESSURE=$(echo "$PRESSURE_VALUES" | head -1)
-MAX_PRESSURE=$(echo "$PRESSURE_VALUES" | tail -1)
-UNIQUE_VALUES=$(echo "$PRESSURE_VALUES" | wc -l)
-
-echo -e "${GREEN}✓ PRESSURE DATA DETECTED${NC}"
-echo ""
-echo "Pressure statistics:"
-echo "  Minimum pressure: $MIN_PRESSURE"
-echo "  Maximum pressure: $MAX_PRESSURE"
-echo "  Unique pressure levels: $UNIQUE_VALUES"
-echo ""
-
-if [ "$MAX_PRESSURE" -gt 1000 ]; then
-    echo -e "${GREEN}✓ Good pressure range (max > 1000)${NC}"
-    echo "  This indicates proper pressure sensitivity"
-else
-    echo -e "${YELLOW}⚠ Low maximum pressure ($MAX_PRESSURE)${NC}"
-    echo "  You might not have pressed hard enough during the test"
-    echo "  Or OTD might not be configured for full pressure range"
-fi
-
-echo ""
-echo "Sample events (showing pressure values):"
-echo "$OUTPUT" | grep "motion" | head -10 | grep --color=always 'a\[2\]=[0-9]*' | sed 's/^/  /'
-
-echo ""
-echo "=========================================="
-echo "CONCLUSION"
-echo "=========================================="
-echo ""
-
-if [ "$MAX_PRESSURE" -gt 100 ]; then
-    echo -e "${GREEN}✓ OTD virtual device IS sending pressure data${NC}"
-    echo ""
-    echo "The problem is NOT with OTD or the device."
-    echo "The issue is with Paintstorm."
-    echo ""
-    echo "Paintstorm is probably not using the OTD virtual device,"
-    echo "even though it's the only active tablet device."
-    echo ""
-    echo "Possible causes:"
-    echo "1. Paintstorm cached the device ID from a previous run"
-    echo "2. Paintstorm has specific device requirements"
-    echo "3. Paintstorm doesn't recognize the OTD virtual device"
-    echo ""
-    echo "Solutions to try:"
-    echo ""
-    echo "A) Clear Paintstorm's configuration:"
-    echo "   rm -rf ~/.config/Paintstorm"
-    echo "   rm -rf ~/.cache/Paintstorm"
-    echo ""
-    echo "B) Check Paintstorm's input settings:"
-    echo "   Look for tablet/input device settings in Paintstorm's preferences"
-    echo ""
-    echo "C) Use native HID (RECOMMENDED):"
-    echo "   pkill otd-daemon"
-    echo "   xinput enable 11 && xinput enable 24"
-    echo "   ~/paintstorm"
-    echo "   Pressure works perfectly with native HID!"
-else
-    echo -e "${YELLOW}⚠ Pressure data exists but range is limited${NC}"
-    echo ""
-    echo "The OTD virtual device is sending some pressure data,"
-    echo "but the range seems limited."
-    echo ""
-    echo "This could mean:"
-    echo "- You didn't press hard enough during the test"
-    echo "- OTD configuration issue"
-    echo ""
-    echo "Run this test again and press HARD on the tablet."
-fi
-
-echo ""
diff --git a/otd-diagnostics/test-which-device-active.sh b/otd-diagnostics/test-which-device-active.sh
deleted file mode 100755
index 3e378c0..0000000
--- a/otd-diagnostics/test-which-device-active.sh
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/bin/bash
-# Test which tablet device is actually receiving events
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-NC='\033[0m'
-
-echo "=========================================="
-echo "Tablet Device Activity Test"
-echo "=========================================="
-echo ""
-
-# Get device IDs
-NATIVE_STYLUS=$(xinput list | grep -i "HUION.*Pen stylus" | grep -v "Virtual" | grep -o 'id=[0-9]*' | cut -d= -f2)
-NATIVE_ERASER=$(xinput list | grep -i "HUION.*Pen eraser" | grep -v "Virtual" | grep -o 'id=[0-9]*' | cut -d= -f2)
-VIRTUAL_STYLUS=$(xinput list | grep -i "OpenTabletDriver.*stylus" | grep -o 'id=[0-9]*' | cut -d= -f2)
-VIRTUAL_ERASER=$(xinput list | grep -i "OpenTabletDriver.*eraser" | grep -o 'id=[0-9]*' | cut -d= -f2)
-
-echo "Detected devices:"
-if [ -n "$NATIVE_STYLUS" ]; then
-    echo -e "${BLUE}  Native Huion Stylus: id=$NATIVE_STYLUS${NC}"
-else
-    echo -e "${YELLOW}  Native Huion Stylus: NOT FOUND${NC}"
-fi
-
-if [ -n "$VIRTUAL_STYLUS" ]; then
-    echo -e "${BLUE}  OTD Virtual Stylus: id=$VIRTUAL_STYLUS${NC}"
-else
-    echo -e "${YELLOW}  OTD Virtual Stylus: NOT FOUND (otd-daemon not running?)${NC}"
-fi
-
-echo ""
-echo "=========================================="
-echo "Testing Native Huion Device"
-echo "=========================================="
-
-if [ -n "$NATIVE_STYLUS" ]; then
-    echo "Move your pen on the tablet for 5 seconds..."
-    echo ""
-
-    NATIVE_OUTPUT=$(timeout 5 xinput test "$NATIVE_STYLUS" 2>&1 | head -20)
-
-    if echo "$NATIVE_OUTPUT" | grep -q "motion"; then
-        echo -e "${GREEN}✓ Native device is ACTIVE${NC}"
-        echo "  Sample output:"
-        echo "$NATIVE_OUTPUT" | head -5 | sed 's/^/    /'
-        NATIVE_ACTIVE=true
-    else
-        echo -e "${RED}✗ Native device is INACTIVE (no events detected)${NC}"
-        NATIVE_ACTIVE=false
-    fi
-else
-    echo -e "${YELLOW}Skipping (device not found)${NC}"
-    NATIVE_ACTIVE=false
-fi
-
-echo ""
-echo "=========================================="
-echo "Testing OTD Virtual Device"
-echo "=========================================="
-
-if [ -n "$VIRTUAL_STYLUS" ]; then
-    echo "Move your pen on the tablet for 5 seconds..."
-    echo ""
-
-    VIRTUAL_OUTPUT=$(timeout 5 xinput test "$VIRTUAL_STYLUS" 2>&1 | head -20)
-
-    if echo "$VIRTUAL_OUTPUT" | grep -q "motion"; then
-        echo -e "${GREEN}✓ OTD virtual device is ACTIVE${NC}"
-        echo "  Sample output:"
-        echo "$VIRTUAL_OUTPUT" | head -5 | sed 's/^/    /'
-        VIRTUAL_ACTIVE=true
-    else
-        echo -e "${RED}✗ OTD virtual device is INACTIVE (no events detected)${NC}"
-        VIRTUAL_ACTIVE=false
-    fi
-else
-    echo -e "${YELLOW}Skipping (device not found - otd-daemon probably not running)${NC}"
-    VIRTUAL_ACTIVE=false
-fi
-
-echo ""
-echo "=========================================="
-echo "DIAGNOSIS"
-echo "=========================================="
-
-if [ "$NATIVE_ACTIVE" = true ] && [ "$VIRTUAL_ACTIVE" = false ]; then
-    echo -e "${GREEN}Result: Using NATIVE Huion HID driver${NC}"
-    echo ""
-    echo "This means:"
-    echo "  • otd-daemon is NOT running (or not working)"
-    echo "  • Generic Linux HID driver is handling your tablet"
-    echo "  • Paintstorm reads from: HUION Huion Tablet_G930L Pen stylus (id=$NATIVE_STYLUS)"
-    echo "  • This is why pressure works WITHOUT otd-daemon"
-    echo ""
-    echo "Recommendation:"
-    echo "  If pressure works, you don't need OTD unless you want its features"
-    echo "  (custom curves, remapping, etc.)"
-
-elif [ "$NATIVE_ACTIVE" = false ] && [ "$VIRTUAL_ACTIVE" = true ]; then
-    echo -e "${GREEN}Result: Using OpenTabletDriver virtual device${NC}"
-    echo ""
-    echo "This means:"
-    echo "  • otd-daemon IS running"
-    echo "  • OTD has exclusive control of hidraw devices"
-    echo "  • Native device (id=$NATIVE_STYLUS) is inactive"
-    echo "  • Paintstorm should read from: OpenTabletDriver Virtual Artist Tablet stylus (id=$VIRTUAL_STYLUS)"
-    echo ""
-    echo "If pressure doesn't work in Paintstorm:"
-    echo "  Paintstorm is probably still trying to use the native device (id=$NATIVE_STYLUS)"
-    echo "  which is now dead because OTD took over."
-    echo ""
-    echo "Solution:"
-    echo "  xinput disable $NATIVE_STYLUS"
-    echo "  This forces Paintstorm to use the OTD virtual device"
-
-elif [ "$NATIVE_ACTIVE" = true ] && [ "$VIRTUAL_ACTIVE" = true ]; then
-    echo -e "${YELLOW}Result: BOTH devices are active (unusual!)${NC}"
-    echo ""
-    echo "This is unexpected. Usually when OTD runs, it takes exclusive"
-    echo "access to hidraw and the native device stops working."
-    echo ""
-    echo "Possible causes:"
-    echo "  • OTD is running but not grabbing your specific tablet"
-    echo "  • Multiple tablets connected"
-    echo "  • OTD configuration issue"
-
-else
-    echo -e "${RED}Result: NO devices are active${NC}"
-    echo ""
-    echo "This means:"
-    echo "  • Your tablet might not be connected"
-    echo "  • Or you didn't move the pen during the tests"
-    echo ""
-    echo "Try running this script again and make sure to move the pen"
-    echo "when prompted."
-fi
-
-echo ""
-echo "=========================================="
-echo "Current OTD Status"
-echo "=========================================="
-
-if pgrep -x otd-daemon > /dev/null; then
-    echo -e "${GREEN}otd-daemon: RUNNING${NC}"
-else
-    echo -e "${YELLOW}otd-daemon: NOT RUNNING${NC}"
-fi
-
-echo ""
diff --git a/otd-diagnostics/test-xsetwacom-compatibility.sh b/otd-diagnostics/test-xsetwacom-compatibility.sh
deleted file mode 100755
index 6567ce4..0000000
--- a/otd-diagnostics/test-xsetwacom-compatibility.sh
+++ /dev/null
@@ -1,169 +0,0 @@
-#!/bin/bash
-# Test if xsetwacom can actually configure Huion tablet buttons
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-BOLD='\033[1m'
-NC='\033[0m'
-
-echo "=========================================="
-echo "xsetwacom Compatibility Test"
-echo "=========================================="
-echo ""
-
-# Check if xsetwacom is installed
-if ! command -v xsetwacom &> /dev/null; then
-    echo -e "${YELLOW}xsetwacom is not installed${NC}"
-    echo ""
-    echo "Install with:"
-    echo "  sudo pacman -S xf86-input-wacom"
-    echo ""
-    read -p "Install now? [y/N]: " install
-    if [[ "$install" =~ ^[Yy]$ ]]; then
-        sudo pacman -S xf86-input-wacom
-    else
-        exit 1
-    fi
-fi
-
-echo "Testing xsetwacom with your Huion tablet..."
-echo ""
-
-# List devices
-echo -e "${BOLD}1. Listing devices with xsetwacom:${NC}"
-echo ""
-xsetwacom --list devices
-echo ""
-
-# Try to get all properties from native Huion device
-DEVICE_NAME="HUION Huion Tablet_G930L Pen stylus"
-
-echo "=========================================="
-echo -e "${BOLD}2. Testing property access:${NC}"
-echo ""
-echo "Attempting to get all properties from:"
-echo "  $DEVICE_NAME"
-echo ""
-
-if xsetwacom --get "$DEVICE_NAME" all 2>&1 | grep -q "error\|Error\|cannot"; then
-    echo -e "${RED}✗ FAILED: xsetwacom cannot access device properties${NC}"
-    echo ""
-    echo "Error output:"
-    xsetwacom --get "$DEVICE_NAME" all 2>&1 | head -20
-    echo ""
-    echo "This confirms that xsetwacom CANNOT configure your Huion tablet."
-    echo ""
-    XSETWACOM_WORKS=false
-else
-    echo -e "${GREEN}✓ SUCCESS: xsetwacom can read properties!${NC}"
-    echo ""
-    echo "Properties:"
-    xsetwacom --get "$DEVICE_NAME" all | head -20
-    echo ""
-    XSETWACOM_WORKS=true
-fi
-
-echo ""
-echo "=========================================="
-echo -e "${BOLD}3. Testing button configuration:${NC}"
-echo ""
-
-if [ "$XSETWACOM_WORKS" = true ]; then
-    echo "Attempting to set Button 2 to 'key ctrl z'..."
-    echo ""
-
-    if xsetwacom --set "$DEVICE_NAME" Button 2 "key ctrl z" 2>&1 | grep -q "error\|Error\|cannot"; then
-        echo -e "${RED}✗ FAILED: Cannot set button mapping${NC}"
-        echo ""
-        xsetwacom --set "$DEVICE_NAME" Button 2 "key ctrl z" 2>&1
-        echo ""
-        BUTTON_MAPPING_WORKS=false
-    else
-        echo -e "${GREEN}✓ SUCCESS: Button mapping set!${NC}"
-        echo ""
-        echo "Verify it worked:"
-        xsetwacom --get "$DEVICE_NAME" Button 2
-        echo ""
-        BUTTON_MAPPING_WORKS=true
-    fi
-else
-    echo "Skipping button test since property access failed."
-    BUTTON_MAPPING_WORKS=false
-fi
-
-echo ""
-echo "=========================================="
-echo "RESULTS"
-echo "=========================================="
-echo ""
-
-if [ "$XSETWACOM_WORKS" = true ] && [ "$BUTTON_MAPPING_WORKS" = true ]; then
-    echo -e "${GREEN}✓✓✓ EXCELLENT NEWS! ✓✓✓${NC}"
-    echo ""
-    echo "xsetwacom CAN configure your Huion tablet!"
-    echo ""
-    echo "This means you can use xsetwacom to:"
-    echo "  - Map pen buttons to keyboard shortcuts"
-    echo "  - Configure pressure curves"
-    echo "  - Set tablet area"
-    echo "  - All without needing OpenTabletDriver!"
-    echo ""
-    echo "You do NOT need OTD if xsetwacom works."
-    echo ""
-    echo "Next steps:"
-    echo "  1. Map your buttons:"
-    echo "     xsetwacom --set \"$DEVICE_NAME\" Button 2 \"key ctrl z\""
-    echo "     xsetwacom --set \"$DEVICE_NAME\" Button 3 \"key e\""
-    echo ""
-    echo "  2. Make mappings permanent:"
-    echo "     Create a startup script or use ~/.xinitrc"
-    echo ""
-    echo "  3. See all options:"
-    echo "     xsetwacom --list parameters"
-    echo ""
-else
-    echo -e "${RED}✗ xsetwacom CANNOT configure your Huion tablet${NC}"
-    echo ""
-    echo "Reasons:"
-    echo "  - Huion tablets require wacom kernel driver for xsetwacom"
-    echo "  - Your system uses generic HID driver instead"
-    echo "  - wacom driver is blacklisted for OTD compatibility"
-    echo ""
-    echo "Alternatives for button mapping:"
-    echo ""
-    echo "1. xbindkeys + xdotool (RECOMMENDED)"
-    echo "   - Works with any device"
-    echo "   - Very flexible"
-    echo "   - Run: ./configure-tablet-buttons.sh"
-    echo ""
-    echo "2. OpenTabletDriver"
-    echo "   - Has built-in button mapping via otd-gui"
-    echo "   - But you've had issues with it"
-    echo ""
-    echo "3. Enable hid_uclogic driver (experimental)"
-    echo "   - Remove wacom/hid_uclogic blacklist"
-    echo "   - Might work with xsetwacom"
-    echo "   - But will break OTD if you ever want to use it"
-    echo ""
-fi
-
-echo ""
-echo "=========================================="
-echo "Technical Details"
-echo "=========================================="
-echo ""
-
-echo "Kernel driver in use:"
-udevadm info /dev/input/event* 2>/dev/null | grep -A 10 "HUION" | grep "DRIVER" | head -1
-echo ""
-
-echo "Modprobe blacklist:"
-if [ -f /etc/modprobe.d/99-opentabletdriver.conf ]; then
-    cat /etc/modprobe.d/99-opentabletdriver.conf
-else
-    echo "No OTD blacklist found"
-fi
-
-echo ""
diff --git a/otd-diagnostics/track-device-state-changes.sh b/otd-diagnostics/track-device-state-changes.sh
deleted file mode 100755
index a07ae2d..0000000
--- a/otd-diagnostics/track-device-state-changes.sh
+++ /dev/null
@@ -1,236 +0,0 @@
-#!/bin/bash
-# Track device state changes before/after launching Paintstorm
-
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-BOLD='\033[1m'
-NC='\033[0m'
-
-SNAPSHOT_DIR="/tmp/device-snapshots"
-mkdir -p "$SNAPSHOT_DIR"
-
-take_snapshot() {
-    local label="$1"
-    local timestamp=$(date +%s)
-    local file="$SNAPSHOT_DIR/${label}_${timestamp}.txt"
-
-    echo "=== Device Snapshot: $label ===" > "$file"
-    echo "Time: $(date)" >> "$file"
-    echo "" >> "$file"
-
-    echo ">>> xinput list" >> "$file"
-    xinput list >> "$file" 2>&1
-    echo "" >> "$file"
-
-    echo ">>> xinput list (devices only)" >> "$file"
-    xinput list | grep -E "(HUION|OpenTabletDriver|Virtual core pointer|pointer|stylus|eraser)" >> "$file" 2>&1
-    echo "" >> "$file"
-
-    echo ">>> Disabled devices (floating)" >> "$file"
-    xinput list | grep "floating" >> "$file" 2>&1
-    echo "" >> "$file"
-
-    echo ">>> OTD daemon status" >> "$file"
-    pgrep -fa otd-daemon >> "$file" 2>&1 || echo "Not running" >> "$file"
-    echo "" >> "$file"
-
-    echo ">>> Native device states" >> "$file"
-    for id in 11 24; do
-        if xinput list | grep -q "id=$id"; then
-            state=$(xinput list | grep "id=$id" | grep -o '\[.*\]')
-            name=$(xinput list | grep "id=$id" | sed 's/.*↳ //' | sed 's/id=.*//' | xargs)
-            echo "  id=$id ($name): $state" >> "$file"
-        fi
-    done
-    echo "" >> "$file"
-
-    echo ">>> Virtual device states" >> "$file"
-    xinput list | grep "OpenTabletDriver" | while read line; do
-        id=$(echo "$line" | grep -o 'id=[0-9]*' | cut -d= -f2)
-        state=$(echo "$line" | grep -o '\[.*\]')
-        name=$(echo "$line" | sed 's/.*↳ //' | sed 's/id=.*//' | xargs)
-        echo "  id=$id ($name): $state" >> "$file"
-    done >> "$file" 2>&1
-    echo "" >> "$file"
-
-    # Test which devices are active
-    echo ">>> Testing native device (id=11) for 2 seconds" >> "$file"
-    if xinput list | grep -q "id=11"; then
-        native_events=$(timeout 2 xinput test 11 2>&1 | grep -c "motion" || echo "0")
-        echo "  Events detected: $native_events" >> "$file"
-    else
-        echo "  Device not found" >> "$file"
-    fi
-    echo "" >> "$file"
-
-    echo ">>> Testing OTD virtual device for 2 seconds" >> "$file"
-    virtual_id=$(xinput list | grep "OpenTabletDriver.*stylus" | head -1 | grep -o 'id=[0-9]*' | cut -d= -f2)
-    if [ -n "$virtual_id" ]; then
-        virtual_events=$(timeout 2 xinput test "$virtual_id" 2>&1 | grep -c "motion" || echo "0")
-        echo "  Virtual device id=$virtual_id" >> "$file"
-        echo "  Events detected: $virtual_events" >> "$file"
-    else
-        echo "  Device not found" >> "$file"
-    fi
-
-    echo -e "${GREEN}✓ Snapshot saved: $file${NC}"
-    echo "$file"
-}
-
-compare_snapshots() {
-    echo ""
-    echo "=========================================="
-    echo "Comparing Snapshots"
-    echo "=========================================="
-    echo ""
-
-    local files=($(ls -t "$SNAPSHOT_DIR"/*.txt 2>/dev/null))
-
-    if [ ${#files[@]} -lt 2 ]; then
-        echo -e "${YELLOW}Need at least 2 snapshots to compare${NC}"
-        return
-    fi
-
-    echo "Latest snapshots:"
-    for i in "${!files[@]}"; do
-        basename="${files[$i]##*/}"
-        label=$(echo "$basename" | sed 's/_[0-9]*\.txt//')
-        timestamp=$(stat -c %y "${files[$i]}" | cut -d' ' -f1-2 | cut -d. -f1)
-        echo "  [$i] $label - $timestamp"
-    done
-    echo ""
-
-    read -p "Compare which two? (e.g., 0 1): " idx1 idx2
-
-    if [ -f "${files[$idx1]}" ] && [ -f "${files[$idx2]}" ]; then
-        echo ""
-        echo "Differences between snapshots:"
-        echo ""
-        diff -u "${files[$idx1]}" "${files[$idx2]}" || true
-    else
-        echo -e "${RED}Invalid selection${NC}"
-    fi
-}
-
-show_all_snapshots() {
-    echo ""
-    echo "=========================================="
-    echo "All Snapshots"
-    echo "=========================================="
-    echo ""
-
-    local files=($(ls -t "$SNAPSHOT_DIR"/*.txt 2>/dev/null))
-
-    if [ ${#files[@]} -eq 0 ]; then
-        echo -e "${YELLOW}No snapshots found${NC}"
-        return
-    fi
-
-    for file in "${files[@]}"; do
-        basename="${file##*/}"
-        label=$(echo "$basename" | sed 's/_[0-9]*\.txt//')
-        timestamp=$(stat -c %y "$file" | cut -d' ' -f1-2 | cut -d. -f1)
-
-        echo -e "${BOLD}--- $label ($timestamp) ---${NC}"
-
-        # Show key info
-        echo "OTD: $(grep -A 1 "OTD daemon status" "$file" | tail -1)"
-        echo "Native id=11: $(grep "id=11" "$file" | grep -o '\[.*\]' | head -1)"
-        echo "Native id=24: $(grep "id=24" "$file" | grep -o '\[.*\]' | head -1)"
-
-        virtual_line=$(grep "OpenTabletDriver.*stylus" "$file" | head -1)
-        if [ -n "$virtual_line" ]; then
-            virtual_state=$(echo "$virtual_line" | grep -o '\[.*\]')
-            echo "Virtual device: $virtual_state"
-        else
-            echo "Virtual device: NOT FOUND"
-        fi
-
-        echo ""
-    done
-}
-
-echo "=========================================="
-echo "Device State Tracker"
-echo "=========================================="
-echo ""
-echo "This tool tracks xinput device states to diagnose"
-echo "why Paintstorm works the first time but not the second."
-echo ""
-echo "What to do:"
-echo "1) Take snapshot: Before starting OTD"
-echo "2) Start OTD, take snapshot: After OTD starts"
-echo "3) Take snapshot: After disabling native devices"
-echo "4) Launch Paintstorm (1st time), take snapshot: After first launch"
-echo "5) Close Paintstorm, take snapshot: After closing"
-echo "6) Launch Paintstorm (2nd time), take snapshot: After second launch"
-echo "7) Compare snapshots to see what changed"
-echo ""
-echo "=========================================="
-echo ""
-
-echo "Choose an action:"
-echo ""
-echo "1) Take snapshot (with label)"
-echo "2) Quick snapshot (auto-label with current state)"
-echo "3) Show all snapshots"
-echo "4) Compare two snapshots"
-echo "5) Clear all snapshots"
-echo "6) Exit"
-echo ""
-read -p "Choice [1-6]: " choice
-
-case $choice in
-    1)
-        echo ""
-        read -p "Enter label for this snapshot: " label
-        label=$(echo "$label" | tr ' ' '_')
-        take_snapshot "$label"
-        ;;
-
-    2)
-        echo ""
-        # Auto-detect state
-        otd_running=$(pgrep -f otd-daemon > /dev/null && echo "otd_running" || echo "otd_stopped")
-        native_disabled=$(xinput list | grep "id=11" | grep -q "floating" && echo "native_disabled" || echo "native_enabled")
-
-        auto_label="${otd_running}_${native_disabled}"
-        echo "Auto-detected state: $auto_label"
-        take_snapshot "$auto_label"
-        ;;
-
-    3)
-        show_all_snapshots
-        ;;
-
-    4)
-        compare_snapshots
-        ;;
-
-    5)
-        echo ""
-        read -p "Delete all snapshots? [y/N]: " confirm
-        if [[ "$confirm" =~ ^[Yy]$ ]]; then
-            rm -f "$SNAPSHOT_DIR"/*.txt
-            echo -e "${GREEN}All snapshots cleared${NC}"
-        else
-            echo "Cancelled"
-        fi
-        ;;
-
-    6)
-        echo "Exiting."
-        exit 0
-        ;;
-
-    *)
-        echo "Invalid choice"
-        exit 1
-        ;;
-esac
-
-echo ""
-echo "Snapshots are stored in: $SNAPSHOT_DIR"
-echo ""