Simple but bold: Only use your computer for work. Real work. The work of making something.
Have a second device, perhaps an iPad, and use it for games, web commenting, online shopping, networking… anything that doesn’t directly create valued output (no need to have an argument here about which is which, which is work and which is not… draw a line, any line, and separate the two of them. If you don’t like the results from that line, draw a new line).
Now, when you pick up the iPad, you can say to yourself, “break time.” And if you find yourself taking a lot of that break time, you’ve just learned something important.