Script to shutdown

Is there a way to create a script in bash, to shutdown at a certain percentage? I’ve looked it up many times but most results point to windows. Thanks!

I’m assuming that you want your laptop shutdown when battery reach a low level. Check this old answer, it could be useful yet:

I don’t know which DE you are using, but in xfce you can set it in the power manager settings.

Ah, sorry about that I should have been more specific. Currently I am using both budgie and i3wm. What I mean is how to go about having a script, unexclusive to the DE/wm, since I would be able to have it in both in the DE and the i3wm.
Budgies options are very odd in that there is no option for to shutdown at a battery%.