Re: Running X window programs from PM suspend-resume scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2010-03-22 at 22:38 +0200, Serguei Miridonov wrote:
> On Monday 22 March 2010, Chris Tyler wrote:
> > On Mon, 2010-03-22 at 21:10 +0200, Serguei Miridonov wrote:
> > > Hello,
> > > 
> > > Is there a trick to run X window programs from PM suspend-resume
> > > hooks? For example, I need to restore keyboard mapping after
> > > suspend to RAM using
> > > 
> > > xkbcomp some_file.xkm :0.0
> > > 
> > > Running this in
> > > 
> > > #!/bin/bash
> > > DISPLAY=":0.0"
> > > export DISPLAY
> > > case $1 in
> > > 
> > >     hibernate | suspend)
> > > 	
> > > 	;;
> > > 	
> > >     thaw | resume)
> > >     
> > >         sleep 2
> > > 	
> > > 	chvt 1
> > > 	sleep 1
> > > 	xkbcomp /etc/X11/GoodKeyMap.xkm $DISPLAY
> > > 	;;
> > > 	
> > >     *)
> > >     
> > >         ;;
> > > 
> > > esac
> > > exit 0
> > > 
> > > gives an error: Cannot open display ":0.0"
> > > 
> > > Any idea?
> > 
> > Sounds like a problem with auth. Try setting the XAUTHORITY
> > environment variable, perhaps?
> 
> OK, I have changed the script adding the line
> 
> user=`who | grep -e ' :0' | sed 's/ *:0.*$//'`
> 
> and then running the required command as
> 
> su - $user -c "xkbcomp /etc/X11/GoodKeyMap.xkm $DISPLAY"
> 
> It works now. Is there a something simpler?

This works because, with a HOME directory specified, the xkbcomp command
can find the ~/.Xauthority file to get the magic cookie for display
connection authentication.

You should be able to set the XAUTHORITY environment variable to the
absolute path of the .Xauthority file instead of using su (try something
like: export XAUTHORITY=/home/${user}/.Xauthority)

-Chris

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux