1. to wake up; to awake; to perk up; to snap out (of a day dream, etc.)
それで気づいたら目が覚めたんです。And then, before I knew it, I woke up.
2. to awaken (to the truth, etc.); to come to a realization; to come to one's senses
失敗して、やっと目が覚めた。It took failing for me to finally come to my senses.