whim (n.)
1640s, "play on words, pun," shortened from whimwham "fanciful object" (q.v.). Meaning "caprice, fancy, sudden turn or inclination of the mind" first recorded 1690s, probably a shortened form of whimsy.