I do as much as possible to make the situation surrounding my unmotivating work pleasant. I choose one of my favorite songs and put it on repeat and listen to it over and over (the repetition of it makes it both less distracting and more calming), but I turn it off if it's starting to distract me such that I am not making enough progress on my work. I often make a cup of hot chocolate, or buy it if I am in the library. I also bring candy, crackers, strawberries, or something else that I really like to eat, so that I'm not getting hungry while I'm working, and again, to make the situation as pleasant as possible. I take breaks regularly, but I try to keep them to 15-20 minutes for every hour or so that I work. If I'm studying very difficult material, though, I may take as much as an hour off, but then I've usually focused for two to three hours (and typically, the more difficult stuff is more motivating for me, so I take fewer breaks anyway).
On my break, I might go online or complete a sudoku puzzle, call a friend, or go grab a meal from somewhere (man, this post makes it sound like I"m constantly eating! Haha, you all must think I'm obese!--actually I'm a pretty average weight for my height). A lot of times, I'll try to find something that'll make me laugh--I might find an online episode of a half hour show and watch that (because without commercials, it's actually only 20-25 minutes).