Well, God gave us the gift of language, and it’s not exactly using His gift to His glory to be swearing, is it? More like abusing it. So I reckon for the most part it would be sinfulm like abusing the gifts of food, alcohol, sex or what have you.
Certainly the hitting your thumb means it would only be a venial sin at most. My own view is that unless you’re taking the name of Our Lord or Our Lady - or some other holy person or object - in vain as a curseword, or calling upon Him to d**n someone or something, it’s probably not a mortal sin under any circumstances.
A highly undesirable behaviour though - time to bring out the ol’ swear jar.