Not iMac specific, but if your focus issues are similar to mine maybe some of the typical ADHD hacks might help. I think a lot of other folks I know (especially SWEs) that I know do things like this, but everyone has their own system that kind of works for them.

- Get rid of as many of the notifications as you can. Quit or log out of desktop email, discord, messages, whatever. Stuff shouldn't intrude when you're trying to focus. The relationship I try to have with social media is that I check it, it shouldn't check me.

- Instead of cutting distractions completely out of my life, I set aside specific times and places for them. I usually browse forums and things for about 30 minutes while I sip coffee in the morning, and then I'm done until just before bed. I find that making that place means I don't really get the urge to check the forums intruding into my workday. Sometimes if there's high drama or if I'm having a really pleasant interaction it might intrude, but I try to keep that confined to lunch.

- When I'm at work, I check Outlook near the bottom of each hour to see if there's anything I need to deal with, and when I'm done I close the program. This frequency works for me because nobody typically emails me about something that needs to happen asap, your mileage might vary. I usually leave a single, less-distracting "work channel" open. In my case, that's Zoom. If someone needs to message me on this, it's a work thing and it's not really a "distraction" to me. Nobody really messages me for fun on it, anyway.

- At home, when I'm working on classwork using my own computer, I just "get rid of" everything. Shut off all the desktop notifiers. Since Chrome's logged in to all my gmail/twitter/whatever accounts, I switch to Firefox to get stuff done. I haven't put the Bitwarden add-on to Firefox, so it's just mildly more difficult to log in and get distracted. While the barrier isn't really that much higher, it's just enough that I have to think twice before letting myself get sidetracked. Opening reddit and finding myself logged out is enough to remind me that I did this on purpose, and taking any more steps to pursue that distraction just feels like losing which is usually enough to dissuade me. I think there's "focus" software you can use to enforce your rules if you need a higher barrier?

- I do Pomodoro splits when I have trouble motivating myself to focus. It's easier to make a small promise to try for 25 minutes than it is to make the large promise to focus for a few hours. A lot of the time I find that it just takes getting started to actually get interested, and then I don't need the crutch to keep going. I use a physical timer for this because it's less to fiddle with on my computer i.e. alt-tabbing, using the computer at all if I'm trying to read a textbook, etc.

- I try not to put my phone on the desk when I'm working & I don't wear a smartwatch. I gave the smartwatch thing a shot a while back since people were saying they were less distracting than a phone but I found the notifications really intrusive and distracting. The phone's usually in my pocket on do not disturb at work, with a few specific people who I usually do want to talk to allowed through. I'm okay with getting a little distracted if my girlfriend texts me at work.