In /etc/pam_usb/hotplug.conf I set enable to 1, and enabled log for the usbhotplug. Now it should lock X when I unplug my usb storage device. In log this is what happens: [usbhotplug] --- LOG STARTED --- [usbhotplug] Received a hotplug event [usbhotplug] Cannot retrieve device informations [usbhotplug] Access denied for user root, starting the handler [usbhotplug] Running as user root [ uid:0 | gid:0 ] [usbhotplug] Starting the lock handler [usbhotplug] About to execute /etc/pam_usb/handlers/xlock.sh start... [usbhotplug] --- LOG STARTED --- [usbhotplug] Received a hotplug event [usbhotplug] Cannot retrieve device informations [usbhotplug] Access granted for user root, starting the handler [usbhotplug] Running as user root [ uid:0 | gid:0 ] [usbhotplug] Starting the unlock handler [usbhotplug] About to execute /etc/pam_usb/handlers/xlock.sh stop... I tried to edit script xlock.sh, and added line: touch /root/test in the start section of the script, and file was created. After that I tried to run from terminal the command /etc/pam_usb/handlers/xlock.sh start and it started xlock as it should. Reproducible: Always Steps to Reproduce: 1.Unplug usb storage device, and xlock wont be started, but it should be 2. 3. Actual Results: Nothing. Just entries in the log Expected Results: It should have started xlock root@jaguar /var/log # emerge info Portage 2.0.51.21-r1 (default-linux/x86/2005.0, gcc-3.3.5, glibc-2.3.5-r0, 2.6.11-cko5 i686) ================================================================= System uname: 2.6.11-cko5 i686 AMD Athlon(tm) XP 2500+ Gentoo Base System version 1.6.11 ccache version 2.4 [enabled] dev-lang/python: 2.3.5 sys-apps/sandbox: 1.2.8 sys-devel/autoconf: 2.13, 2.59-r6 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.5 sys-devel/binutils: 2.15.92.0.2-r8 sys-devel/libtool: 1.5.16 virtual/os-headers: 2.6.11 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CBUILD="i686-pc-linux-gnu" CFLAGS="-O3 -march=athlon-xp -pipe -mmmx -msse -mfpmath=sse,387 -m3dnow -momit-leaf-frame-pointer -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/share/config /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-O3 -march=athlon-xp -pipe -mmmx -msse -mfpmath=sse,387 -m3dnow -momit-leaf-frame-pointer -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FEATURES="autoconfig ccache distlocks sandbox sfperms strict" GENTOO_MIRRORS="ftp://mirror.etf.bg.ac.yu/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/storage/portage" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="x86 3dnow X acpi alsa apache2 avi bash-completion bitmap-fonts bzlib cdparanoia cdr cups divx4linux dvd dvdr dvdread encode gimpprint gpm gtk gtk2 jabber mp3 ncurses nls nptl offensive ogg oggvorbis opengl oss pam perl png quicktime sse ssl truetype truetype-fonts type1-fonts usb v4l xmms xv zlib userland_GNU kernel_linux elibc_glibc" Unset: ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS
This is because the handler is not authorized to connect to the X server. To fix this you have to add xhost +root (or whatever username you have used on /etc/pam_usb/ hotplug.conf) to your .xinitrc.