Remove the loop and sleep from the script you created so it just runs and exits.
Then create a file at /etc/systemd/system/battery-alarm.service
with the following:
[Unit]
Description="Sound alarm when battery is low"
[Service]
ExecStart=/usr/local/bin/battery-alarm.sh # point this to your script
Then create a file at /etc/systemd/system/battery-alarm.timer
with the following:
[Unit]
Description="Run battery-alarm.service every 2 mins"
[Timer]
OnUnitActiveSec=2m
Unit=battery-alarm.service
[Install]
WantedBy=multi-user.target
Then sudo systemctl enable --now helloworld.timer
to start and enable the timer on boot.
This will be a little more robust then your current script. It works without the user needing to log in. And there is nothing to get killed so will always trigger. The current script will just silently stop working if it ever gets killed or crashes.
The problem with bash scripts is they tend to explode in unexpected ways when thing don’t go as intended. This could be one of the command you run returning some expected or not output which might work now but might not in the future. Best to program bash defensively.