Q:

Detect change on D- D+ lines

How can i detect change  on D- and D+ (puling one or both of them high) USB lines from Linux environment? 

A:

After attaching 1k5 pull-up resistor from 3.3V to D+/D- unknown/unrecognized USB high/low speed device would show up. You can check for this device with e.g. lsusb.
Much riskier method: most USB hosts should detect excessive current from USB power line. The problem is some other motherboards may not have overcurrent protection at all or it may not work correctly.
Other than that STM32F042F4/F6 in TSSOP20 package costs less than $3 ($1 in volume), does not require crystal and would be much more flexible.

