How to detect if computer is asleep

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








up vote
2
down vote

favorite












I am trying to find a way to query the state of my laptop from the terminal. I would like to know if it is asleep or awake.



Is there a dbus query suitable for this?










share|improve this question





















  • What do you mean by asleep? well when you start typing it's active...
    – Ravexina
    Mar 28 at 20:40






  • 4




    Still I can't get what do you mean by asleep, you can get the IDLE time using xprintidle, when your PC is sleep, well it's off, it can't do anything.
    – Ravexina
    Mar 28 at 20:43







  • 2




    Sleep mode suspends the system to RAM so nothing is running. You would not be able to connect to your system in sleep mode, unless you had WOL (Wake On LAN) configured to wake the system back up so you could use it. It sounds to me that you would not be able to see if your system is asleep as it would wake up once you connected to it. See: en.wikipedia.org/wiki/Sleep_mode
    – Terrance
    Mar 28 at 21:14






  • 1




    This is like asking your roommate whether he's asleep. Assuming he doesn't lie, there's no way he'd ever answer yes.
    – Byte Commander
    Mar 28 at 23:06






  • 2




    Reviewers: Although this question does appear to hinge on a misunderstanding of what sleep mode entails, this can be addressed in an an answer, which would answer the question. @Terrance Can you post something like that comment as an answer?
    – Eliah Kagan
    Mar 29 at 20:36














up vote
2
down vote

favorite












I am trying to find a way to query the state of my laptop from the terminal. I would like to know if it is asleep or awake.



Is there a dbus query suitable for this?










share|improve this question





















  • What do you mean by asleep? well when you start typing it's active...
    – Ravexina
    Mar 28 at 20:40






  • 4




    Still I can't get what do you mean by asleep, you can get the IDLE time using xprintidle, when your PC is sleep, well it's off, it can't do anything.
    – Ravexina
    Mar 28 at 20:43







  • 2




    Sleep mode suspends the system to RAM so nothing is running. You would not be able to connect to your system in sleep mode, unless you had WOL (Wake On LAN) configured to wake the system back up so you could use it. It sounds to me that you would not be able to see if your system is asleep as it would wake up once you connected to it. See: en.wikipedia.org/wiki/Sleep_mode
    – Terrance
    Mar 28 at 21:14






  • 1




    This is like asking your roommate whether he's asleep. Assuming he doesn't lie, there's no way he'd ever answer yes.
    – Byte Commander
    Mar 28 at 23:06






  • 2




    Reviewers: Although this question does appear to hinge on a misunderstanding of what sleep mode entails, this can be addressed in an an answer, which would answer the question. @Terrance Can you post something like that comment as an answer?
    – Eliah Kagan
    Mar 29 at 20:36












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am trying to find a way to query the state of my laptop from the terminal. I would like to know if it is asleep or awake.



Is there a dbus query suitable for this?










share|improve this question













I am trying to find a way to query the state of my laptop from the terminal. I would like to know if it is asleep or awake.



Is there a dbus query suitable for this?







dbus detect






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 20:31









Senior-Jesticle

142




142











  • What do you mean by asleep? well when you start typing it's active...
    – Ravexina
    Mar 28 at 20:40






  • 4




    Still I can't get what do you mean by asleep, you can get the IDLE time using xprintidle, when your PC is sleep, well it's off, it can't do anything.
    – Ravexina
    Mar 28 at 20:43







  • 2




    Sleep mode suspends the system to RAM so nothing is running. You would not be able to connect to your system in sleep mode, unless you had WOL (Wake On LAN) configured to wake the system back up so you could use it. It sounds to me that you would not be able to see if your system is asleep as it would wake up once you connected to it. See: en.wikipedia.org/wiki/Sleep_mode
    – Terrance
    Mar 28 at 21:14






  • 1




    This is like asking your roommate whether he's asleep. Assuming he doesn't lie, there's no way he'd ever answer yes.
    – Byte Commander
    Mar 28 at 23:06






  • 2




    Reviewers: Although this question does appear to hinge on a misunderstanding of what sleep mode entails, this can be addressed in an an answer, which would answer the question. @Terrance Can you post something like that comment as an answer?
    – Eliah Kagan
    Mar 29 at 20:36
















  • What do you mean by asleep? well when you start typing it's active...
    – Ravexina
    Mar 28 at 20:40






  • 4




    Still I can't get what do you mean by asleep, you can get the IDLE time using xprintidle, when your PC is sleep, well it's off, it can't do anything.
    – Ravexina
    Mar 28 at 20:43







  • 2




    Sleep mode suspends the system to RAM so nothing is running. You would not be able to connect to your system in sleep mode, unless you had WOL (Wake On LAN) configured to wake the system back up so you could use it. It sounds to me that you would not be able to see if your system is asleep as it would wake up once you connected to it. See: en.wikipedia.org/wiki/Sleep_mode
    – Terrance
    Mar 28 at 21:14






  • 1




    This is like asking your roommate whether he's asleep. Assuming he doesn't lie, there's no way he'd ever answer yes.
    – Byte Commander
    Mar 28 at 23:06






  • 2




    Reviewers: Although this question does appear to hinge on a misunderstanding of what sleep mode entails, this can be addressed in an an answer, which would answer the question. @Terrance Can you post something like that comment as an answer?
    – Eliah Kagan
    Mar 29 at 20:36















What do you mean by asleep? well when you start typing it's active...
– Ravexina
Mar 28 at 20:40




What do you mean by asleep? well when you start typing it's active...
– Ravexina
Mar 28 at 20:40




4




4




Still I can't get what do you mean by asleep, you can get the IDLE time using xprintidle, when your PC is sleep, well it's off, it can't do anything.
– Ravexina
Mar 28 at 20:43





Still I can't get what do you mean by asleep, you can get the IDLE time using xprintidle, when your PC is sleep, well it's off, it can't do anything.
– Ravexina
Mar 28 at 20:43





2




2




Sleep mode suspends the system to RAM so nothing is running. You would not be able to connect to your system in sleep mode, unless you had WOL (Wake On LAN) configured to wake the system back up so you could use it. It sounds to me that you would not be able to see if your system is asleep as it would wake up once you connected to it. See: en.wikipedia.org/wiki/Sleep_mode
– Terrance
Mar 28 at 21:14




Sleep mode suspends the system to RAM so nothing is running. You would not be able to connect to your system in sleep mode, unless you had WOL (Wake On LAN) configured to wake the system back up so you could use it. It sounds to me that you would not be able to see if your system is asleep as it would wake up once you connected to it. See: en.wikipedia.org/wiki/Sleep_mode
– Terrance
Mar 28 at 21:14




1




1




This is like asking your roommate whether he's asleep. Assuming he doesn't lie, there's no way he'd ever answer yes.
– Byte Commander
Mar 28 at 23:06




This is like asking your roommate whether he's asleep. Assuming he doesn't lie, there's no way he'd ever answer yes.
– Byte Commander
Mar 28 at 23:06




2




2




Reviewers: Although this question does appear to hinge on a misunderstanding of what sleep mode entails, this can be addressed in an an answer, which would answer the question. @Terrance Can you post something like that comment as an answer?
– Eliah Kagan
Mar 29 at 20:36




Reviewers: Although this question does appear to hinge on a misunderstanding of what sleep mode entails, this can be addressed in an an answer, which would answer the question. @Terrance Can you post something like that comment as an answer?
– Eliah Kagan
Mar 29 at 20:36










1 Answer
1






active

oldest

votes

















up vote
5
down vote













Sleep mode on a computer suspends its current state to the RAM. The computer will then go into a low power mode keeping enough power going to the RAM to keep the suspended state. No applications are running at this time.



To wake the computer back up from a remote session would have to be done by a WOL (Wake On LAN) which is controlled by the motherboard. This would then wake the system back up. ssh daemons would not be running at the time the system is asleep so you would not be able to connect to the host that way. Once the magic packet is sent to WOL, the system would no longer be in the sleep state so the answer would be false every time for sleep.



See https://en.wikipedia.org/wiki/Sleep_mode for more information.



There would be one other way to find out if a system is powered on or not from a remote console but that requires special hardware that supports Out-of-band Management that is normally built into server hardware. There are some remote power management items that can be purchased for systems without the management, but they can be pricey and only control the power itself. Here are some that I did a quick search for.



Hope this helps!






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1020088%2fhow-to-detect-if-computer-is-asleep%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    5
    down vote













    Sleep mode on a computer suspends its current state to the RAM. The computer will then go into a low power mode keeping enough power going to the RAM to keep the suspended state. No applications are running at this time.



    To wake the computer back up from a remote session would have to be done by a WOL (Wake On LAN) which is controlled by the motherboard. This would then wake the system back up. ssh daemons would not be running at the time the system is asleep so you would not be able to connect to the host that way. Once the magic packet is sent to WOL, the system would no longer be in the sleep state so the answer would be false every time for sleep.



    See https://en.wikipedia.org/wiki/Sleep_mode for more information.



    There would be one other way to find out if a system is powered on or not from a remote console but that requires special hardware that supports Out-of-band Management that is normally built into server hardware. There are some remote power management items that can be purchased for systems without the management, but they can be pricey and only control the power itself. Here are some that I did a quick search for.



    Hope this helps!






    share|improve this answer


























      up vote
      5
      down vote













      Sleep mode on a computer suspends its current state to the RAM. The computer will then go into a low power mode keeping enough power going to the RAM to keep the suspended state. No applications are running at this time.



      To wake the computer back up from a remote session would have to be done by a WOL (Wake On LAN) which is controlled by the motherboard. This would then wake the system back up. ssh daemons would not be running at the time the system is asleep so you would not be able to connect to the host that way. Once the magic packet is sent to WOL, the system would no longer be in the sleep state so the answer would be false every time for sleep.



      See https://en.wikipedia.org/wiki/Sleep_mode for more information.



      There would be one other way to find out if a system is powered on or not from a remote console but that requires special hardware that supports Out-of-band Management that is normally built into server hardware. There are some remote power management items that can be purchased for systems without the management, but they can be pricey and only control the power itself. Here are some that I did a quick search for.



      Hope this helps!






      share|improve this answer
























        up vote
        5
        down vote










        up vote
        5
        down vote









        Sleep mode on a computer suspends its current state to the RAM. The computer will then go into a low power mode keeping enough power going to the RAM to keep the suspended state. No applications are running at this time.



        To wake the computer back up from a remote session would have to be done by a WOL (Wake On LAN) which is controlled by the motherboard. This would then wake the system back up. ssh daemons would not be running at the time the system is asleep so you would not be able to connect to the host that way. Once the magic packet is sent to WOL, the system would no longer be in the sleep state so the answer would be false every time for sleep.



        See https://en.wikipedia.org/wiki/Sleep_mode for more information.



        There would be one other way to find out if a system is powered on or not from a remote console but that requires special hardware that supports Out-of-band Management that is normally built into server hardware. There are some remote power management items that can be purchased for systems without the management, but they can be pricey and only control the power itself. Here are some that I did a quick search for.



        Hope this helps!






        share|improve this answer














        Sleep mode on a computer suspends its current state to the RAM. The computer will then go into a low power mode keeping enough power going to the RAM to keep the suspended state. No applications are running at this time.



        To wake the computer back up from a remote session would have to be done by a WOL (Wake On LAN) which is controlled by the motherboard. This would then wake the system back up. ssh daemons would not be running at the time the system is asleep so you would not be able to connect to the host that way. Once the magic packet is sent to WOL, the system would no longer be in the sleep state so the answer would be false every time for sleep.



        See https://en.wikipedia.org/wiki/Sleep_mode for more information.



        There would be one other way to find out if a system is powered on or not from a remote console but that requires special hardware that supports Out-of-band Management that is normally built into server hardware. There are some remote power management items that can be purchased for systems without the management, but they can be pricey and only control the power itself. Here are some that I did a quick search for.



        Hope this helps!







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 29 at 21:42

























        answered Mar 29 at 21:26









        Terrance

        17.3k23784




        17.3k23784



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1020088%2fhow-to-detect-if-computer-is-asleep%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491