Ryan and Debi & Toren

NoMachine Freezing on Xubuntu 22.04

I have a headless fileserver that runs XFCE (Xubuntu). I recently reformatted the operating system (transferring my files in a ZFS raid to the new operating system rather seamlessly). But the software I use within my local network to access the fileserver, NoMachine, started having problems. Basically, I could access my machine, but the NoMachine interface would freeze up after about 5 minutes of inactivity.

My initial thought was, as it turns out, the correct one, but something about XFCE’s current setup prevented it from working. So, the longer version…

My initial thought was that this had to do with the power management settings of my XFCE machine. I thought it may be that when the screensaver turns on or when the machine is told to go to sleep, that is making it so NoMachine freezes up. To fix this, I changed the Power Manager settings using the System Settings interface

Here is where you change the settings:

As you can see, I had switched the settings in this dialog so the screen should never go blank, the display should never go to sleep, and the display should never shut off. Yet, even after changing those settings, after 5 minutes, my NoMachine interface would freeze up and become useless until I (a) restarted the computer or (b) restarted the lightdm screen manager using the following command in the console via SSH:

systemctl restart lightdm

That code would restart the window manager, which would unfreeze the desktop, and I could then use it until it would freeze up again.

Of course, I also turned off the screensaver just to make sure that wasn’t the problem either:

Here is the settings box showing that it was off:

Despite using the systems settings dialog boxes to make it so the display never went to sleep, I was getting this same issue.

I was genuinely baffled and couldn’t find anyone else struggling with this specific issue online. So, I went to NoMachine’s forums and posted about the problem. The folks there helped point me in the right direction. They looked through my logs (I sent them) and noted that the system was going into a low power mode and that was the problem. I reiterated that I had changed all the settings and even tried changing a few additional settings with DKMS and such, but to no avail.

I then tried some other troubleshooting (I’ll spare readers the details) by adding some additional packages that are tied to VNC, but that didn’t help.

At a loss for what to do next, I began to wonder where the actual settings are in XFCE to change the power management features of the computer. The windows/interfaces for changing those are really just changing settings in a file somewhere and the OS is reading that file and responding accordingly. It turns out, the power management settings are here:

/home/[user]/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml

Opening that file with a text editor, I looked for any instance where the setting didn’t make sense. For some reason, the windows to change these settings hadn’t completely changed the settings. For instance, on this line, I had a “3” when I should have had a “0.”

<property name="blank-on-ac" type="int" value="3"/>

In this file, “0” means “never,” which would tell the computer to never blank the screen when on AC power. I’m assuming “3” means after 5 minutes. So, despite me using the Power Management interface to tell XFCE to never blank the screen on AC power, that setting did NOT get updated in the actual file that controls this. I changed the value manually in the text editor and restarted my computer.

Alas, that didn’t solve the problem either. There is clearly something going on with XFCE that is forcing the machine into low power mode after about 5 minutes despite me changing all the settings I could find both via the System Settings tools and the actual configuration files.

So, I took a different route. I wrote a bash script that tells the OS that the SHIFT key has been pressed every 3 minutes to keep the machine from going into a low power mode. This confirmed that the problem was the low power mode setting. Here’s how I did that:

First, I installed this package:

sudo apt-get install xdotool

I then wrote a bash script that would send a signal to the computer that the SHIFT key had been pressed, which would prevent the machine from going into low-power mode. I opted for the SHIFT key as it doesn’t do anything unless it is combined with another key other than tell the computer that someone is there. Here’s the bash script:

#!/bin/bash

while true; do
    # Check if xdotool is installed
    if ! command -v xdotool &> /dev/null; then
         echo "xdotool not found. Please install it first."
         exit 1
    fi

    xdotool key Shift
    sleep 180 # sleep for 3 minutes
done

I saved this to my home directory as a file named “keepalive.sh.” I then ran it from the Konsole to test the script to make sure it would work by simply navigating to that location and running the script:

cd /home/[user]
./keepalive.sh

Sure enough, with the script running, this prevented the computer from going into a low power mode and NoMachine no longer froze up on me either during a session or between sessions.

I then added the script to my list of Autostart Applications so the script will run every time I turn on the computer. It’s annoying that I have to run this script to keep the computer from going into low-power mode, but it solved the problem.

(NOTES: I tried a number of other things to solve this, including changing the NoMachine settings and none of those worked.)

Exit mobile version