"Turn screen off when inactive"-setting from terminal [duplicate]

I want to turn the "Turn screen off when inactive for x minutes" setting (in the brightness settings) to "never" from the terminal, but I couldn't find the right command.

This will be used in a executable file to change a few settings on a Ubuntu live installation.

Edit:

Due to more involved reasons I want to change this specific setting which is independent of the screen saver settings (I think).


gsettings set org.gnome.desktop.session idle-delay 0

will prevent your screen from locking and change that setting to never.

Notice: close / re-open the settings window to see the effects the command takes.

The value that you write there is the time (in seconds) that it will take for Unity to decide that you have not been doing anything and the screen should be locked.


I think you can use this command:

xset s off

From the xset manual page (man xset):

s       The  s  option  lets you set the screen saver parameters.  This
       option   accepts   up   to   two   numerical   parameters,    a
       'blank/noblank'  flag,  an  'expose/noexpose' flag, an 'on/off'
       flag, an 'activate/reset' flag, or the 'default' flag.   If  no
       parameters  or  the  'default' flag is used, the system will be
       set to its default screen saver characteristics.  The  'on/off'
       flags  simply  turn  the screen saver functions on or off.  The
       'activate' flag forces activation of screen saver even  if  the
       screen  saver  had  been  turned  off.  The 'reset' flag forces
       deactivation of screen saver if it is active.  The 'blank' flag
       sets  the preference to blank the video (if the hardware can do
       so) rather than display a background pattern,  while  'noblank'
       sets  the preference to display a pattern rather than blank the
       video.  The 'expose' flag sets the preference to  allow  window
       exposures  (the  server  can  freely  discard window contents),
       while 'noexpose' sets the preference to  disable  screen  saver
       unless  the  server  can regenerate the screens without causing
       exposure events.  The length  and  period  parameters  for  the
       screen  saver  function  determines how long the server must be
       inactive for screen saving  to  activate,  and  the  period  to
       change  the background pattern to avoid burn in.  The arguments
       are specified in seconds.  If only one numerical  parameter  is
       given, it will be used for the length.

for Gnome and Unity desktops, to turn lock screen after an amount of time off:

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

to turn it back on:

gsettings set org.gnome.desktop.screensaver lock-enabled true

You can also set x minutes after which the screen will lock after the screen blanks, but you have to enter it as seconds (multiply by 60):

gsettings set org.gnome.desktop.screensaver lock-delay "x"

An example values are 300 for 5 minutes - you may be able to enter as minutes in the following bash line:

gsettings set org.gnome.desktop.screensaver lock-delay $(echo X*60 | bc)

Where X is a number in minutes - seems to work in Ubuntu 13.10.

Oh, and to disable screen dimming:

gsettings set org.gnome.settings-daemon.plugins.power idle-dim false

Try this it worked to me at least :

xset +dpms
xset dpms 300

300 is 5 min , so if it is 5 min inactive , it will power off .