6 Sep 2009

How to create your own XSession

Submitted by blizzz

My use case is that i use my other computer primarily for watching TV (my notebook overpowers it and i use it with dual screen at home). So, usually i don't need a full blown KDE, but only kdetv as i have an older analog TV card plugged in. Thus, best is to generate a kdetv-only session.

Therefore you need basically two files. The first is .desktop file that populates your session, the second is the script which is being started if you log into it. Let's take a closer look:

/usr/share/xsessions/kdetv.desktop
[Desktop Entry]
Encoding=UTF-8
Type=XSession
Exec=/usr/local/bin/xkdetv
TryExec=/usr/local/bin/xkdetv
Name=KDE TV
Comment=KDETV only session

As you see we set the type as "XSession" and set the command which is to be executed with Exec. Well, why there's TryExec? Dunno, i copied it from the original kde.desktop file. The name is what appears on the session menu.

So, what's in the script?

/usr/local/bin/startxkdetv
#!/bin/bash
if test "x$DISPLAY" = "x" then
  prog=xinit
else
  prog=/bin/sh
fi

exec $prog /usr/bin/kdetv $* -- :0

Here we have a little bit of overkillity, as we check wether X is running or not. If we know we will always start from within a login manager, we can reduce this to shebang and the last line, replacing $prog with /bin/sh. However, discriminating it we are able to start our session from tty and any login manager shut down via xinit. Well, it's obvious that we start kdetv then.

So, if you make up those files, now, and restart your login manager, you should be able to select the "KDE TV" session. Eventually it should start up in full screen.

The only problem I have is that the screen seems to be turned off by power management features every 15min, which is quite bad when you're only watching. Someone any idea how to turn disable it?

Btw: this time the post is posted with Bilbo Blogger.

Comments

You might be able to do something with laptop-mode settings - i think they can control the X power management or there are some settings in xorg.conf which might do it:
Option "StandbyTime" "time"
sets the inactivity timeout for the standby phase of DPMS mode. time is in minutes, and the value can be changed at run-time with
xset(1). Default: 20 minutes. This is only suitable for VESA DPMS compatible monitors, and may not be supported by all video drivers.
It is only enabled for screens that have the "DPMS" option set (see the MONITOR section below).

Option "SuspendTime" "time"
sets the inactivity timeout for the suspend phase of DPMS mode. time is in minutes, and the value can be changed at run-time with
xset(1). Default: 30 minutes. This is only suitable for VESA DPMS compatible monitors, and may not be supported by all video drivers.
It is only enabled for screens that have the "DPMS" option set (see the MONITOR section below).

Option "OffTime" "time"
sets the inactivity timeout for the off phase of DPMS mode. time is in minutes, and the value can be changed at run-time with xset(1).
Default: 40 minutes. This is only suitable for VESA DPMS compatible monitors, and may not be supported by all video drivers. It is
only enabled for screens that have the "DPMS" option set (see the MONITOR section below).

^from man xorg.conf

Thanks a lot for the hint, which led me to the solution. Adding those options didn't not have an effect, because the screen turned black after 10 minutes. But the manpage also describes "BlankTime":

Option "BlankTime" "time"
sets the inactivity timeout for the blank phase of the screensaver. time is in minutes. This is equivalent to the Xorg
server’s -s flag, and the value can be changed at run-time with xset(1). Default: 10 minutes.

I set everything to zero and now it looks quite perfect. Thanks!

I'd like to try this, but using xinit to start a second X with the proprietary ati drivers takes down your box :-(

If you start a second XServer, you need to change the number after the colon to 1, e.g. resulting in
xinit /usr/bin/kdetv $* -- :1
Did you try this?

I know I have to start the new X server on another display. I'm just having troubles with a fglrx bug that won't be resolved any time soon:
https://bugs.launchpad.net/ubuntu/+source/fglrx-installer/+bug/290704

So if you have an ati vid card with fglrx: don't try this, it will crash your pc!

Add new comment