Depending on how the desktop is encoded (sometimes it's a video encoded to a gif), you may get artifacts etc. that make every frame different. But if that's not the case, and the snapshot of each frame is pretty much 1:1 on what's on the desktop, you can use Imagemagick to remove duplicate frames
https://www.imagemagick.org/Usage/anim_opt/#removedups
And right above this paragraph is a dope technique to use overlays and a non-dispose of frames to make the gif only change which pixels are being updated (like a video format I guess).
This might sound pretty complex, and sure, That's fair, we are coming up on 30 years since an update to the format. People just generally use videos these days for desktop recording since they're more suited for the job, at a even lower filesize