No internet connection
  1. Home
  2. Support

Turning off display

By Jonathan Grossman @Jonathan_Grossman
    2020-05-13 17:00:03.955Z

    Is there a way to program the keys SHIFT CONTROL EJECT which will put the displays to sleep. Looks like EJECT isn't on the SF keyboard.

    • 10 replies
    1. Kitch Membery @Kitch2020-05-13 21:07:19.302Z

      Hi Jonathan,

      you could use a system command line like this;

      sf.system.exec({
          commandLine: 'pmset displaysleepnow',
      });
      

      Rock on!

      1. you rule! Thanks Kitch. Hope you're well.

        1. Kitch Membery @Kitch2020-05-13 21:35:35.815Z

          You too Jonathan!

      2. T
        Tom Mochiach @Tom_Mochiach
          2022-07-18 09:12:35.353Z

          hi
          it does not work for me
          I'm on MacBook Pro 2022 with an external thunderbolt 27

          1. RRob Byers @Rob_Byers
              2023-01-20 19:24:37.894Z

              I am having the same result as Tom. MacBook Pro 2021 with external displays via USB C and Displayport (USB C).

              @Kitch might you have any ideas?

              1. Kitch Membery @Kitch2023-01-20 21:06:08.770Z

                Hi @Rob_Byers,

                Other than using this the following code.

                sf.system.exec({
                    commandLine: 'pmset displaysleepnow',
                });
                

                I'm unaware of a way to do this.

                If I find a way I'll let you know. :-)

                1. In reply toRob_Byers:
                  Kitch Membery @Kitch2023-01-20 21:32:11.294Z

                  @Rob_Byers

                  You could also try adding the force tag to the code like this.

                  sf.system.exec({
                      commandLine: 'pmset displaysleepnow force',
                  });
                  

                  From what I understand, the "force" option in the command pmset displaysleepnow force is used to put external monitors to sleep even if it is the primary display.

                  By default, when you run the command pmset displaysleepnow, the command will only put secondary displays to sleep, leaving the primary display active. However, when you use the force option, the command will put the primary display to sleep as well.

                  So if you have multiple monitors connected to your Mac it will turn off all of them.

                  I have not tested it though.

                  1. RRob Byers @Rob_Byers
                      2023-01-21 16:34:27.519Z

                      Thank you, Kitch, I will try this. Appreciate your help, as always.

                      1. RRob Byers @Rob_Byers
                          2023-01-23 14:28:41.570Z

                          Kitch, I just gave this a try to no avail. Upon running the script, there are no changes on-screen.

                          I'm running an Macbook Pro M1 Max in clamshell mode. I bet the clamshell mode is getting in the way!

                          1. Kitch Membery @Kitch2023-01-23 19:56:31.758Z

                            That's a shame. I'll let you know if I find an alternative method.