I was able to convert to this habit during my later years in college (my first two years in college consisted of laziness, video games, girl-chasing, and not so much studying) and when I headed into my professional career. I don't know if this works for everyone so feel free to ignore my advice or only use parts of it. Oddly enough, I've never used meditation even though it's been made available to me.
The main idea is to build up a self-image of being someone with a lot of focus over a long period of time by using short-term hacks (like "close all other applications") over time until you have a track record of being someone with a lot of focus and you and everyone else believes you have a lot of focus. This eventually becomes self-reinforcing because then you begin to naturally do things that stay on track rather than allowing yourself to become distracted. Like Nietzsche said, "there are no actors, only actions."
- So first, don't dismiss hacks like the one you describe above. Keeping a small bag of these and employing them faithfully will keep you on track and help build the image of having focus.
- Develop a habit of getting enough sleep each night. Sacrifice other activities in order to go to bed on time and manage your daytime schedule so that you can sleep as much as you need. 8 hours is good. Spend money on a high-quality mattress and very comfortable sheets. This is a very worthwhile one-time capital investment because you spend 30% of your lifetime here. Being sleepy makes you easily distracted and makes it more difficult to pay attention to topics for long periods of time (you may start to fall asleep and need to stimulate yourself awake by distracting yourself).
- Only work on a couple big things in your life at once. If you care about a lot of things, decide which 2 or 3 things you really really care about and then start ignoring the rest. This may involve ignoring certain long-time hobbies or even relationships, though remember that you are making the choices yourself (I mention that so that you don't grieve for the loss of those things, and also remember that you can reverse those decisions). Exceptional focus does not come without sacrifice.
- Exceptional focus does not mean that you are able to work during all your waking hours. During your "downtime" (time when you are not being productive but also not sleeping), don't try to work on lower-priority projects. Instead, make sure you are goofing off. The most focused people maintain focus over long periods of time (months, years) rather than working obsessively on something over entire days (which is likely to lead to burnout), so make sure your daily schedule involves breaks where you deliberately don't do anything productive. The idea here is to not fatigue your mind with focus, but to continually "re-attract" it back to the thing you want to focus on.
- Lastly, orient your thinking towards the notion of completion or goals. Whenever you are embarking on something, make sure you have a notion of the end goal you are trying to achieve, and drive primarily towards achieving that goal. Don't worry if the goals aren't exactly right; the idea is to reach them, and if they don't turn out to be exactly what you needed, you can just set new ones. The reason here is that high focus without goals is just obsession, but if you drive towards specific goals with a lot of focus, you will get things done, which allows you to "let up" on focusing on that goal and refocus on the next one. The ultimate effect is that you'll become a person who can focus steadily on achieving goal after goal without getting bored or distracted because you know that "soon" you'll reach your next goal and be able to work on the next thing (i.e. it's subverting your "distraction" tendency into being a "drive towards achievement" tendency). From the outside (and thus, when you look back on your life), it will appear as though you have a lot of focus on one overarching meta-goal that you are able to continually sustain over months and years. Only you will know that the secret is breaking it up into many little interesting and novel sub-goals!