- 追加された行はこのように表示されます。
- 削除された行は
このように表示されます。
!akonadiでカレンダみてみる
KOrganizerのバックエンドであAkonadiにSQLiteでアクセスできるようなので,
Python使ってアクセスしてみた.
とりあえずベーシックにはこんな感じ.
SQL文でデータ減らせるのが望ましいけど,複雑な条件書くのも面倒だよね,という感じ.
ちなみに,PartTableはblob形式で文字列ではないので注意.
import os
import sqlite3
from icalendar import Calendar
from datetime import datetime, date
import pytz
def main():
db = f'{os.environ["HOME"]}/.local/share/akonadi/akonadi.db'
conn = sqlite3.connect(db)
cur = conn.cursor()
cur.execute(f'''
SELECT p.id,
CAST(pt.data AS TEXT)
FROM PimItemTable p
JOIN PartTable pt ON pt.pimItemId = p.id
WHERE p.mimeTypeId = 3
AND instr(pt.data, 'BEGIN:VCALENDAR') > 0
''')
count = 0
for item in cur:
count += 1
k,v = item
print(v)
print(f'#. of items = {count}')
if __name__ == '__main__':
main()
ちょっとビューワ作ってみようかと思ったけど,
繰り返しの予定(RRULE)で,日付が変更になったり取消しがあったりするものの扱い(RECURRENCE-ID,EXDATE)や
複数の日に渡る終日の予定など,結構,扱いが面倒なものがあって,一旦ペンディング.
ちなみに,データの更新は,
busctl --user call org.freedesktop.Akonadi.Agent.akonadi_google_resource_0 / org.freedesktop.Akonadi.Resource synchronize
busctl --user call org.freedesktop.Akonadi.Agent.akonadi_google_resource_2 / org.freedesktop.Akonadi.Resource synchronize
とした.
ここで,引数の,
org.freedesktop.Akonadi.Agent.akonadi_google_resource_0
と,
org.freedesktop.Akonadi.Resource synchronize
は,
busctl --user list | grep Akonadi
で得られた結果
org.freedesktop.Akonadi.Agent.akonadi_google_resource_0 876669 akonadi_google_ miyo :1.854 session-c3.scope c3 -
をみて,さらに,
busctl --user introspect org.freedesktop.Akonadi.Agent.akonadi_google_resource_0 /
とすると,
org.freedesktop.Akonadi.Resource interface - - -
.name method - s -
.requestItemDelivery method axaay - -
.setName method s - -
.synchronize method - - no-reply
.synchronizeCollection method x - no-reply
.synchronizeCollection method xb - no-reply
.synchronizeCollectionAttributes method x - no-reply
.synchronizeCollectionTree method - - no-reply
.synchronizeRelations method - - no-reply
.synchronizeTags method - - no-reply
.attributesSynchronized signal x - -
.collectionTreeSynchronized signal - - -
.nameChanged signal s - -
.synchronized signal - - -
と,して探し出す.