[SOLVED] Run xscreensaver when I close the laptop lid

I have xscreensaver running in my archlinux, and with a systemd service, I can start it after waking up my laptop.
The problem is that I like to keep my laptop running when I close the lid (for example, to go to bed while I'm downloading a file, I like to simply close my lid), but I want to lock my computer.
In the /etc/systemd/logind.conf, there is a nice option called HandleLidSwitch, which specifies which action is invoked when the lid is closed, and there is a lock option, but It doesn't work for me.
The option suspend works fine.
Here is my /etc/systemd/logind.conf:
# This file is part of systemd.
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# See logind.conf(5) for details
[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#Controllers=
#ResetControllers=cpu
#InhibitDelayMaxSec=5
HandlePowerKey=suspend
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
HandleLidSwitch=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#IdleAction=ignore
#IdleActionSec=30min
Any help?
Last edited by alomsimoy (2013-09-10 18:08:33)

I would say that you should just have logind ignore the LidSwitch altogether.  So if it is set to ignore the lid switch, then it obviously isn't going to be entering the suspend.target (or is it the sleep.target, I can't remember).  Therefore, you are going to have to have some other way of triggering actions in response to these events.
The lid switch sends an event to udev, so you have the option of having a udev rule that responds to this, or using acpid to start this for you.  I would recommend using acpid, as it is much more flexible in what it can allow you to do.
Edit: acpid is not necessarily more flexible than a udev rule, as it relies on the udev events.  But it is a much easier method of setup since it simply relies of basic scripting in order to make it work.  It can allow for one central script (or collection of scripts) to handle all the different events that udev sends.  To see what kinds of things trigger a udev event, you can use udevadm monitor or if you install acpid, there is the acpi_listen option.
Edit2:  BTW, what is it you mean by not working?  Does it still suspend on lid close, or is your xscreensaver not started?  You need to be more explicit there.  If it is still suspending, have you rebooted or restarted logind after making those changes to logind.conf?  You can't just edit the file and have the changes implemented right away, as the configuration is parsed and the settign implemented on the service start.
Last edited by WonderWoofy (2013-09-10 17:28:05)

Similar Messages

  • My mac makes a popping sound when I close the laptop lid

    I have a question I am going into a apple certified repair store and getting my mac repaired cause of the popping noise it makes. it is reproducible so thats not a issue with having to prove that i'm not making it up. will they replace the laptop or will they repair it and if they do determine to replace it then do they give you a replacement right away or do you have to have it repaired so many times ?. I have had the laptop for a year and 2 months and I do have apple care on it so thats not an issue. has anyone else dealt with this issue and what did apple do in the end ?

    Open your mac pro and listen carfully.  It could be coming from a failing hard drive or a bad fan.  If you have more than one drive you could remove the ones you are not currently using and add them back one by one to try to localize or eliminate the sound.  Caution though, only remove drives when your machine is off.  You cannot hot swap the drive bays.

  • Screen wont shut off when I close the laptop after fresh install (L512)

    So I recently replaced the hard drive in an lenovo L512 with an i3. I've updated windows completely and installed I believe most of the drivers. Everything seems to be functioning perfectly. The only thing is when I close the laptop. The display does not shut off. Is there a driver I am missing? I am running windows 7 professional x64. completely legitimate copy with the original key from the laptop. Thanks for any help!

    jordN wrote:
    This only started happening after I upgraded from Windows 8.1 to Windows 10, I don't have a clue why it does it, but if I close the screen on my laptop and open it, the screen doesn't come back on it just stays off but the power light button comes on and the WiFi signal button is on but it is red as if the wifi is turned off, is anyone else having this problem or does anyone know how to fix it? I have to manually hold down the power button everytime I close my laptop to turn it off and then back on and once it is on it works perfectly, but I don't like holding the power button down for obvious reasons. Thank you.Go back to Windows 10, seems HP do not care about releasing up to date drivers for Windows 10, this is despite the problem you report also happening during BETA Testing of Windows 10 over TWELVE MONTHS AGO! It is only now HP are bothering to advise people not to upgrade, but yet they clearly won't reply in this topic, which is more or less about your problem from many different users! http://h30434.www3.hp.com/t5/Notebook-Operating-Systems-and-Software/Windows-10-Laptop-won-t-go-into-sleep-mode/m-p/5181173#M304826

  • Firefox 4 closes the current tab when I close the laptop - why?

    I've just upgraded to firefox 4. Now when I close the laptop the open tab disappears. This never happened with the older version.

    See http://kb.mozillazine.org/Firefox_crashes and [[Firefox crashes]]
    Set the pref [http://kb.mozillazine.org/browser.sessionstore.max_resumed_crashes browser.sessionstore.max_resumed_crashes] to '''0''' on the '''about:config''' page to get the about:sessionrestore page immediately with the first restart after a crash has occurred or the Task Manager was used to close Firefox.
    See https://wiki.mozilla.org/Session_Restore#Preferences
    http://kb.mozillazine.org/Browser.sessionstore.max_resumed_crashes
    See also http://kb.mozillazine.org/Session_Restore#Firefox_keeps_crashing_after_restoring_a_session

  • Firefox locks up when I reopen the laptop lid.

    I have W7 on my A505 Toshiba. I have Fox News (home page), Comcast home page and Comcast mail tabs displayed. I close the laptop lid. Reopen several hours later and performance is slow. X out of mail, Comcast, and then try to X out of Fox and computer hangs up. This has started within the last couple weeks. During that time, I downloaded an Adobe update only.

    Hi,
    You can try to [https://www.mozilla.org/en-US/firefox/new/ updating Firefox] and check. If the problem persists, you can also try to '''Disable''' suspicious '''Plugins''' in '''Tools '''('''Alt '''+ '''T''') > '''Add-ons'''. Please note that this may also happen if the laptop close lid action was changed from sleep to hibernate because Windows would take more time to restore the saved state from disk.

  • How does monitor work when you close the laptop

    can the monitor still work if you close the laptop? if not, how can i turn off the picture on the laptop screen as i don't want to see both screens?

    That setting is always on if you are using an USB mouse; to do it with a Bluetooth device, follow the instructions in this article.
    (19623)

  • When I close my laptop lid and it goes to sleep so that I can use an external monitor, monitor does not turn on when I hit a key to start laptop

    When I use my external monitor, I cannot get it to work after awakening my laptop using any key.  My monitor won't light up although laptop keyboard is backlit showing that it has come out of sleep mode.  Why does the monitor not get the signal from the laptop?

    I still cannot figure out why it doesn't always work.  All parameters were met and my bluetooth keyboard is set correctly to wake the computer.  My keyboard becomes backlit, but my LG monitor does not pick up a video signal and is black and my laptop monitor is off.  The only way I can get out is to hold on button on laptop until it shuts down and I can start up again.  This happens on an intermittent basis.  Sometimes it works and other times I get black screens.   I need to know if I can use command F1 to get the laptop to detect the display or is their another key combination to send the signal to the external monitor when I can't see anything because I hate to do a hard shut down to get out of this mode!  Please advise!

  • HP Pavilion G6 (G6-2313AX) automatically stops music when I put the laptop lid down, please help?

    Hi,
    My Laptop is a Pavilion G6-2313AX (AMD A10-4600M with 7660G+7670M Dual Graphics) with genuine Windows 8. I use this laptop a lot in the school bus, while going in cars etc to listen to music. Problem is whenever I put my laptop screen down (It is set NOT to go to sleep mode), the track pauses on Windows Media Player, iTunes, any program. Someone please help me on what I should do to prevent this from happening!

    I understand that the music pauses when the notebook is closed.  When the notebook is closed, this is usually to move it from one place to another.  This may be triggering HP ProtectSmart which physically stops the HDD from spinning causing everything to pause until the HDD is stable.  Newser systems are more sensitive to protect the HDD and the data on it.
    This sounds like it's more in relation to ProtectSmart more so than a power plan.  Review this thread as it looks similar to your issue.  Disabling HP ProtectSmart is what fixed it for them.
    Let me know if this answered your question.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • How come my safari windows disappear when I close my laptop and open again? The safari windows I wanted to keep running for the next time I open my laptop disappeared. Why? Help me.

    How come my safari windows disappear when I close my laptop and open again? The safari windows I wanted to keep running for the next time I open my laptop disappeared. Why? Help me.

    Important note, do NOT sleep your macbook Air with headphones attached until this is resolved.
    Ive done a good best of testing on same to confirm not to do that
    also if you have the APP "BOOM" installed........ remove it

  • How do i run an external monitor with my macbook and change settings so that when i close the lid the signal to the monitor is not lost and i can continue using the mac with a mouse and a wireless keyboard?

    How do i run an external monitor with my macbook and change settings so that when i close the lid the signal to the monitor is not lost and i can continue using the mac with a mouse and a wireless keyboard?

    No, nothing will prevent the computer from going to sleep when you close its display except third-party hacks that are designed to do exactly that. I strongly advise against using any of those, as they may interfere with successful entry into clamshell mode (and they carry other downside risks as well). Just wait until the computer is asleep (with its sleep light pulsing), then press any key on the keyboard. It sounds as though your setup is working as it's designed to do.

  • I've connected my macbook pro (os 10.6.8) to an external display, but it will not go into clam shell mode!  When I close the lid the laptop goes to sleep, and I am unable to wake it using the external keyboard or mouse.

    A rundown of what I've tried:
    Adjusting energy settings to try to prevent sleep
    Pluging the USB keyboard and wacom tablet directly into the laptop (as opposed to a usb hub)
    My laptop's power cable is connected
    My display (a Vizio TV) is recognized in the System Preferences panel
    I'd been using this TV for about a year with my older Macbook Pro (OS 10.5.8), though using a different wireless keyboard and mouse
    ***Update:  The issue seems to lie with the keyboard and wacom tablet.  I am trying to use a wireless Case Logic keyboard (with dongal) and wired wacom tablet to wake the Macbook Pro in clamshell mode.  To experiment, I tried using my Logitech wireless keyboard & mouse set (also dongal) that I had been using before and it wakes the computer without any problems!  However, I really need to be able to use my wacom tablet.  If I switch to the tablet after waking the computer using the Logitech keyboard & mouse it works, but once the computer sleeps it won't work anymore.  I could keep switching back and forth I suppose, but it's sort of a pain.  There has to be an easier way!  Any ideas why the wired wacom tablet is unable to wake the computer in clamshell mode?
    Thanks!

    So your keyboard or mouse won't wake the Mac when you close the lid correct? Try resetting the SMC and pram
    Shut down the computer.
    Disconnect the MagSafe power adapter from the computer, if it's connected.
    Remove the battery.
    Press and hold the power button for 5 seconds.
    Release the power button.
    Reconnect the battery and MagSafe power adapter.
    Press the power button to turn on the computer.
    Resetting NVRAM / PRAM
    Shut down your Mac.
    Locate the following keys on the keyboard: Command (⌘), Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.

  • The new version of firefox does not shut down when I close the browser it continues running in the background. In addition it opens Adobe Reader for a brief time and then that closes. Everything worked fine before this new version.

    Firefox automatically loaded a new version recently. The new version does not shut down when I close the browser it continues running in the background. In addition it opens Adobe Reader for a brief time and then that closes. Everything worked fine before this new version.

    See "Hang at exit":
    * http://kb.mozillazine.org/Firefox_hangs
    * https://support.mozilla.com/kb/Firefox+hangs

  • Have most recent macbook pro connected to thunderbolt via thunderbolt cable.  Occasionally when I close my laptop the thunderbolt display goes black and does not come back on---even in response to keyboard.  Help

    Have most recent macbook pro connected to thunderbolt via thunderbolt cable.  Occasionally when I close my laptop the thunderbolt display goes black and does not come back on---even in response to keyboard.  Help

    Hello QuinnDev,
    Thank you for posting in the Apple Support Communities.  It sounds like you are trying to use your MacBook Pro with a Thunderbolt Display in closed clamshell mode (MacBook Pro closed), but sometimes the display doesn't stay on.  I found an article that talks about closed clamshell mode.  You would have to fulfill the following requirements to use your display this way:
    Requirements for closed display mode:
    Power adapter
    External keyboard, mouse, or trackpad
    External display
    You can find all the steps and the full article here:
    Mac notebooks: How to use your computer in closed clamshell (display closed) mode with an external display
    http://support.apple.com/kb/HT3131
    I hope this helps!
    All the best,
    Sheila M.

  • When I close the last tab I am sent to my desk top and do not stay on Firefox, but if I hit the open button again it says Firefox is running??

    This started this last weekend. When I close the last tab instead of staying on Firefox it goes directly to my desktop. If I hit the Firefox icon again I get a message saying that Firefox is still running and that I should restart. But if I just hit open again it reopens or shows Firefox home page again. How do I stop this?

    Set the pref browser.tabs.closeWindowWithLastTab to false on the about:config page to prevent closing the last tab from closing that window, you need to use "File > Close Window" or the close X on the title bar.
    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold(user set).
    *Preferences can be reset to the default or changed via the right-click context menu.
    You may need to wait a bit longer before restarting Firefox.
    See "Hang at exit":
    *http://kb.mozillazine.org/Firefox_hangs
    *https://support.mozilla.com/kb/Firefox+hangs

  • My computer is running slow after Yosemite install -but in the Mail program, when I open an email and then open the attachment -all is good -when I close the attachment the Mail program goes away, and I have to reopen it in my Dock -every time -been

    My computer is running slow after Yosemite install -but in the Mail program, when I open an email and then open the attachment -all is good -when I close the attachment the Mail program goes away, and I have to reopen it in my Dock -every time.

    I tried this, but no luck. I went to Previous System>Users. There is nothing inside the "Users" folder, so I hit a dead end.
    I can find my new e-mails -- those that came in since I re-installed the system -- in my NEW system (which I did to see if I was correctly understanding the advice), by going to Users>Home>Library>Mail>POP account name>Inbox.
    Let me add a new question: I am running PhotoShop C3. It opens OK, and I can use it, but when it opens I get this message: "One or more files for Adobe Application Support folder are missing. Please re-run the PhotoShop installer."
    I don't like re-installing working programs if I can avoid it, because it always seems to lead to other issues. Any idea what files are missing, and where it/they might be in the Previous System folder?
    thanks
    Mike

Maybe you are looking for