Put suspend time on hold in script

I have some scripts that will fail if my computer goes into suspension.

Is there a bash method of putting suspension on hold while the script is running?

I tried systemd-inhibit test.sh and got
Failed to inhibit: No buffer space available

The command itself is in test.sh

This works but there is a potential problem. If I do a Ctrl C to stop it, the re-enabling of suspend is never reached.

# Stop computer from sleeping while timer is running

echo Computer will be suspended from sleeping while timer is running.
echo

echo fake | sudo -S systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

if [ $# -eq 1 ]
then
	DURATION="$1"
else
	read -r -p "Timer for how many minutes?( for fractional use decimal notation , 0.5==30s, 1.25==75s etc) : "  DURATION
	read -r -p "Enter text to display at the end of the timer : " n1
fi

# To re-enable the suspend and hibernation modes, run the command:
echo in | sudo -S systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

I found this.

#!/bin/bash

# trap ctrl-c and call ctrl_c()
trap ctrl_c INT

function ctrl_c() {
        echo "** Trapped CTRL-C"
}

for i in `seq 1 5`; do
    sleep 1
    echo -n "."
done