Modafinil is a drug developed for the treatment of narcolepsy. ( a pathological condition characterized by excessive sleep) and obstructive sleep apnea. Modafinil is generally considered to be well tolerated, but in rare cases can cause a headache and restlessness.