GNOME: disable sleep on lid close











up vote
13
down vote

favorite
6












Is it possible to stop my laptop going to sleep when I close the lid?



GNOME 3.20, Fedora 24.





My laptop does not reliably wake from sleep. (It happens to be a hardware issue... I think I basically killed it while trying to replace a wifi card. But I want to keep using it for a while longer).










share|improve this question


























    up vote
    13
    down vote

    favorite
    6












    Is it possible to stop my laptop going to sleep when I close the lid?



    GNOME 3.20, Fedora 24.





    My laptop does not reliably wake from sleep. (It happens to be a hardware issue... I think I basically killed it while trying to replace a wifi card. But I want to keep using it for a while longer).










    share|improve this question
























      up vote
      13
      down vote

      favorite
      6









      up vote
      13
      down vote

      favorite
      6






      6





      Is it possible to stop my laptop going to sleep when I close the lid?



      GNOME 3.20, Fedora 24.





      My laptop does not reliably wake from sleep. (It happens to be a hardware issue... I think I basically killed it while trying to replace a wifi card. But I want to keep using it for a while longer).










      share|improve this question













      Is it possible to stop my laptop going to sleep when I close the lid?



      GNOME 3.20, Fedora 24.





      My laptop does not reliably wake from sleep. (It happens to be a hardware issue... I think I basically killed it while trying to replace a wifi card. But I want to keep using it for a while longer).







      gnome suspend laptop






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 2 '16 at 16:23









      sourcejedi

      22.2k43397




      22.2k43397






















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          17
          down vote



          accepted










          Install GNOME Tweak Tool and go to the Power section. There's an option to disable the automatic suspend on lid close.



          Option details



          I compared dconf before and after to find the option, but it turns out that's not how it's implemented. Instead, Tweak Tool creates ~/.config/autostart/ignore-lid-switch-tweak.desktop. The autostart is a script which effectively runs systemd-inhibit --what=handle-lid-switch. So we can see the lid close action is handled purely by systemd-logind.



          Alternative route



          An alternative would be to edit /etc/systemd/logind.conf to include:



          HandleLidSwitch=ignore


          This would work all the time, not just when your user is logged in.






          share|improve this answer



















          • 1




            Also described in the gnome on-line help
            – don_crissti
            Sep 2 '16 at 17:56










          • Lol. It comes up in search results (8th down)... but I was searching "disable" instead of "stop". In that case Google shows the snippet "When you close the lid of your laptop, your computer will suspend in order to save power", and nothing else. I suspect I saw that, but I didn't think it was a promising avenue of investigation! I mainly posted this question to get an answer into the Google results. At least that's worked :). google.com/search?q=gnome+stop+lid+close+suspend
            – sourcejedi
            Sep 2 '16 at 19:21








          • 4




            Editing /etc/systemd/logind.conf instead of using GNOME Tweak Tool may be better because it works even when GNOME is not running, for example when working at the console.
            – Francesco Turco
            Sep 3 '16 at 17:41






          • 1




            @Ash thanks for the report, if you want to talk about collecting more information on that, it would probably work best elsewhere e.g. a separate question on this site, or a report on the Ubuntu bug tracker.
            – sourcejedi
            Nov 4 at 16:59








          • 1




            @sourcejedi I've got nvidia graphics -- which may be a big part of the problem :)
            – jocull
            Nov 9 at 19:50


















          up vote
          4
          down vote













          Unfortunately, the inhibitor routes didn't seem to work as advertised for me on openSUSE Tumbleweed (42.1) using GNOME. But, I had success with Systemd masking:



          systemctl mask sleep.target suspend.target


          To undo the mask, you can use unmask:



          systemctl unmask sleep.target suspend.target





          share|improve this answer























          • A serverfault answer pointed me in the right direction.
            – palswim
            Dec 15 '16 at 17:32










          • Nothing worked but this!!
            – markroxor
            Sep 9 at 6:45


















          up vote
          1
          down vote













          I had solved this issue once before, but it seems the latest versions of Fedora (I'm on Fedora 28 now), requires these two entries now, whereas before only the first one was necessary:



          user$ sudo vi /etc/systemd/logind.conf

          HandleLidSwitch=ignore <---- Set both of these
          HandleLidSwitchDocked=ignore <---- to ignore lid events.

          user$ sudo systemctl restart systemd-logind


          EDIT: As mentioned by commenters below, you might want to just reboot after making the edits.






          share|improve this answer



















          • 1




            Thanks! It would be safer to reboot though. If you restart logind on a default Fedora system, your graphical X session(s) will die (same with any Wayland compositor that I know about).
            – sourcejedi
            Oct 24 at 7:59












          • This worked great for me! But I would suggest just rebooting also. When I restarted systemd it got weird and I had to kill the machine anyway.
            – jocull
            Nov 9 at 15:26











          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',
          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%2f307497%2fgnome-disable-sleep-on-lid-close%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          17
          down vote



          accepted










          Install GNOME Tweak Tool and go to the Power section. There's an option to disable the automatic suspend on lid close.



          Option details



          I compared dconf before and after to find the option, but it turns out that's not how it's implemented. Instead, Tweak Tool creates ~/.config/autostart/ignore-lid-switch-tweak.desktop. The autostart is a script which effectively runs systemd-inhibit --what=handle-lid-switch. So we can see the lid close action is handled purely by systemd-logind.



          Alternative route



          An alternative would be to edit /etc/systemd/logind.conf to include:



          HandleLidSwitch=ignore


          This would work all the time, not just when your user is logged in.






          share|improve this answer



















          • 1




            Also described in the gnome on-line help
            – don_crissti
            Sep 2 '16 at 17:56










          • Lol. It comes up in search results (8th down)... but I was searching "disable" instead of "stop". In that case Google shows the snippet "When you close the lid of your laptop, your computer will suspend in order to save power", and nothing else. I suspect I saw that, but I didn't think it was a promising avenue of investigation! I mainly posted this question to get an answer into the Google results. At least that's worked :). google.com/search?q=gnome+stop+lid+close+suspend
            – sourcejedi
            Sep 2 '16 at 19:21








          • 4




            Editing /etc/systemd/logind.conf instead of using GNOME Tweak Tool may be better because it works even when GNOME is not running, for example when working at the console.
            – Francesco Turco
            Sep 3 '16 at 17:41






          • 1




            @Ash thanks for the report, if you want to talk about collecting more information on that, it would probably work best elsewhere e.g. a separate question on this site, or a report on the Ubuntu bug tracker.
            – sourcejedi
            Nov 4 at 16:59








          • 1




            @sourcejedi I've got nvidia graphics -- which may be a big part of the problem :)
            – jocull
            Nov 9 at 19:50















          up vote
          17
          down vote



          accepted










          Install GNOME Tweak Tool and go to the Power section. There's an option to disable the automatic suspend on lid close.



          Option details



          I compared dconf before and after to find the option, but it turns out that's not how it's implemented. Instead, Tweak Tool creates ~/.config/autostart/ignore-lid-switch-tweak.desktop. The autostart is a script which effectively runs systemd-inhibit --what=handle-lid-switch. So we can see the lid close action is handled purely by systemd-logind.



          Alternative route



          An alternative would be to edit /etc/systemd/logind.conf to include:



          HandleLidSwitch=ignore


          This would work all the time, not just when your user is logged in.






          share|improve this answer



















          • 1




            Also described in the gnome on-line help
            – don_crissti
            Sep 2 '16 at 17:56










          • Lol. It comes up in search results (8th down)... but I was searching "disable" instead of "stop". In that case Google shows the snippet "When you close the lid of your laptop, your computer will suspend in order to save power", and nothing else. I suspect I saw that, but I didn't think it was a promising avenue of investigation! I mainly posted this question to get an answer into the Google results. At least that's worked :). google.com/search?q=gnome+stop+lid+close+suspend
            – sourcejedi
            Sep 2 '16 at 19:21








          • 4




            Editing /etc/systemd/logind.conf instead of using GNOME Tweak Tool may be better because it works even when GNOME is not running, for example when working at the console.
            – Francesco Turco
            Sep 3 '16 at 17:41






          • 1




            @Ash thanks for the report, if you want to talk about collecting more information on that, it would probably work best elsewhere e.g. a separate question on this site, or a report on the Ubuntu bug tracker.
            – sourcejedi
            Nov 4 at 16:59








          • 1




            @sourcejedi I've got nvidia graphics -- which may be a big part of the problem :)
            – jocull
            Nov 9 at 19:50













          up vote
          17
          down vote



          accepted







          up vote
          17
          down vote



          accepted






          Install GNOME Tweak Tool and go to the Power section. There's an option to disable the automatic suspend on lid close.



          Option details



          I compared dconf before and after to find the option, but it turns out that's not how it's implemented. Instead, Tweak Tool creates ~/.config/autostart/ignore-lid-switch-tweak.desktop. The autostart is a script which effectively runs systemd-inhibit --what=handle-lid-switch. So we can see the lid close action is handled purely by systemd-logind.



          Alternative route



          An alternative would be to edit /etc/systemd/logind.conf to include:



          HandleLidSwitch=ignore


          This would work all the time, not just when your user is logged in.






          share|improve this answer














          Install GNOME Tweak Tool and go to the Power section. There's an option to disable the automatic suspend on lid close.



          Option details



          I compared dconf before and after to find the option, but it turns out that's not how it's implemented. Instead, Tweak Tool creates ~/.config/autostart/ignore-lid-switch-tweak.desktop. The autostart is a script which effectively runs systemd-inhibit --what=handle-lid-switch. So we can see the lid close action is handled purely by systemd-logind.



          Alternative route



          An alternative would be to edit /etc/systemd/logind.conf to include:



          HandleLidSwitch=ignore


          This would work all the time, not just when your user is logged in.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 3 '16 at 19:07

























          answered Sep 2 '16 at 16:23









          sourcejedi

          22.2k43397




          22.2k43397








          • 1




            Also described in the gnome on-line help
            – don_crissti
            Sep 2 '16 at 17:56










          • Lol. It comes up in search results (8th down)... but I was searching "disable" instead of "stop". In that case Google shows the snippet "When you close the lid of your laptop, your computer will suspend in order to save power", and nothing else. I suspect I saw that, but I didn't think it was a promising avenue of investigation! I mainly posted this question to get an answer into the Google results. At least that's worked :). google.com/search?q=gnome+stop+lid+close+suspend
            – sourcejedi
            Sep 2 '16 at 19:21








          • 4




            Editing /etc/systemd/logind.conf instead of using GNOME Tweak Tool may be better because it works even when GNOME is not running, for example when working at the console.
            – Francesco Turco
            Sep 3 '16 at 17:41






          • 1




            @Ash thanks for the report, if you want to talk about collecting more information on that, it would probably work best elsewhere e.g. a separate question on this site, or a report on the Ubuntu bug tracker.
            – sourcejedi
            Nov 4 at 16:59








          • 1




            @sourcejedi I've got nvidia graphics -- which may be a big part of the problem :)
            – jocull
            Nov 9 at 19:50














          • 1




            Also described in the gnome on-line help
            – don_crissti
            Sep 2 '16 at 17:56










          • Lol. It comes up in search results (8th down)... but I was searching "disable" instead of "stop". In that case Google shows the snippet "When you close the lid of your laptop, your computer will suspend in order to save power", and nothing else. I suspect I saw that, but I didn't think it was a promising avenue of investigation! I mainly posted this question to get an answer into the Google results. At least that's worked :). google.com/search?q=gnome+stop+lid+close+suspend
            – sourcejedi
            Sep 2 '16 at 19:21








          • 4




            Editing /etc/systemd/logind.conf instead of using GNOME Tweak Tool may be better because it works even when GNOME is not running, for example when working at the console.
            – Francesco Turco
            Sep 3 '16 at 17:41






          • 1




            @Ash thanks for the report, if you want to talk about collecting more information on that, it would probably work best elsewhere e.g. a separate question on this site, or a report on the Ubuntu bug tracker.
            – sourcejedi
            Nov 4 at 16:59








          • 1




            @sourcejedi I've got nvidia graphics -- which may be a big part of the problem :)
            – jocull
            Nov 9 at 19:50








          1




          1




          Also described in the gnome on-line help
          – don_crissti
          Sep 2 '16 at 17:56




          Also described in the gnome on-line help
          – don_crissti
          Sep 2 '16 at 17:56












          Lol. It comes up in search results (8th down)... but I was searching "disable" instead of "stop". In that case Google shows the snippet "When you close the lid of your laptop, your computer will suspend in order to save power", and nothing else. I suspect I saw that, but I didn't think it was a promising avenue of investigation! I mainly posted this question to get an answer into the Google results. At least that's worked :). google.com/search?q=gnome+stop+lid+close+suspend
          – sourcejedi
          Sep 2 '16 at 19:21






          Lol. It comes up in search results (8th down)... but I was searching "disable" instead of "stop". In that case Google shows the snippet "When you close the lid of your laptop, your computer will suspend in order to save power", and nothing else. I suspect I saw that, but I didn't think it was a promising avenue of investigation! I mainly posted this question to get an answer into the Google results. At least that's worked :). google.com/search?q=gnome+stop+lid+close+suspend
          – sourcejedi
          Sep 2 '16 at 19:21






          4




          4




          Editing /etc/systemd/logind.conf instead of using GNOME Tweak Tool may be better because it works even when GNOME is not running, for example when working at the console.
          – Francesco Turco
          Sep 3 '16 at 17:41




          Editing /etc/systemd/logind.conf instead of using GNOME Tweak Tool may be better because it works even when GNOME is not running, for example when working at the console.
          – Francesco Turco
          Sep 3 '16 at 17:41




          1




          1




          @Ash thanks for the report, if you want to talk about collecting more information on that, it would probably work best elsewhere e.g. a separate question on this site, or a report on the Ubuntu bug tracker.
          – sourcejedi
          Nov 4 at 16:59






          @Ash thanks for the report, if you want to talk about collecting more information on that, it would probably work best elsewhere e.g. a separate question on this site, or a report on the Ubuntu bug tracker.
          – sourcejedi
          Nov 4 at 16:59






          1




          1




          @sourcejedi I've got nvidia graphics -- which may be a big part of the problem :)
          – jocull
          Nov 9 at 19:50




          @sourcejedi I've got nvidia graphics -- which may be a big part of the problem :)
          – jocull
          Nov 9 at 19:50












          up vote
          4
          down vote













          Unfortunately, the inhibitor routes didn't seem to work as advertised for me on openSUSE Tumbleweed (42.1) using GNOME. But, I had success with Systemd masking:



          systemctl mask sleep.target suspend.target


          To undo the mask, you can use unmask:



          systemctl unmask sleep.target suspend.target





          share|improve this answer























          • A serverfault answer pointed me in the right direction.
            – palswim
            Dec 15 '16 at 17:32










          • Nothing worked but this!!
            – markroxor
            Sep 9 at 6:45















          up vote
          4
          down vote













          Unfortunately, the inhibitor routes didn't seem to work as advertised for me on openSUSE Tumbleweed (42.1) using GNOME. But, I had success with Systemd masking:



          systemctl mask sleep.target suspend.target


          To undo the mask, you can use unmask:



          systemctl unmask sleep.target suspend.target





          share|improve this answer























          • A serverfault answer pointed me in the right direction.
            – palswim
            Dec 15 '16 at 17:32










          • Nothing worked but this!!
            – markroxor
            Sep 9 at 6:45













          up vote
          4
          down vote










          up vote
          4
          down vote









          Unfortunately, the inhibitor routes didn't seem to work as advertised for me on openSUSE Tumbleweed (42.1) using GNOME. But, I had success with Systemd masking:



          systemctl mask sleep.target suspend.target


          To undo the mask, you can use unmask:



          systemctl unmask sleep.target suspend.target





          share|improve this answer














          Unfortunately, the inhibitor routes didn't seem to work as advertised for me on openSUSE Tumbleweed (42.1) using GNOME. But, I had success with Systemd masking:



          systemctl mask sleep.target suspend.target


          To undo the mask, you can use unmask:



          systemctl unmask sleep.target suspend.target






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 15 '16 at 17:31

























          answered Dec 15 '16 at 7:07









          palswim

          1,34611630




          1,34611630












          • A serverfault answer pointed me in the right direction.
            – palswim
            Dec 15 '16 at 17:32










          • Nothing worked but this!!
            – markroxor
            Sep 9 at 6:45


















          • A serverfault answer pointed me in the right direction.
            – palswim
            Dec 15 '16 at 17:32










          • Nothing worked but this!!
            – markroxor
            Sep 9 at 6:45
















          A serverfault answer pointed me in the right direction.
          – palswim
          Dec 15 '16 at 17:32




          A serverfault answer pointed me in the right direction.
          – palswim
          Dec 15 '16 at 17:32












          Nothing worked but this!!
          – markroxor
          Sep 9 at 6:45




          Nothing worked but this!!
          – markroxor
          Sep 9 at 6:45










          up vote
          1
          down vote













          I had solved this issue once before, but it seems the latest versions of Fedora (I'm on Fedora 28 now), requires these two entries now, whereas before only the first one was necessary:



          user$ sudo vi /etc/systemd/logind.conf

          HandleLidSwitch=ignore <---- Set both of these
          HandleLidSwitchDocked=ignore <---- to ignore lid events.

          user$ sudo systemctl restart systemd-logind


          EDIT: As mentioned by commenters below, you might want to just reboot after making the edits.






          share|improve this answer



















          • 1




            Thanks! It would be safer to reboot though. If you restart logind on a default Fedora system, your graphical X session(s) will die (same with any Wayland compositor that I know about).
            – sourcejedi
            Oct 24 at 7:59












          • This worked great for me! But I would suggest just rebooting also. When I restarted systemd it got weird and I had to kill the machine anyway.
            – jocull
            Nov 9 at 15:26















          up vote
          1
          down vote













          I had solved this issue once before, but it seems the latest versions of Fedora (I'm on Fedora 28 now), requires these two entries now, whereas before only the first one was necessary:



          user$ sudo vi /etc/systemd/logind.conf

          HandleLidSwitch=ignore <---- Set both of these
          HandleLidSwitchDocked=ignore <---- to ignore lid events.

          user$ sudo systemctl restart systemd-logind


          EDIT: As mentioned by commenters below, you might want to just reboot after making the edits.






          share|improve this answer



















          • 1




            Thanks! It would be safer to reboot though. If you restart logind on a default Fedora system, your graphical X session(s) will die (same with any Wayland compositor that I know about).
            – sourcejedi
            Oct 24 at 7:59












          • This worked great for me! But I would suggest just rebooting also. When I restarted systemd it got weird and I had to kill the machine anyway.
            – jocull
            Nov 9 at 15:26













          up vote
          1
          down vote










          up vote
          1
          down vote









          I had solved this issue once before, but it seems the latest versions of Fedora (I'm on Fedora 28 now), requires these two entries now, whereas before only the first one was necessary:



          user$ sudo vi /etc/systemd/logind.conf

          HandleLidSwitch=ignore <---- Set both of these
          HandleLidSwitchDocked=ignore <---- to ignore lid events.

          user$ sudo systemctl restart systemd-logind


          EDIT: As mentioned by commenters below, you might want to just reboot after making the edits.






          share|improve this answer














          I had solved this issue once before, but it seems the latest versions of Fedora (I'm on Fedora 28 now), requires these two entries now, whereas before only the first one was necessary:



          user$ sudo vi /etc/systemd/logind.conf

          HandleLidSwitch=ignore <---- Set both of these
          HandleLidSwitchDocked=ignore <---- to ignore lid events.

          user$ sudo systemctl restart systemd-logind


          EDIT: As mentioned by commenters below, you might want to just reboot after making the edits.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 9 at 15:31

























          answered Aug 3 at 19:09









          prismalytics.io

          1268




          1268








          • 1




            Thanks! It would be safer to reboot though. If you restart logind on a default Fedora system, your graphical X session(s) will die (same with any Wayland compositor that I know about).
            – sourcejedi
            Oct 24 at 7:59












          • This worked great for me! But I would suggest just rebooting also. When I restarted systemd it got weird and I had to kill the machine anyway.
            – jocull
            Nov 9 at 15:26














          • 1




            Thanks! It would be safer to reboot though. If you restart logind on a default Fedora system, your graphical X session(s) will die (same with any Wayland compositor that I know about).
            – sourcejedi
            Oct 24 at 7:59












          • This worked great for me! But I would suggest just rebooting also. When I restarted systemd it got weird and I had to kill the machine anyway.
            – jocull
            Nov 9 at 15:26








          1




          1




          Thanks! It would be safer to reboot though. If you restart logind on a default Fedora system, your graphical X session(s) will die (same with any Wayland compositor that I know about).
          – sourcejedi
          Oct 24 at 7:59






          Thanks! It would be safer to reboot though. If you restart logind on a default Fedora system, your graphical X session(s) will die (same with any Wayland compositor that I know about).
          – sourcejedi
          Oct 24 at 7:59














          This worked great for me! But I would suggest just rebooting also. When I restarted systemd it got weird and I had to kill the machine anyway.
          – jocull
          Nov 9 at 15:26




          This worked great for me! But I would suggest just rebooting also. When I restarted systemd it got weird and I had to kill the machine anyway.
          – jocull
          Nov 9 at 15:26


















          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%2f307497%2fgnome-disable-sleep-on-lid-close%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

          Entries order in /etc/network/interfaces

          新発田市

          Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)