Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Apr 2016 18:20:33 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        "Brandon J. Wandersee" <brandon.wandersee@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Simple devd.conf rule has no effect
Message-ID:  <alpine.BSF.2.20.1604191810540.59174@wonkity.com>
In-Reply-To: <86bn552vga.fsf@WorkBox.Home>
References:  <86fuuywldn.fsf@WorkBox.Home> <alpine.BSF.2.20.1604061523060.39687@wonkity.com> <86bn552vga.fsf@WorkBox.Home>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 19 Apr 2016, Brandon J. Wandersee wrote:

>
> Warren Block writes:
>
>> On Wed, 6 Apr 2016, Brandon J. Wandersee wrote:
>>
>>>
>>> Hi, folks. I'm trying to get my laptop screen to lock when the lid
>>> closes, using x11/slock. I've created the file /etc/devd/lidlock.conf
>>> with the following rule:
>>>
>>> | notify 0 {
>>> |         match   "system"        "ACPI";
>>> |         match   "subsystem"     "Lid";
>>> |         match   "notify"        "0x00";
>>> |         action  "/usr/local/bin/slock";
>>> | };
>>>
>>> This is really just a slight variation on the example from the
>>> devd.conf(5) man page. Now when I close the lid, the screen fails to
>>> lock, yet /var/log/messages displays the message "devd: Executing
>>> 'slock'". Any advice on what to look into to figure out why the program
>>> is not actually executed? Thanks in advace.
>>
>> devd(8) stuff runs as root, I think.  So it probably does not have
>> $DISPLAY set.  Maybe use su to switch to the normal X user and execute
>> the command:
>>
>>    su -l xusername -c 'setenv DISPLAY :0.0 && /usr/local/bin/slock'
>
> Thanks for the response, Warren; sorry for the lateness of mine. Your
> solution works when run from a shell, but devd still doesn't properly
> execute it. I also tried changing the quotes around, adapting it for my
> user shell (changing 'setenv' to 'export DISPLAY='), and putting it in a
> shell script and executing the script from the devd config file. No
> luck. Guess I'll just keep messing with it when the mood strikes, see if
> anything clicks.

This was actually a good time for a reply, as I needed to set up 
something similar.  The idea was to run xlock before suspending so text 
on the screen is not visible when it wakes up.  This, based on your 
example, finally worked:

   notify 20 {
 	match "system"    "ACPI";
 	match "subsystem" "Lid";
 	match "notify"    "0x00";
 	action "/usr/bin/su wblock -c '/usr/local/bin/xlock -display :0.0 -mode qix & /bin/sleep 2'"'
 	action "acpiconf -s3";
   };

Running xlock as my unprivileged user might not be necessary, but seems 
safer.  The 'sleep 2' might not be required, either, but it didn't want 
to work correctly until I did that.  More experimentation is needed.

The second action runs as root to suspend the machine.  There is
/etc/rc.suspend, but X already seemed to be stopped by the time that 
executed.  Or something prevented running xlock from in there.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.20.1604191810540.59174>