How to determine if screensaver is active on another session

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











up vote
1
down vote

favorite
2












You can detect if a user's screensaver is active via:



gnome-screensaver-command -q


I'm trying to create a daemon to perform actions when the user is inactive, but I'm finding this command always returns false when not run from inside the user's session. For example, these variants all report the screensaver is inactive, even when it's active:



sudo gnome-screensaver-command -q
sudo -u myuser gnome-screensaver-command -q


Why is this, and how do I check the status of a user's screen from a different user like root?










share|improve this question



























    up vote
    1
    down vote

    favorite
    2












    You can detect if a user's screensaver is active via:



    gnome-screensaver-command -q


    I'm trying to create a daemon to perform actions when the user is inactive, but I'm finding this command always returns false when not run from inside the user's session. For example, these variants all report the screensaver is inactive, even when it's active:



    sudo gnome-screensaver-command -q
    sudo -u myuser gnome-screensaver-command -q


    Why is this, and how do I check the status of a user's screen from a different user like root?










    share|improve this question

























      up vote
      1
      down vote

      favorite
      2









      up vote
      1
      down vote

      favorite
      2






      2





      You can detect if a user's screensaver is active via:



      gnome-screensaver-command -q


      I'm trying to create a daemon to perform actions when the user is inactive, but I'm finding this command always returns false when not run from inside the user's session. For example, these variants all report the screensaver is inactive, even when it's active:



      sudo gnome-screensaver-command -q
      sudo -u myuser gnome-screensaver-command -q


      Why is this, and how do I check the status of a user's screen from a different user like root?










      share|improve this question















      You can detect if a user's screensaver is active via:



      gnome-screensaver-command -q


      I'm trying to create a daemon to perform actions when the user is inactive, but I'm finding this command always returns false when not run from inside the user's session. For example, these variants all report the screensaver is inactive, even when it's active:



      sudo gnome-screensaver-command -q
      sudo -u myuser gnome-screensaver-command -q


      Why is this, and how do I check the status of a user's screen from a different user like root?







      command-line screen-lock screensaver






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 3 '16 at 23:40









      Jeff Schaller

      33.7k851113




      33.7k851113










      asked Oct 3 '16 at 22:58









      Cerin

      3841517




      3841517




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          I know that it's a bit late but maybe some other people can read the answer now.



          The problem is with dbus. You need to export the right variable before running the gnome-screensaver-command.



          First you need to know the uid of the user. I exported also the DISPLAY of the user. You can get its value using the command w



          sudo -u myuser DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID_OF_MYUSER/bus DISPLAY=:0 gnome-screensaver-command --query


          This worked with Debian 9 and gnome-screensaver-command 3.6.1






          share|improve this answer








          New contributor




          Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















            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: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2funix.stackexchange.com%2fquestions%2f314124%2fhow-to-determine-if-screensaver-is-active-on-another-session%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
            1
            down vote













            I know that it's a bit late but maybe some other people can read the answer now.



            The problem is with dbus. You need to export the right variable before running the gnome-screensaver-command.



            First you need to know the uid of the user. I exported also the DISPLAY of the user. You can get its value using the command w



            sudo -u myuser DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID_OF_MYUSER/bus DISPLAY=:0 gnome-screensaver-command --query


            This worked with Debian 9 and gnome-screensaver-command 3.6.1






            share|improve this answer








            New contributor




            Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















              up vote
              1
              down vote













              I know that it's a bit late but maybe some other people can read the answer now.



              The problem is with dbus. You need to export the right variable before running the gnome-screensaver-command.



              First you need to know the uid of the user. I exported also the DISPLAY of the user. You can get its value using the command w



              sudo -u myuser DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID_OF_MYUSER/bus DISPLAY=:0 gnome-screensaver-command --query


              This worked with Debian 9 and gnome-screensaver-command 3.6.1






              share|improve this answer








              New contributor




              Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.



















                up vote
                1
                down vote










                up vote
                1
                down vote









                I know that it's a bit late but maybe some other people can read the answer now.



                The problem is with dbus. You need to export the right variable before running the gnome-screensaver-command.



                First you need to know the uid of the user. I exported also the DISPLAY of the user. You can get its value using the command w



                sudo -u myuser DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID_OF_MYUSER/bus DISPLAY=:0 gnome-screensaver-command --query


                This worked with Debian 9 and gnome-screensaver-command 3.6.1






                share|improve this answer








                New contributor




                Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                I know that it's a bit late but maybe some other people can read the answer now.



                The problem is with dbus. You need to export the right variable before running the gnome-screensaver-command.



                First you need to know the uid of the user. I exported also the DISPLAY of the user. You can get its value using the command w



                sudo -u myuser DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID_OF_MYUSER/bus DISPLAY=:0 gnome-screensaver-command --query


                This worked with Debian 9 and gnome-screensaver-command 3.6.1







                share|improve this answer








                New contributor




                Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered yesterday









                Fabio Zoratti

                111




                111




                New contributor




                Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Fabio Zoratti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f314124%2fhow-to-determine-if-screensaver-is-active-on-another-session%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    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?