- commit
- d0e372a3f12319b9ac1379f79fb295503bdffa91
- parent
- e220d139dd2ecf3626fbac47f8d060c3903cc087
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2024-07-27 16:15
use flatpak-info for app_id
Diffstat
| A | xikeyring/app_id.py | 13 | +++++++++++++ |
| M | xikeyring/dbus.py | 3 | ++- |
2 files changed, 15 insertions, 1 deletions
diff --git a/xikeyring/app_id.py b/xikeyring/app_id.py
@@ -0,0 +1,13 @@
-1 1 import configparser
-1 2 from pathlib import Path
-1 3
-1 4
-1 5 def get_app_id(pid: int) -> str:
-1 6 path = Path('/proc') / str(pid) / 'root' / '.flatpak-info'
-1 7 config = configparser.ConfigParser()
-1 8 try:
-1 9 with path.open() as fh:
-1 10 config.read_file(fh)
-1 11 return config['Application']['name']
-1 12 except Exception:
-1 13 return ''
diff --git a/xikeyring/dbus.py b/xikeyring/dbus.py
@@ -8,6 +8,7 @@ import gi 8 8 from gi.repository import Gio 9 9 from gi.repository import GLib 10 10 -1 11 from .app_id import get_app_id 11 12 from .dbus_sessions import create_session 12 13 from .keyring import AccessDeniedError 13 14 from .keyring import NotFoundError @@ -123,7 +124,7 @@ class BaseDBusService: 123 124 -1, 124 125 None, 125 126 )[0]126 -1 return os.readlink(f'/proc/{pid}/exe')-1 127 return get_app_id(pid) 127 128 128 129 129 130 class DBusService(BaseDBusService):