Mapping keyboard with xmodmap and xcape on startup

This works great when I do it in terminal, but I keep getting issues when I try to automate it on startup. I’ve added modifications to the .Xmodmap file and I run xcape scripts in .xprofile. Should I be doing this differently?

My .Xmodmap

keycode 248 = Tab
keycode 23 = ISO_Level3_Shift

(I’m mapping Tab to an undefined key and AltGr to Tab)

My .xpofile

#!/bin/bash
xcape -e 'Control_L=BackSpace'
xcape -e 'ISO_Level3_Shift=Tab'

(Control becomes backspace when tapped, and AltGr (Tab) becomes Tab when tapped)

The issue is that when I run it on startup, it doesn’t recognize xcape -e 'ISO_Level3_Shift=Tab' and I can’t use Tab on my keyboard. Previously I had put the entire thing as a Desktop entry, but I had a different issue: the AltGr wouldn’t work on startup. What’s the proper way to do a startup script so that I can modify my keyboard without issues? Sorry, I’m new at Linux.