For instance, if you are studying very hard for your coming entrance exam, when you look up and find your cat yawning, it would make you feel something, right? That’s the nuance of these lines, I guess.

EDIT: 「俺の上で」literally means the cat's position, which means the top of the TV is 'higher' than the guy. And it conveys some 'humor' like the cat is looking down the guy as if it were trying to say his 'tribulation' is nothing.

ギリギリ alone describes the emotional or physical “state” of the speaker. And, つもり refers to his “thought”; how he sees himself (even if it is untrue).
Here’s an example for you.
彼女は美人のつもりでいる。
(She sees herself as being beautiful.)
So, the interpretation of the line would be;ギリギリ（＝極限）の（状態である）（と自分では思っていた）つもりの（＝が、もしかしたらそれは単なる思い込みに過ぎなかったのかもしれない）俺の上（の方）で、テレビの上（に乗った）猫があくびしてる