xi-keyring

simple and extensible alternative for gnome-keyring
git clone https://git.ce9e.org/xi-keyring.git

commit
81569ca7a740b022f6dd92a97818b77830ab5e12
parent
c6d82322afd92f519308d49f6649d76582716c99
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2026-05-24 14:31
mv main loop to __main__

Diffstat

M xikeyring/__main__.py 6 ++++--
M xikeyring/dbus.py 8 ++++----

2 files changed, 8 insertions, 6 deletions


diff --git a/xikeyring/__main__.py b/xikeyring/__main__.py

@@ -4,6 +4,7 @@ import sys
    4     4 from pathlib import Path
    5     5 
    6     6 from cryptography.fernet import Fernet
   -1     7 from gi.repository import GLib
    7     8 
    8     9 from . import crypto
    9    10 from .dbus import DBusService
@@ -64,5 +65,6 @@ elif args.action == 'change-password':
   64    65     encrypted = crypto.encrypt_with_password(keyring.key.value, password)
   65    66     write_bytes(args.key, encrypted)
   66    67 else:
   67    -1     service = DBusService(keyring)
   68    -1     service.run(args.bus)
   -1    68     with DBusService(keyring).own(args.bus):
   -1    69         loop = GLib.MainLoop()
   -1    70         loop.run()

diff --git a/xikeyring/dbus.py b/xikeyring/dbus.py

@@ -2,6 +2,7 @@ import logging
    2     2 import os
    3     3 import re
    4     4 import sys
   -1     5 from contextlib import contextmanager
    5     6 from pathlib import Path
    6     7 
    7     8 import gi
@@ -44,7 +45,8 @@ class BaseDBusService:
   44    45     def on_name_lost(self, conn, name):
   45    46         sys.exit(f'Could not aquire name {name}. Is some other service blocking it?')
   46    47 
   47    -1     def run(self, name):
   -1    48     @contextmanager
   -1    49     def own(self, name):
   48    50         handle = Gio.bus_own_name(
   49    51             Gio.BusType.SESSION,
   50    52             name,
@@ -53,10 +55,8 @@ class BaseDBusService:
   53    55             None,
   54    56             self.on_name_lost,
   55    57         )
   56    -1 
   57    58         try:
   58    -1             loop = GLib.MainLoop()
   59    -1             loop.run()
   -1    59             yield
   60    60         finally:
   61    61             Gio.bus_unown_name(handle)
   62    62