Ubuntu – How to turn off screen (DPMS) together with locking session in KDE

kdekubuntulock-screenpower-managementscreensaver

First of all, I'm aware a similar question for GNOME is asked here: "Switch off laptop backlight when locking screen".

Objective

I would like to turn off my screen on locking the session for power saving reasons.

Actual problem

Locking the screen on Kubuntu (KDE) inevitably triggers the screensaver as far as I can see. There's no screensaver option other than 'Blank screen' together with its background colour set to black that comes just close to my goal. It blanks the screen, but doesn't turn off the screen. Screen's backlight will still be on and not saving any power.

Current workaround

A workaround via a script + shortcut key is possible, however, it's just a workaround since it doesn't trigger on all ways to lock the session. Therefore, I think it should be possible to have it done more elegantly, for example by providing this option in KDE's configuration dialog of the screensaver.

The workaround I am now using is the following. A script that locks the screen and turns off the screen:

#!/bin/bash

qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
xset dpms force standby

and let it run with a shortcut key via a custom menu entry. It works.

Here's why I consider it to be a workaround rather than a solution. It doesn't work for other ways to trigger the locking of the session.

My actual question(s)

Do I need to touching/patching KDE's source?

  • If not what are my options?
  • If so,
    • could someone point me to where I can get started?
    • what do you think is the recommended place in the GUI for configuration?

I'm using Kubuntu 12.04 and willing to upgrade to KDE 4.9 or waiting for the 12.10 release.

Best Answer

Found a way for KDE 4 (up to Ubuntu 14.10). For modern KDE 5 see other answer.

  1. Go to System SettingsApplication and System NotificationsManage Notifications.

  2. Select Screen Saver as the Event Source

  3. Locate and select the Screen Locked

  4. add this command to the event:

     xset dpms force off
    

enter image description here

It will turn off all displays every time it gets locked.

Related Question