Ubuntu 18.04 doesn't lock when I close the lid

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1














Here's what I did:

I created a file /etc/acpi/events/lm_lid and wrote into it:



event=button/lid.*
action=/etc/acpi/lid.sh


I created a file /etc/acpi/lid.sh and wrote into it:



#!/bin/sh 
gnome-screensaver-command --lock


The good news are that this script is being executed when I close the lid. The bad news are that it doesn't lock the system.
Any other command I put in the script is executed when I close the lid except the lock itself. When I run the script manually from command line the system locks.



What did I miss?










share|improve this question



















  • 1




    I think your problem might be that that script is executed outside the X session you want to lock (and probably as another user) .You probably need gnome (I assume that you wanting to run gnome-screensaver is an indication you use gnome) to help you.
    – Henrik
    Dec 24 '18 at 12:38
















1














Here's what I did:

I created a file /etc/acpi/events/lm_lid and wrote into it:



event=button/lid.*
action=/etc/acpi/lid.sh


I created a file /etc/acpi/lid.sh and wrote into it:



#!/bin/sh 
gnome-screensaver-command --lock


The good news are that this script is being executed when I close the lid. The bad news are that it doesn't lock the system.
Any other command I put in the script is executed when I close the lid except the lock itself. When I run the script manually from command line the system locks.



What did I miss?










share|improve this question



















  • 1




    I think your problem might be that that script is executed outside the X session you want to lock (and probably as another user) .You probably need gnome (I assume that you wanting to run gnome-screensaver is an indication you use gnome) to help you.
    – Henrik
    Dec 24 '18 at 12:38














1












1








1







Here's what I did:

I created a file /etc/acpi/events/lm_lid and wrote into it:



event=button/lid.*
action=/etc/acpi/lid.sh


I created a file /etc/acpi/lid.sh and wrote into it:



#!/bin/sh 
gnome-screensaver-command --lock


The good news are that this script is being executed when I close the lid. The bad news are that it doesn't lock the system.
Any other command I put in the script is executed when I close the lid except the lock itself. When I run the script manually from command line the system locks.



What did I miss?










share|improve this question















Here's what I did:

I created a file /etc/acpi/events/lm_lid and wrote into it:



event=button/lid.*
action=/etc/acpi/lid.sh


I created a file /etc/acpi/lid.sh and wrote into it:



#!/bin/sh 
gnome-screensaver-command --lock


The good news are that this script is being executed when I close the lid. The bad news are that it doesn't lock the system.
Any other command I put in the script is executed when I close the lid except the lock itself. When I run the script manually from command line the system locks.



What did I miss?







ubuntu power-management acpi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 30 '18 at 17:37









Jeff Schaller

39k1053125




39k1053125










asked Dec 24 '18 at 11:48









JothamB

61




61







  • 1




    I think your problem might be that that script is executed outside the X session you want to lock (and probably as another user) .You probably need gnome (I assume that you wanting to run gnome-screensaver is an indication you use gnome) to help you.
    – Henrik
    Dec 24 '18 at 12:38













  • 1




    I think your problem might be that that script is executed outside the X session you want to lock (and probably as another user) .You probably need gnome (I assume that you wanting to run gnome-screensaver is an indication you use gnome) to help you.
    – Henrik
    Dec 24 '18 at 12:38








1




1




I think your problem might be that that script is executed outside the X session you want to lock (and probably as another user) .You probably need gnome (I assume that you wanting to run gnome-screensaver is an indication you use gnome) to help you.
– Henrik
Dec 24 '18 at 12:38





I think your problem might be that that script is executed outside the X session you want to lock (and probably as another user) .You probably need gnome (I assume that you wanting to run gnome-screensaver is an indication you use gnome) to help you.
– Henrik
Dec 24 '18 at 12:38











2 Answers
2






active

oldest

votes


















0














I'm using Debian and faced similar problem,
first, i wont recommend script because it doesn't work in lock screen.



if you are using gnome install gnome-tweaks and it has a option.



alternatively edit the /etc/systemd/logind.conf, just uncomment the HandleLidSwitch=suspend line.



this worked for me.






share|improve this answer




















  • Thanks. I can suspend the system but I want to lock it.
    – JothamB
    Dec 24 '18 at 16:28










  • @JothamB There's a setting in Gnome settings under privacy, screen lock. Click on it and set the lock screen after blank for to the option screen turns off.
    – Kushagra Karira
    Dec 25 '18 at 17:23



















0














Try downloading gnome-tweaks and there should be an option about locking when closing the lid.



To download gnome -tweaks do:
sudo apt install gnome-tweaks-tool



You can also use this for tweaking things like right clicking and left clicking.






share|improve this answer




















  • It only has an option to suspend. I want to lock without suspending.
    – JothamB
    Dec 27 '18 at 11:08










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f490757%2fubuntu-18-04-doesnt-lock-when-i-close-the-lid%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I'm using Debian and faced similar problem,
first, i wont recommend script because it doesn't work in lock screen.



if you are using gnome install gnome-tweaks and it has a option.



alternatively edit the /etc/systemd/logind.conf, just uncomment the HandleLidSwitch=suspend line.



this worked for me.






share|improve this answer




















  • Thanks. I can suspend the system but I want to lock it.
    – JothamB
    Dec 24 '18 at 16:28










  • @JothamB There's a setting in Gnome settings under privacy, screen lock. Click on it and set the lock screen after blank for to the option screen turns off.
    – Kushagra Karira
    Dec 25 '18 at 17:23
















0














I'm using Debian and faced similar problem,
first, i wont recommend script because it doesn't work in lock screen.



if you are using gnome install gnome-tweaks and it has a option.



alternatively edit the /etc/systemd/logind.conf, just uncomment the HandleLidSwitch=suspend line.



this worked for me.






share|improve this answer




















  • Thanks. I can suspend the system but I want to lock it.
    – JothamB
    Dec 24 '18 at 16:28










  • @JothamB There's a setting in Gnome settings under privacy, screen lock. Click on it and set the lock screen after blank for to the option screen turns off.
    – Kushagra Karira
    Dec 25 '18 at 17:23














0












0








0






I'm using Debian and faced similar problem,
first, i wont recommend script because it doesn't work in lock screen.



if you are using gnome install gnome-tweaks and it has a option.



alternatively edit the /etc/systemd/logind.conf, just uncomment the HandleLidSwitch=suspend line.



this worked for me.






share|improve this answer












I'm using Debian and faced similar problem,
first, i wont recommend script because it doesn't work in lock screen.



if you are using gnome install gnome-tweaks and it has a option.



alternatively edit the /etc/systemd/logind.conf, just uncomment the HandleLidSwitch=suspend line.



this worked for me.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 24 '18 at 12:00









Kushagra Karira

166




166











  • Thanks. I can suspend the system but I want to lock it.
    – JothamB
    Dec 24 '18 at 16:28










  • @JothamB There's a setting in Gnome settings under privacy, screen lock. Click on it and set the lock screen after blank for to the option screen turns off.
    – Kushagra Karira
    Dec 25 '18 at 17:23

















  • Thanks. I can suspend the system but I want to lock it.
    – JothamB
    Dec 24 '18 at 16:28










  • @JothamB There's a setting in Gnome settings under privacy, screen lock. Click on it and set the lock screen after blank for to the option screen turns off.
    – Kushagra Karira
    Dec 25 '18 at 17:23
















Thanks. I can suspend the system but I want to lock it.
– JothamB
Dec 24 '18 at 16:28




Thanks. I can suspend the system but I want to lock it.
– JothamB
Dec 24 '18 at 16:28












@JothamB There's a setting in Gnome settings under privacy, screen lock. Click on it and set the lock screen after blank for to the option screen turns off.
– Kushagra Karira
Dec 25 '18 at 17:23





@JothamB There's a setting in Gnome settings under privacy, screen lock. Click on it and set the lock screen after blank for to the option screen turns off.
– Kushagra Karira
Dec 25 '18 at 17:23














0














Try downloading gnome-tweaks and there should be an option about locking when closing the lid.



To download gnome -tweaks do:
sudo apt install gnome-tweaks-tool



You can also use this for tweaking things like right clicking and left clicking.






share|improve this answer




















  • It only has an option to suspend. I want to lock without suspending.
    – JothamB
    Dec 27 '18 at 11:08















0














Try downloading gnome-tweaks and there should be an option about locking when closing the lid.



To download gnome -tweaks do:
sudo apt install gnome-tweaks-tool



You can also use this for tweaking things like right clicking and left clicking.






share|improve this answer




















  • It only has an option to suspend. I want to lock without suspending.
    – JothamB
    Dec 27 '18 at 11:08













0












0








0






Try downloading gnome-tweaks and there should be an option about locking when closing the lid.



To download gnome -tweaks do:
sudo apt install gnome-tweaks-tool



You can also use this for tweaking things like right clicking and left clicking.






share|improve this answer












Try downloading gnome-tweaks and there should be an option about locking when closing the lid.



To download gnome -tweaks do:
sudo apt install gnome-tweaks-tool



You can also use this for tweaking things like right clicking and left clicking.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 25 '18 at 17:43









maxim pavlenko

161




161











  • It only has an option to suspend. I want to lock without suspending.
    – JothamB
    Dec 27 '18 at 11:08
















  • It only has an option to suspend. I want to lock without suspending.
    – JothamB
    Dec 27 '18 at 11:08















It only has an option to suspend. I want to lock without suspending.
– JothamB
Dec 27 '18 at 11:08




It only has an option to suspend. I want to lock without suspending.
– JothamB
Dec 27 '18 at 11:08

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f490757%2fubuntu-18-04-doesnt-lock-when-i-close-the-lid%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?