[mythtv-users] KDE Power Management and 0.25

A McDermott list at mcdermotts.ca
Thu Jun 28 05:17:34 UTC 2012


> Would like to use standard KDE power management which dims and sleeps
> the monitor and then shutdown the computer at predefined intervals.  I
...
> Ideas?

Answering my own question:  Here are two methods that I found which
work for me in Kubuntu 4.8.3

In both the methods below, I used the system event triggers to
set/clear a flag in /tmp/ which external scripts picked up on and
inhibit power management at the right times.  Now I can set KDE to run
the screen saver, then turn off the screen, then suspend to RAM
without affecting operation during playback.  I'm in a trusted
environment where (a) I know myth will always be running on DISPLAY 0,
and that "xhost +" does not pose a security risk.

Method 1: use xdotool to mimic mouse movement.  This method is
reliable, and the screen does not flicker when inhibiting power
management


#!/bin/sh

#remove the inhibit flag in case one already exists
rm /tmp/inhbit.sh 2>/dev/null

#wait for KDE to start, needed?
sleep 10

#disable access control
DISPLAY=:0 xhost + 2>&1 1>/dev/null

while true
do

  if [ -e /tmp/inhibit ]
  then
    #move the mouse +10,+10, then move it back -10,-10
    DISPLAY=:0 xdotool mousemove_relative 10 10 2>&1 1>/dev/null
    sleep 15
    DISPLAY=:0 xdotool mousemove_relative -- -10 -10 2>&1 1>/dev/null
    sleep 15
  fi

  sleep 15

done

Method 2: Perhaps more proper, tells the powerdevil daemon to inhibit
operation.  For me, this method sometimes causes the display to
flicker when the inhibit is started, stopped.  You still need to
disable  access control.  The inspiration for this script was taken
from http://lists.exherbo.org/pipermail/paludis-user/2011-April/001705.html
and modified with help from the KDE community (see thread:
http://forum.kde.org/viewtopic.php?f=66&t=102903)

#!/usr/bin/python

import dbus
import time
import signal, sys
import os.path

a = "MythTv"
b = "Watching the tube"
flag = "/tmp/inhibit"

while 1 == 1:
  time.sleep(10)

  if os.path.exists(flag):
    bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
    devobj = bus.get_object('org.kde.kded',
'/org/kde/Solid/PowerManagement/PolicyAgent')
    dev = dbus.Interface (devobj, "org.kde.Solid.PowerManagement.PolicyAgent")

    cookie1 = dev.AddInhibition(1, a, b)
    cookie2 = dev.AddInhibition(2, a, b)
    cookie3 = dev.AddInhibition(4, a, b)

    while 1 == 1:
      if not os.path.exists(flag):
        dev.ReleaseInhibition(cookie1)
        dev.ReleaseInhibition(cookie2)
        dev.ReleaseInhibition(cookie3)
        break
      time.sleep(30)


More information about the mythtv-users mailing list