you need ground.
you need accessory-switched power. not dome light power, not door switch power.
when the truck is on, you'll have power to the mirror.
there are two sensors in the mirror, one on the front (facing the front of the truck) and one on the mirror face (facing the back of the truck); when more light is sensed rearward than forward and the truck is running or the key is in the "ACC" position, the mirror dims.