Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Lid closed = screen locked?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 725

PostPosted: Sun Sep 16, 2012 11:11 am    Post subject: Lid closed = screen locked? Reply with quote

Can I have the screen locked whenever the laptop lid is closed in xfce4 without using xfce4-power-manager?

How about having the screen turned off when the lid is closed?
Back to top
View user's profile Send private message
audiodef
Watchman
Watchman


Joined: 06 Jul 2005
Posts: 5252

PostPosted: Sun Sep 16, 2012 2:43 pm    Post subject: Reply with quote

I think you can, but I can't think offhand what bash script you'd need to come up with. I think it's a matter of finding the event handler for on-lid-close or some such, and have that event trigger xlockmore or the screensaver lock command.

As for turning off the screen when you close the lid, that might be something you can find in the BIOS.
_________________
Gentoo Studio: http://gentoostudio.org
Facebook: http://www.facebook.com/gentoostudio
G+: https://plus.google.com/113947758237122861689/posts
Pappy's Kernel Seeds: http://kernel-seeds.gentoostudio.org
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3205

PostPosted: Sun Sep 16, 2012 5:27 pm    Post subject: Reply with quote

Best option is to use acpi. It will be independent of your desktop manager. You will need to fill in the following "blanks".
1. Determine the lid close event. Use acpi_listen to find out what event is triggered.
2. Create a file /etc/acpi/events/lid with the contents
Code:
event=button/lid # replace button/lid with your event
action=/etc/acpi/actions/lid "%e"

3. Create an executable script /etc/acpi/actions/lid that catches this event
Code:
#!/bin/bash

# if launched through a lid event and lid is open, do nothing
# replace the following string with your lid open event string from acpi_listen
[[ "$1" = *button/lid*open ]] && exit 0

# Determine your logged in user, or hard code your username
# See http://forums.gentoo.org/viewtopic-t-927908-view-previous.html
XUSER="username"

# Launch whatever you want
export DISPLAY=":0.0"

# You might also need to determine the dbus instance if you want to run xfce lock command.
<xfce lock command here> & # Put an "&" at the end if the lock command doesn't exit immediately.
xset dpms force off # will blank screen

_________________
emerge --quiet redefined | E17 vids: I, II
Back to top
View user's profile Send private message
grant123
l33t
l33t


Joined: 23 Mar 2005
Posts: 725

PostPosted: Mon Sep 17, 2012 7:12 am    Post subject: Reply with quote

Thank you, I've decided to stick with xfce4-power-manager but this should come in handy for someone.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum