How to disable screen off and screen lock on Jetpack3.1 of TX2 device

Dear Sir,
I want to disable screen off and screen lock on Jetpack3.1 of TX2 device, because when screen locked, U disk and tf card can not mount success, after unlock screen , they can be mounted success. As we may not have screen connected ,so is there any configuration file which can set for screen lock and screen off ? Thanks!

You could just use the GUI to do this setting-> System setting -> Power.

As for command, please try if this works.

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Dear Wayne,
I use the command, but still occur screen off and lock

you need to set the parameter screen off to never and trigger screen lock to off
System Settings -> Personal-> Brightness and Lock section

Yes, I know that could be done, but endusr have no chance to do such change because there is no screen connected with TX2 device. So I need command or configuration to make screen off to never.
Any advice?

you may ssh -X to the device and call the system setting interface to appear at host computer, in my opinion. Otherwise:

gsettings set org.gnome.settings-daemon.plugins.power sleep-display-ac 0
gsettings set org.gnome.settings-daemon.plugins.power sleep-display-battery 0
gsettings set org.gnome.desktop.session idle-delay 0

source: https://askubuntu.com/questions/313455/brightness-settings-from-terminal

gsettings set org.gnome.desktop.screensaver.lock-enabled false
gsettings set org.gnome.desktop.idle-activation-enabled false

source: https://askubuntu.com/questions/379090/how-to-disable-screen-lock-timeout-from-a-script

when I run gsettings set org.gnome.desktop.session idle-delay 120 ,it cause error as follows. But can work on personal PC

nvidia@tegra-ubuntu:~$ gsettings set org.gnome.desktop.session idle-delay 120
(process:2417): dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY

In my opinion your issie is addressed in the following thread: https://askubuntu.com/questions/457016/how-to-change-gsettings-via-remote-shell
BTW, why do not you just use vino server and connect over vnc? That will allow to use GUI.

The error mentioning “without X11 $DISPLAY” implies you were not logged in to the GUI from which the command would be associated. If there is a user logged in to that display, then probably “export DISPLAY=:0” prior to the command would do the trick. On the other hand, I never thought of that command as needing a currently login. I can see the possibility that the command might involve different displays in a multi-monitor situation, so maybe this is why there is such a requirement. So as an experiment I read (“gsettings get org.gnome.desktop.session idle-delay”) without DISPLAY and got “3600”, then tried to “set” using this same value in multiple ways, but all methods failed. Even if I had logged in and set DISPLAY I got a DBUS error, so I don’t know what gsettings wants to make this work.

Some explanation from the askubuntu url above:

The key is to set the DBUS_SESSION_BUS_ADDRESS environment variable.

On this thread I found the following script, that helps to get the correct value of that variable. It requires name of the process, that is running on the desktop, on which we want to change the dbus settings. (There can be more than 1 running graphical sessions in parallel). Lets call it discover_session_bus_address.sh

#!/bin/bash

# Remember to run this script using the command "source ./filename.sh"

# Search these processes for the session variable 
# (they are run as the current user and have the DBUS session variable set)
compatiblePrograms=( nautilus kdeinit kded4 pulseaudio trackerd )

# Attempt to get a program pid
for index in ${compatiblePrograms[@]}; do
    PID=$(pidof -s ${index})
    if [[ "${PID}" != "" ]]; then
        break
    fi
done
if [[ "${PID}" == "" ]]; then
    echo "Could not detect active login session"
    return 1
fi

QUERY_ENVIRON="$(tr '

The key is to set the DBUS_SESSION_BUS_ADDRESS environment variable.

On this thread I found the following script, that helps to get the correct value of that variable. It requires name of the process, that is running on the desktop, on which we want to change the dbus settings. (There can be more than 1 running graphical sessions in parallel). Lets call it discover_session_bus_address.sh

#!/bin/bash

Remember to run this script using the command “source ./filename.sh”

Search these processes for the session variable

(they are run as the current user and have the DBUS session variable set)

compatiblePrograms=( nautilus kdeinit kded4 pulseaudio trackerd )

Attempt to get a program pid

for index in {compatiblePrograms[@]}; do PID=(pidof -s {index}) if [[ "{PID}" != “” ]]; then
break
fi
done
if [[ “${PID}” == “” ]]; then
echo “Could not detect active login session”
return 1
fi

QUERY_ENVIRON="(tr '\0' '\n' < /proc/{PID}/environ | grep “DBUS_SESSION_BUS_ADDRESS” | cut -d “=” -f 2-)"
if [[ “{QUERY_ENVIRON}" != "" ]]; then export DBUS_SESSION_BUS_ADDRESS="{QUERY_ENVIRON}”
echo “Connected to session:”
echo “DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}”
else
echo “Could not find dbus session ID in user environment.”
return 1
fi

return 0
With this script we can do the following, assuming that unity process is running on the desktop, on which we want to apply our settings:

. ./discover_session_bus_address.sh unity
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize “4”
And things should work OK.

' '\n' < /proc/${PID}/environ | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)"
if [[ "${QUERY_ENVIRON}" != "" ]]; then
    export DBUS_SESSION_BUS_ADDRESS="${QUERY_ENVIRON}"
    echo "Connected to session:"
    echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
else
    echo "Could not find dbus session ID in user environment."
    return 1
fi

return 0
With this script we can do the following, assuming that unity process is running on the desktop, on which we want to apply our settings:

. ./discover_session_bus_address.sh unity
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize "4"
And things should work OK.

However , I would just use GUI like vnc and configure the required parameters.
As the author of the topic doesn’t have a display that is connected to the device as is stated in the post, vnc will be the most simple way, in my opinion.

Dear Andrey1984,
Thank you very much! After running this script, the following cmd can work normal.
gsettings set org.gnome.desktop.session idle-delay 0

Dear linuxdev,
Thanks for your kindly reply.