LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-18-2017, 10:55 AM   #1
drew2x
LQ Newbie
 
Registered: Apr 2005
Location: Brooklyn, NY
Distribution: Slackware64 14.2
Posts: 26

Rep: Reputation: 0
Trying to trigger xautolock from opening lid to laptop


Hello,

I've managed to get xautolock to trigger Suckless.org's "slock" after 15 minutes of idling from my xinitrc. However, I'm having a hard time figuring out how to have the screen locked after shutting and opening the lid of my laptop. I found the lid action on a previous thread, so I managed to get pm-suspend working. I tried adding the following to my /etc/acpi/events/lid file to no avail.. not sure what I'm missing or if I'm just attempting this from the wrong location. As I type this I'm thinking maybe I need to reverse and have it called on wake?

Code:
event=button/lid LID close
action=/usr/bin/slock && /usr/sbin/pm-suspend
 
Old 11-19-2017, 05:39 AM   #2
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
The problem you have is that the acpid events are handled outside of the users X process environment, so slock running in the event handler will have no connection to the user or the Xserver.

The way to workaround that is to have the acpid handler send some sort of signal to a screenlocker daemon process running within the users X environment.

A quick and dirty one knocked up in shellscript might look something like this:
/usr/local/bin/lid-locker:
Code:
#!/bin/sh

lockscreen()
{ 
  xlock -mode blank
}

trap lockscreen SIGUSR1
trap exit SIGTERM SIGINT

echo lid-locker PID: $$
trap -p 

while : 
do
  sleep 1d &
  while ! wait
  do 
    :
  done
done
Have that started in the background from your xsession/xinitrc and then the acpid script just needs to
pkill --signal USR1 -x lid-locker


There might be more modern ways of doing something like this involving udev, or dbus, but I don't have much knowledge of those.

Hope that gives you some ideas.
 
Old 11-20-2017, 02:18 AM   #3
drew2x
LQ Newbie
 
Registered: Apr 2005
Location: Brooklyn, NY
Distribution: Slackware64 14.2
Posts: 26

Original Poster
Rep: Reputation: 0
That makes sense, I'm going to play around with this script idea and see if I can get it working. For the moment I figured out how to setup a shortcut to trigger slock with F12 in dwm before I close the lid. Thanks! I will report my luck.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Password when opening Laptop Lid 300_baud SUSE / openSUSE 5 07-03-2019 11:35 AM
[SOLVED] No image on screen after closing and opening my laptop's lid on Debian Squeeze rebelplankton Linux - Laptop and Netbook 2 11-01-2012 12:11 AM
Screen does not activate after opening the lid momchil Linux - Laptop and Netbook 3 01-10-2010 05:31 PM
Screen stays blank after re-opening lid. . . K2712 Fedora 3 05-10-2005 06:59 PM
Corruption at the top of screen after shutting and opening laptop lid TMH Linux - Hardware 1 01-18-2005 02:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration