Yes, I was prescribed it for a supposed autoimmune sleep disorder similar to narcolepsy but without cataplexy. I would point out this has some very very nasty possible side effects such as psychosis and worse, even if rare - including your skin falling off!!! Just read the side effects listed on the leaflet and google what some of them mean.
It helped keep me awake but to be honest it did not cause me to be more functional overall. I used to have sleep attacks all day and major drowsiness like I had been given a sedative. but my brain would sometimes wake up for a few hours here and there especially in the evening in which I could get some work done etc. However, on modafinil, although I stopped physically falling asleep on my desk, it felt like I was on speed and found it hard to concentrate or focus my brain for the entire day meaning I could get even less done and didn't get the few hours per day I felt relatively okay. I refused to take it any longer a month later as the results and side affects were just not worth it or balanced by any benefit. They have no idea why it does what it does as was an accidental finding which messes around with neurotransmitters and I just don't trust things like this as also long term safety/effects have not yet been determined
If you haven't tried it, I would highly recommend a gluten free diet as this solved the problem within a couple of months and can now stay fully awake all day. I still get tired but it's a more normal tired. Otherwise keep trying to find the root cause of why it is happening.
Obviously, it's down to you whether you want to give it a go but this was just my experience or thoughts on it