Commands failing in script in systemd

I am having trouble with stopping the screensaver.
I know that ‘xset s off’ works in the terminal or a script.
I have been able to insert a script with that command in the startup apps list and works fine for booting.
However, the screensave returns after a period of suspend.
I have seen examples of scripts that can be inserted in /usr/lib/systemd/system-sleep that can be executed on entry to and exit from suspend.

This is what I have been trying:

#!/bin/sh
#
case $1 in
    (pre) echo "$(date) - We are suspending." >> /home/frank/Documents/screensave.txt ;;
    (post | *) sleep 20s
        xset s off
         screen=""
         screen=$(xset q | awk -F ' ' '$1 == "timeout:" {print $2}')
         echo "$(date) - Screensave timeout: $screen" >> /home/frank/Documents/screensave.txt ;;
esac

This script works fine if launched from file manager, terminal or shortcut. It is made executable.
When the computer returns from suspend the 'xset s off" fails as well as the ‘screen=$(xset q…’. The text file receives the echo line with a blank for $screen and the screensave timeout: is still at 600 instead of 0.
Why does this not work executing from systemd and how can I fix it.


Moderator edit: In the future, please use proper formatting: [HowTo] Post command output and file content as formatted text

What is the desired end result?

Usually, the screen saver can be controlled from the settings in the desktop environment that you use (whatever that is - you didn’t say
presumably Xfce4, from your profile).

… not system wide - rather a per user setting …

You also didn’t tell how you tried to do it via systemd, how you integrated your script.

… what is it that you want to achieve?
Perhaps the way you approach it is not how it’s done …?

The desired end result is to have no screensaver. Now it comes on as default with a 5 min delay.
There is no screensaver setting in the Settings Manager. The only thing I can find is under Power Manager/Display Manger on/off, Blank After and Put to Sleep After.
In the past I thought that if Display Manager is set to OFF, then the other settings don’t matter. After your comment, maybe not. I set them all to zero times.

I need to see the result. It takes a long time for the computer being on standby to revert to the default. I need to wait for that and come back with result after that.

I just had the computer in suspend for over 4 hours.
After this time it should come back with the default settings.

I am now totally embarrassed to have to admit that I did all the work looking for the systemd approach when there was a GUI (a little misleading though) that address the screensave situation. With Display Power Management being turned off, the settings under it were still active (that I missed).

Thank you Nachlese for giving me nudge to look into the GUI in more detail.

As for the systemd entry, I just created a text file ‘screensave’ with the contents shown above and placed it in system-sleep folder (already there) under the systemd folder.
This script does actually run, I know because the echo statements are redirected into a text file screensave.txt. This text file contains the redirected texts proving that the script does execute. The ‘case’ command also functions correctly. What I didn’t and don’t understand is why some commands are executed while others do not.

I know for a fact that there is.
Two places:
personal → screen saver
and
hardware → power manager

just noticed your second post after I wrote this

I am running Manjaro Xfce.
It does not have a Screen Saver section in the Settings Manager in the Personal section or anywhere else.
It does have a Power Manager in the Hardware section as I stated before.