Check if Gnome keyring is unlocked?

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











up vote
3
down vote

favorite












I am searching for a method with which to determine whether a Gnome keyring is unlocked; primarily, the default one. I got very close using secret-tool, but if a keyring is locked, it still presents a dialog.



I do not want to ask the user to unlock the keyring.



Either it is locked, or it is unlocked, end of story. The intent is to avoid the user ever having to know or think about keyrings. If the keyring is locked, do a thing (delete all keyrings), if a keyring is unlocked, do another thing (proceed as normal), all silently in the background.



So the question is, which tool actually allows that sort of check? I've got the rest of the script in place, I only need a silent replacement of secret-tool.







share|improve this question























    up vote
    3
    down vote

    favorite












    I am searching for a method with which to determine whether a Gnome keyring is unlocked; primarily, the default one. I got very close using secret-tool, but if a keyring is locked, it still presents a dialog.



    I do not want to ask the user to unlock the keyring.



    Either it is locked, or it is unlocked, end of story. The intent is to avoid the user ever having to know or think about keyrings. If the keyring is locked, do a thing (delete all keyrings), if a keyring is unlocked, do another thing (proceed as normal), all silently in the background.



    So the question is, which tool actually allows that sort of check? I've got the rest of the script in place, I only need a silent replacement of secret-tool.







    share|improve this question





















      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I am searching for a method with which to determine whether a Gnome keyring is unlocked; primarily, the default one. I got very close using secret-tool, but if a keyring is locked, it still presents a dialog.



      I do not want to ask the user to unlock the keyring.



      Either it is locked, or it is unlocked, end of story. The intent is to avoid the user ever having to know or think about keyrings. If the keyring is locked, do a thing (delete all keyrings), if a keyring is unlocked, do another thing (proceed as normal), all silently in the background.



      So the question is, which tool actually allows that sort of check? I've got the rest of the script in place, I only need a silent replacement of secret-tool.







      share|improve this question











      I am searching for a method with which to determine whether a Gnome keyring is unlocked; primarily, the default one. I got very close using secret-tool, but if a keyring is locked, it still presents a dialog.



      I do not want to ask the user to unlock the keyring.



      Either it is locked, or it is unlocked, end of story. The intent is to avoid the user ever having to know or think about keyrings. If the keyring is locked, do a thing (delete all keyrings), if a keyring is unlocked, do another thing (proceed as normal), all silently in the background.



      So the question is, which tool actually allows that sort of check? I've got the rest of the script in place, I only need a silent replacement of secret-tool.









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jul 4 at 17:18









      DigitalMan

      1213




      1213




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Gnome Keyring Tools (i made some little tools to check and control gnome keyring)



          Sources & Release : https://github.com/intika/gnome-keyring-tools



          Lock Keyring - gkey-lock.c



          #include <stdio.h>
          #include <gnome-keyring.h>

          int main()
          GnomeKeyringResult lock_result = gnome_keyring_lock_all_sync();
          if (lock_result == GNOME_KEYRING_RESULT_OK)
          printf("Successfully lockedn");
          return 0;
          else
          printf("Error locking keyring: %dn", lock_result);
          return 1;




          Unlock Keyring - gkey-unlock.c



          #include <stdio.h>
          #include <gnome-keyring.h>

          int main()
          GnomeKeyringResult lock_result = gnome_keyring_unlock_sync(NULL,NULL);
          if (lock_result == GNOME_KEYRING_RESULT_OK)
          printf("Successfully unlockedn");
          return 0;
          else
          printf("Error unlocking keyring: %dn", lock_result);
          return 1;




          Check Keyring - gkey-check.c



          #include <stdio.h>
          #include <gnome-keyring.h>

          int main()

          GnomeKeyringInfo *info;
          GnomeKeyringResult gkr;

          gkr = gnome_keyring_get_info_sync(NULL, &info);
          if (gkr != GNOME_KEYRING_RESULT_OK)
          printf("errorn");
          return -1;

          if (gnome_keyring_info_get_is_locked(info))
          printf("lockedn");
          return 0;

          else
          printf("unlockedn");
          return -1;

          gnome_keyring_info_free(info);




          How to build



          cc gkey-lock.c -o gkey-lock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
          cc gkey-unlock.c -o gkey-unlock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
          cc gkey-check.c -o gkey-check -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0


          Bonus - Check With Python - gkey-check.py



          import gnomekeyring
          print gnomekeyring.get_info_sync(gnomekeyring.get_default_keyring_sync()).get_is_locked()


          Bonus II - Monitor Gnome Keyring State In KDE Taskbar/Tray



          I made gkey-check return error when its unlocked in addition to the string unlocked i could then use KDE Server Status widget to monitor keyring state locked/unlocked with a visual icon :) with the command gkey-check






          share|improve this answer























            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%2f453459%2fcheck-if-gnome-keyring-is-unlocked%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













            Gnome Keyring Tools (i made some little tools to check and control gnome keyring)



            Sources & Release : https://github.com/intika/gnome-keyring-tools



            Lock Keyring - gkey-lock.c



            #include <stdio.h>
            #include <gnome-keyring.h>

            int main()
            GnomeKeyringResult lock_result = gnome_keyring_lock_all_sync();
            if (lock_result == GNOME_KEYRING_RESULT_OK)
            printf("Successfully lockedn");
            return 0;
            else
            printf("Error locking keyring: %dn", lock_result);
            return 1;




            Unlock Keyring - gkey-unlock.c



            #include <stdio.h>
            #include <gnome-keyring.h>

            int main()
            GnomeKeyringResult lock_result = gnome_keyring_unlock_sync(NULL,NULL);
            if (lock_result == GNOME_KEYRING_RESULT_OK)
            printf("Successfully unlockedn");
            return 0;
            else
            printf("Error unlocking keyring: %dn", lock_result);
            return 1;




            Check Keyring - gkey-check.c



            #include <stdio.h>
            #include <gnome-keyring.h>

            int main()

            GnomeKeyringInfo *info;
            GnomeKeyringResult gkr;

            gkr = gnome_keyring_get_info_sync(NULL, &info);
            if (gkr != GNOME_KEYRING_RESULT_OK)
            printf("errorn");
            return -1;

            if (gnome_keyring_info_get_is_locked(info))
            printf("lockedn");
            return 0;

            else
            printf("unlockedn");
            return -1;

            gnome_keyring_info_free(info);




            How to build



            cc gkey-lock.c -o gkey-lock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
            cc gkey-unlock.c -o gkey-unlock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
            cc gkey-check.c -o gkey-check -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0


            Bonus - Check With Python - gkey-check.py



            import gnomekeyring
            print gnomekeyring.get_info_sync(gnomekeyring.get_default_keyring_sync()).get_is_locked()


            Bonus II - Monitor Gnome Keyring State In KDE Taskbar/Tray



            I made gkey-check return error when its unlocked in addition to the string unlocked i could then use KDE Server Status widget to monitor keyring state locked/unlocked with a visual icon :) with the command gkey-check






            share|improve this answer



























              up vote
              1
              down vote













              Gnome Keyring Tools (i made some little tools to check and control gnome keyring)



              Sources & Release : https://github.com/intika/gnome-keyring-tools



              Lock Keyring - gkey-lock.c



              #include <stdio.h>
              #include <gnome-keyring.h>

              int main()
              GnomeKeyringResult lock_result = gnome_keyring_lock_all_sync();
              if (lock_result == GNOME_KEYRING_RESULT_OK)
              printf("Successfully lockedn");
              return 0;
              else
              printf("Error locking keyring: %dn", lock_result);
              return 1;




              Unlock Keyring - gkey-unlock.c



              #include <stdio.h>
              #include <gnome-keyring.h>

              int main()
              GnomeKeyringResult lock_result = gnome_keyring_unlock_sync(NULL,NULL);
              if (lock_result == GNOME_KEYRING_RESULT_OK)
              printf("Successfully unlockedn");
              return 0;
              else
              printf("Error unlocking keyring: %dn", lock_result);
              return 1;




              Check Keyring - gkey-check.c



              #include <stdio.h>
              #include <gnome-keyring.h>

              int main()

              GnomeKeyringInfo *info;
              GnomeKeyringResult gkr;

              gkr = gnome_keyring_get_info_sync(NULL, &info);
              if (gkr != GNOME_KEYRING_RESULT_OK)
              printf("errorn");
              return -1;

              if (gnome_keyring_info_get_is_locked(info))
              printf("lockedn");
              return 0;

              else
              printf("unlockedn");
              return -1;

              gnome_keyring_info_free(info);




              How to build



              cc gkey-lock.c -o gkey-lock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
              cc gkey-unlock.c -o gkey-unlock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
              cc gkey-check.c -o gkey-check -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0


              Bonus - Check With Python - gkey-check.py



              import gnomekeyring
              print gnomekeyring.get_info_sync(gnomekeyring.get_default_keyring_sync()).get_is_locked()


              Bonus II - Monitor Gnome Keyring State In KDE Taskbar/Tray



              I made gkey-check return error when its unlocked in addition to the string unlocked i could then use KDE Server Status widget to monitor keyring state locked/unlocked with a visual icon :) with the command gkey-check






              share|improve this answer

























                up vote
                1
                down vote










                up vote
                1
                down vote









                Gnome Keyring Tools (i made some little tools to check and control gnome keyring)



                Sources & Release : https://github.com/intika/gnome-keyring-tools



                Lock Keyring - gkey-lock.c



                #include <stdio.h>
                #include <gnome-keyring.h>

                int main()
                GnomeKeyringResult lock_result = gnome_keyring_lock_all_sync();
                if (lock_result == GNOME_KEYRING_RESULT_OK)
                printf("Successfully lockedn");
                return 0;
                else
                printf("Error locking keyring: %dn", lock_result);
                return 1;




                Unlock Keyring - gkey-unlock.c



                #include <stdio.h>
                #include <gnome-keyring.h>

                int main()
                GnomeKeyringResult lock_result = gnome_keyring_unlock_sync(NULL,NULL);
                if (lock_result == GNOME_KEYRING_RESULT_OK)
                printf("Successfully unlockedn");
                return 0;
                else
                printf("Error unlocking keyring: %dn", lock_result);
                return 1;




                Check Keyring - gkey-check.c



                #include <stdio.h>
                #include <gnome-keyring.h>

                int main()

                GnomeKeyringInfo *info;
                GnomeKeyringResult gkr;

                gkr = gnome_keyring_get_info_sync(NULL, &info);
                if (gkr != GNOME_KEYRING_RESULT_OK)
                printf("errorn");
                return -1;

                if (gnome_keyring_info_get_is_locked(info))
                printf("lockedn");
                return 0;

                else
                printf("unlockedn");
                return -1;

                gnome_keyring_info_free(info);




                How to build



                cc gkey-lock.c -o gkey-lock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
                cc gkey-unlock.c -o gkey-unlock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
                cc gkey-check.c -o gkey-check -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0


                Bonus - Check With Python - gkey-check.py



                import gnomekeyring
                print gnomekeyring.get_info_sync(gnomekeyring.get_default_keyring_sync()).get_is_locked()


                Bonus II - Monitor Gnome Keyring State In KDE Taskbar/Tray



                I made gkey-check return error when its unlocked in addition to the string unlocked i could then use KDE Server Status widget to monitor keyring state locked/unlocked with a visual icon :) with the command gkey-check






                share|improve this answer















                Gnome Keyring Tools (i made some little tools to check and control gnome keyring)



                Sources & Release : https://github.com/intika/gnome-keyring-tools



                Lock Keyring - gkey-lock.c



                #include <stdio.h>
                #include <gnome-keyring.h>

                int main()
                GnomeKeyringResult lock_result = gnome_keyring_lock_all_sync();
                if (lock_result == GNOME_KEYRING_RESULT_OK)
                printf("Successfully lockedn");
                return 0;
                else
                printf("Error locking keyring: %dn", lock_result);
                return 1;




                Unlock Keyring - gkey-unlock.c



                #include <stdio.h>
                #include <gnome-keyring.h>

                int main()
                GnomeKeyringResult lock_result = gnome_keyring_unlock_sync(NULL,NULL);
                if (lock_result == GNOME_KEYRING_RESULT_OK)
                printf("Successfully unlockedn");
                return 0;
                else
                printf("Error unlocking keyring: %dn", lock_result);
                return 1;




                Check Keyring - gkey-check.c



                #include <stdio.h>
                #include <gnome-keyring.h>

                int main()

                GnomeKeyringInfo *info;
                GnomeKeyringResult gkr;

                gkr = gnome_keyring_get_info_sync(NULL, &info);
                if (gkr != GNOME_KEYRING_RESULT_OK)
                printf("errorn");
                return -1;

                if (gnome_keyring_info_get_is_locked(info))
                printf("lockedn");
                return 0;

                else
                printf("unlockedn");
                return -1;

                gnome_keyring_info_free(info);




                How to build



                cc gkey-lock.c -o gkey-lock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
                cc gkey-unlock.c -o gkey-unlock -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0
                cc gkey-check.c -o gkey-check -Wall -I/usr/include/gnome-keyring-1 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgnome-keyring -lglib-2.0


                Bonus - Check With Python - gkey-check.py



                import gnomekeyring
                print gnomekeyring.get_info_sync(gnomekeyring.get_default_keyring_sync()).get_is_locked()


                Bonus II - Monitor Gnome Keyring State In KDE Taskbar/Tray



                I made gkey-check return error when its unlocked in addition to the string unlocked i could then use KDE Server Status widget to monitor keyring state locked/unlocked with a visual icon :) with the command gkey-check







                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited Jul 17 at 1:46


























                answered Jul 16 at 8:53









                intika

                1505




                1505






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453459%2fcheck-if-gnome-keyring-is-unlocked%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?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay