Xsession.d and tpb

Tomas Krag tt at krag.org
Wed Feb 16 13:55:17 UTC 2005


On Wed, 16 Feb 2005 01:38:42 +0200, Marius Gedminas wrote:
> On Tue, Feb 15, 2005 at 04:53:56PM +0100, Tomas Krag wrote:
>> I'm running Warty on an IBM X31, and am mostly extremely satisfied with
>> almost everything.
>> I installed the thinkpad button package (tpb) and it adds a script
>> /etc/X11/Xsession.d/90tpb
>> which looks as if it should start the tpd daemon on starting X. 
> 
> Not exactly.  X session scripts are executed when a user logs in into X.
> 
>> However, after booting a quick os -aux |grep tpb 
>> shows tpb is not running.
> 
> There can be two reasons for this:
> 
> 1. tpb needs /dev/nvram and fails to start up if that device is not available.
>    /dev/nvram appears only when you modproble the nvram module, which is
>    not done by default.
> 
>      echo nvram >> /etc/modules
> 
>    should fix the problem.
> 
> 2. Xsession.d scripts are run with user (not root) privileges, so you
>    need to have access to /dev/nvram.
> 
>      sudo adduser (yourusername) nvram
> 
>    should fix the problem.
> 
>> If I run "sudo tpb -d" from a terminal or from
>> the gnome-sessions it works.
> 
> From this I assume (2) is the case.
> 
>> There are other files in /etc/X11/Xsession.d/ that also do not seem to be
>> run. 
>> What is the idea with Xsession.d ?
> 
> If you feel like studying how X logins work, start at /etc/gdm/Xsession
> and look what is executed and when.  Its very educational.
> 
>> If these files do not run, what would be the ideal place to start a
>> program that needs to be run as root? /etc/init.d/ ?
> 
> In general, yes, but this only applies to programs that do not interact
> with X.
> 
> HTH,
> Marius Gedminas

Thanks for the response,

It seems the permissions were wrong, because I had misunderstood when the
/etc/X11/Xsession.d files were executed, I assumed they were run with root
privilege, which is obviously wrong. 

Adding "sudo" to the tpb command solved that problem (along with a
NOPASSWD flag for specific commands in the sudoers file.

I also took your advice and ran through the /etc/gdm/Xsession script to
see what actually happens. I am still a little confused though, because
according to /etc/gdm/Xsession the files in /etc/X11/Xsession.d/* are most
definitely sourced and the commands executed. Yet I took a script from the
Xsession.d man-page which is supposed to load a custom keymap with xmodmap
(see below) and added it as /etc/X11/Xsession.d/40custom_load-xmodmap

I made it executable, and have ensured that the xmodmap binary and the
$HOME/.Xmodmap files are in the correct places, yet when I log in to X the
custom keymap is not loaded.

If I execute 
$ xmodmap ~/.Xmodmap in a terminal after starup it all works fine.

Oh well, these are minor issues that mostly annoy me because they trigger
my curiosity.

Thanks for the answer

cheers

/tomas




######################
SYSMODMAP="/etc/X11/Xmodmap"
USRMODMAP="$HOME/.Xmodmap"

if [ -x /usr/bin/X11/xmodmap ]; then
        if [ -f "$SYSMODMAP" ]; then
                xmodmap "$SYSMODMAP"
        fi
fi

if [ -x /usr/bin/X11/xmodmap ]; then
        if [ -f "$USRMODMAP" ]; then
                xmodmap "$USRMODMAP"
        fi
fi
######################





More information about the ubuntu-users mailing list