Page 1 of 1

Screen Saver -> Screen OFF instead of Screen black

Posted: Wed Mar 16, 2016 11:28 am
by Gerd
Hi there,

running my new Pi3 I noticed that when the screen saver kicks in, it displays black pixels instead of swiching off the screen. While I do not care about the 1 or 2 watts the pi3 draws when idle, I do care about the 70 watts my screen draws when displaying black pixels.
After an intensive search I found a solution to this:
Append the following line in config.txt

Code: Select all

hdmi_blanking=1
After the next reboot and coffee break, voilà: Screen is blank

I`d like to share this finding, because I didn't find this setting documented neither in http://elinux.org/RPiconfig nor https://www.raspberrypi.org/documentati ... fig-txt.md , only in this git commit https://github.com/raspberrypi/document ... /245/files I stumbled upon.

Hope this is helpful for someone not using his Pi as a media center.

Gerd, new user who is reading a lot at the moment.

Re: Screen Saver -> Screen OFF instead of Screen black

Posted: Thu Mar 31, 2016 1:28 pm
by mikluz
Hi,

maybe you or someone else would know the answer on the question: "How to trigger locking or blank screen with a keyboard shortcut"?
You know, the same as works on M$ when you hit Windows+L, or Ctrl+Alt+L on Ubuntu-like distros?

I tried to search the answer on that question, but apparently I couldn't find anything that fully covers my issues.


Thanks a lot for your help.

Re: Screen Saver -> Screen OFF instead of Screen black

Posted: Thu Mar 31, 2016 1:34 pm
by darkbibble
you can also install xscreensaver and get gui options for screen off

Re: Screen Saver -> Screen OFF instead of Screen black

Posted: Fri Apr 01, 2016 8:52 am
by mikluz
I know about xscreensaver and am testing it right now, but as someone else stated in this forum, that xscreensaver is using lots of CPU (sic!).
I just wondered Raspbian knows how to switch monitor off, so, there is a routine for that. Maybe someone knows how to attach keyboard shortcut for running this routine like it is done in other desktop OS (Windows + L or so)?

//EDIT
I've written the script that adds Ctrl + Alt + L shortcut that locks the screen
Here is the answer: viewforum.php?f=28

Re: Screen Saver -> Screen OFF instead of Screen black

Posted: Tue Apr 26, 2016 12:11 am
by Rive
mikluz wrote:Hi,

maybe you or someone else would know the answer on the question: "How to trigger locking or blank screen with a keyboard shortcut"?
You know, the same as works on M$ when you hit Windows+L, or Ctrl+Alt+L on Ubuntu-like distros?

I tried to search the answer on that question, but apparently I couldn't find anything that fully covers my issues.


Thanks a lot for your help.
Youtube Video: https://youtu.be/aTrp83lgq_s

Code: Select all

xset q
note- "xset q" is useful for checking screen and dpms settings, and changing them for testing (e.g., Monitor "off" is set for 1200 sec, or 20 min, and you want to test it, so you set dpms to 10 sec (xset dpms 0 0 10)). Changes here are temporary, and will not survive a reboot.

Run:

Code: Select all

sudo apt-get install light-locker
Open:

Code: Select all

sudo nano /boot/config.txt
Add:

Code: Select all

# uncomment to put the monitor into power saving mode (DPMS)
hdmi_blanking=1
Open:

Code: Select all

sudo nano ~/.config/lxsession/LXDE-pi/autostart
Add:

Code: Select all

@xset s 0 0
@xset s noblank
@xset s noexpose
@xset dpms 0 0 1200
Save with 'Ctrl + x', then 'y', then 'enter'

open:
(note- if you do an "apt-get dist-upgrade" instead of an "apt-get upgrade", you will need to re-add this keybind)

Code: Select all

nano ~/.config/openbox/lxde-pi-rc.xml
find:

Code: Select all

 <!--keybindings for LXPanel →
add:

Code: Select all

      <keybind key="C-A-L">
    <action name="Execute"><command>lxlock</command></action>
  </keybind>
The above dpms '1200', means turn off monitor after 20min, and lock screen with light-locker (lxlock). Change to whatever time you want (in seconds).

If you do not want screen to autolock
If you prefer screen to just turn off/go into power save mode, and resume if you move mouse, or hit a key WITHOUT requiring login, and wish to manually do screenlock, then;

open

Code: Select all

sudo nano /etc/xdg/autostart/light-locker.desktop
find "Exec=light-locker", change to

Code: Select all

Exec=light-locker --lock-after-screensaver=0 --no-lock-on-suspend --no-late-locking

Code: Select all

sudo reboot

Shortcuts:
1. add "ScreenLock" Menu shortcut (via Menu/Preferences/Main Menu Editor/Other/)
2. use keyboard 'Ctrl ' + 'Alt' + 'L' to turn off monitor and lock screen

Re: Screen Saver -> Screen OFF instead of Screen black

Posted: Tue Apr 26, 2016 12:19 am
by DougieLawson
Try running this

Code: Select all

#!/bin/bash

bl_on() {
  echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
}

bl_off() {
  echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
}

process() {
  while read line; do
     case "$line" in
       UNBLANK*)
          bl_on
          ;;
       BLANK*)
          bl_off
          ;;
       RUN*)
          bl_off
          ;;
     esac
  done
}

/usr/local/bin/xscreensaver-command -watch | process
If you have sudo protected with PASSWD (rather then NOPASSWD, which I have changed) you'll fail on the sudo tee command. I ended up writing a suid (chmod +s) program to write to the backlight file from any userid without needing sudo.

Re: Screen Saver -> Screen OFF instead of Screen black

Posted: Thu Aug 24, 2017 4:57 pm
by antirasp
DougieLawson wrote:
Tue Apr 26, 2016 12:19 am
Try running this

Code: Select all

#!/bin/bash

bl_on() {
  echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
}

bl_off() {
  echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
}

process() {
  while read line; do
     case "$line" in
       UNBLANK*)
          bl_on
          ;;
       BLANK*)
          bl_off
          ;;
       RUN*)
          bl_off
          ;;
     esac
  done
}

/usr/local/bin/xscreensaver-command -watch | process
If you have sudo protected with PASSWD (rather then NOPASSWD, which I have changed) you'll fail on the sudo tee command. I ended up writing a suid (chmod +s) program to write to the backlight file from any userid without needing sudo.


HEllo:

Is this to turn off the screen with a shortcut to the script, or does it simply change the way the screen shuts off in an original way, ie from black screen to off screen?
Apologies for my lousy English, it is done with the google translator. Thank you.

Re: Screen Saver -> Screen OFF instead of Screen black

Posted: Thu Aug 24, 2017 7:57 pm
by DougieLawson
bl_on() turns it on, bl_off() turns it off.

Code: Select all

#include <stdio.h>     /* for printf */
#include <stdlib.h>    /* for exit */
#include <unistd.h>    /* for getopt */

#define FN "/sys/class/backlight/rpi_backlight/bl_power"
#define BL_ON 0
#define BL_OFF 1

FILE *bl;

void bl_on ()
{
 fwrite("0", 1, 1, bl);
}

void bl_off()
{
 fwrite("1", 1, 1, bl);
}

int main (int argc, char **argv)
{

    int c, err = 0;
    int sflag = 0;
    char *sopt = 0;
    static char usage[] = "Usage: %s -s 0|1 \n";
    
    while ((c = getopt(argc, argv, "s:")) != -1)
    {
        switch (c)
        {
        case 's':
            sflag = 1;
            printf ("option s with value '%s'\n", optarg);
            sopt = optarg;
            break;
        case '?':
            fprintf(stderr, usage, argv[0]);
            err = 1;
            break;
        }
    }
    if ((optind) != argc)
    {
       fprintf(stderr, usage, argv[0]);
       exit(-1);
    }
    else if (sflag == 0)
    {
       fprintf(stderr, "Err: %s: missing -s option\n", argv[0]);
       exit(-1);
    }
    else if (err)
    {
       fprintf(stderr, usage, argv[0]);
       exit(-1);
    }
    bl = fopen(FN, "w");
    if (strcmp(sopt, "0")==0)
    {
       printf("Backlight ON");
       bl_on();
    }
    else if (strcmp(sopt, "1")==0)
    {
       printf("Backlight OFF");
       bl_off();
    }
    else
    {
       fprintf(stderr, "Invalid switch option");
       exit(-1);
    }
    fclose(bl);
    exit (0);
}