Using Taskwarrior with Logseq

I use Logseq as my daily journaling application, and one of the things I love about Logseq is how easy it is to quickly capture free form…

Using Taskwarrior with Logseq
Logseq -> bugwarrior -> Taskwarrior

I use Logseq as my daily journaling application, and I love how easy it is to quickly capture free form TODO items when I’m taking meeting notes, doing planning, and capturing thoughts to come back to later.

TODO [#C] complete the quarterly project status report for #ProjectX

One benefit of using Logseq is that you can easily capture tasks inline with related notes. However, this approach can also make it difficult to get an overview of all your tasks at once, as they're scattered across multiple pages of notes. To address this issue, Logseq offers a powerful feature for creating dynamic queries across the knowledge graph. But, crafting a query that displays tasks in a concise and prioritized list can be tricky, especially due to the complexity of the underlying Clojure-based Datalog syntax.

One challenge I face when trying to get a complete picture of my work is that tasks are scattered across multiple platforms. In addition to Logseq, I also use Jira at work and various personal task management tools like Trello and Todoist for my side projects.

So this is where Taskwarrior and bugwarrior really help me out.

Taskwarrior offers a simple way to capture tasks using the command line. Additionally, bugwarrior provides an essential feature: it synchronizes tasks from multiple task management tools, into Taskwarrior's database. This unified view of all tasks allows for easy sorting and filtering, and also enables linking back to the original source for updating or managing each task.

With the addition of Logseq support in bugwarrior I now pull all of my Logseq tasks into this single view. The integration makes use of the LogSeq built in HTTP APIs Server. For this the Logseq application must be running on the same machine as bugwarrior, and the required Logseq Graph must be open in the application.

Enable Logseq HTTP APIs

First enable the HTTP APIs server in the Logseq settings. If this was not enabled already you will need to restart the application

After Logseq restarts you will see the API server icon on the top right of the window. Select the icon to modify the settings and start the server

Before starting the server, select the Authorization tokens option and enter a unique token that will be used to authorize application access to the Logseq graph. You can add multiple tokens, and the value can be set to anything you like. Take a note of this token as you will need it later for the bugwarrior configuration.

Note that by default Logseq can only be accessed by applications running on the same computer. While it is possible to setup the server for remote access this is not recommended as the server only uses HTTP, which is not encrypted.

After saving the new token start the API server. The cross through the API icon will disappear and you should see the API endpoint is active on http://127.0.0.1:12315/

Configure Taskwarrior and bugwarrior to sync the Logseq tasks

Install Taskwarrior, see the Taskwarrior download page for full details for different platforms. e.g. on MacOS

$ brew install task

bugwarrior is a Python based application, make sure you have a recent version of Python 3 installed for your platform. I recommend installing bugwarrior from the latest source.

$ git clone https://github.com/GothenburgBitFactory/bugwarrior.git 
$ pip install -e .

Create the ~/.config/bugwarrior/bugwarriorrc configuration file. See How to Configure for additional details.

$ mkdir -p ~/.config/bugwarrior 
$ vi ~/.config/bugwarrior/bugwarriorrc
[general] 
targets = logseq 
 
[logseq] 
service = logseq 
logseq.token = EXAMPLEUNIQUETOKENOFLETTERSANDNUMBER12345

Run bugwarrior uda command to get the list of User Defined Attributes to be appended to the Taskwarrior configuration file ~/.taskrc

$ bugwarrior uda  
 
# Bugwarrior UDAs 
uda.logseqid.type=string 
uda.logseqid.label=Logseq ID 
uda.logsequuid.type=string 
uda.logsequuid.label=Logseq UUID 
uda.logseqstate.type=string 
uda.logseqstate.label=Logseq State 
uda.logseqtitle.type=string 
uda.logseqtitle.label=Logseq Title 
uda.logseqdone.type=date 
uda.logseqdone.label=Logseq Done 
uda.logsequri.type=string 
uda.logsequri.label=Logseq URI 
# END Bugwarrior UDAs

Now run bugwarrior pull to start fetching the Logseq tasks

$ bugwarrior pull 
 
INFO:bugwarrior.db:Service-defined UDAs exist: you can optionally use the `bugwarrior-uda` command to export a list of UDAs you can add to your taskrc file. 
INFO:bugwarrior.collect:Starting to aggregate remote issues. 
INFO:bugwarrior.collect:Spawning 1 workers. 
INFO:bugwarrior.collect:Done aggregating remote issues. 
INFO:bugwarrior.db:Adding 0 tasks 
INFO:bugwarrior.db:Updating 3 tasks 
INFO:bugwarrior.db:Updating task 954130df-bc33-4a6e-bbc0-eab78d36db96, (bw)Is#26 - DOING write a blog post about using .. logseq://graph/TestGraph?block-id=6692f0cd-7206-4bcc-890b-4ea4ea633605; logseqid: '26' -> 26 
INFO:bugwarrior.db:Updating task 31015b0c-c8ad-471b-8daa-cb91cc2cbdcf, (bw)Is#28 - TODO complete the quarterly project .. logseq://graph/TestGraph?block-id=6692f0e9-1285-4e4a-b32d-0ea4a857776b; logseqid: '28' -> 28 
INFO:bugwarrior.db:Updating task 9ef745a2-1f60-45ef-9d88-96064a185feb, (bw)Is#33 - DOING  Complete Pull request to 【Bu .. logseq://graph/TestGraph?block-id=6692f10e-4558-424e-91ff-e81f64d70c3a; logseqid: '33' -> 33 
INFO:bugwarrior.db:Closing 0 tasks

You can new view the tasks in Taskwarrior from the command line

$ task list 
 
ID Age  P Project   Tags      Description                                                                                                                    Urg 
 3 3min H TestGraph           (bw)Is#33 - DOING  Complete Pull request to 【Bu .. logseq://graph/TestGraph?block-id=6692f10e-4558-424e-91ff-e81f64d70c3a [3]    8 
 1 3min M TestGraph           (bw)Is#26 - DOING write a blog post about using .. logseq://graph/TestGraph?block-id=6692f0cd-7206-4bcc-890b-4ea4ea633605 [3]   5.9 
 2 3min L TestGraph #ProjectX (bw)Is#28 - TODO complete the quarterly project .. logseq://graph/TestGraph?block-id=6692f0e9-1285-4e4a-b32d-0ea4a857776b       3.6
$ task 1 
 
Name          Value 
ID            1 
Description   (bw)Is#26 - DOING write a blog post about using .. logseq://graph/TestGraph?block-id=6692f0cd-7206-4bcc-890b-4ea4ea633605 
                2024-07-13 18:31:38 :LOGBOOK: 
                2024-07-13 18:31:39 CLOCK: 〈2024-07-13 Sat 17:27:38〉 
                2024-07-13 18:31:40 :END: 
Status        Pending 
Project       TestGraph 
Entered       2024-07-13 18:31:38 (11min) 
Last modified 2024-07-13 18:31:39 (11min) 
Virtual tags  ANNOTATED PENDING PRIORITY PROJECT READY UDA UNBLOCKED 
UUID          954130df-bc33-4a6e-bbc0-eab78d36db96 
Urgency       5.9 
Logseq ID     26 
Logseq State  DOING 
Logseq Title  DOING write a blog post about using 【Logseq】 with 【Taskwarrior】 
Logseq URI    logseq://graph/TestGraph?block-id=6692f0cd-7206-4bcc-890b-4ea4ea633605 
Logseq UUID   6692f0cd-7206-4bcc-890b-4ea4ea633605 
Priority      M 
 
    project             1 *    1 =      1 
    annotations         1 *    1 =      1 
    UDA priority.M      1 *  3.9 =    3.9 
                                   ------ 
                                      5.9

Opening tasks back in Logseq

A great convenience with tasks synced with bugwarrior is the provided URL allows for navigation back to the source of the task. One limitation however if most terminals only recognize http(s) links as clickable, and the so the logseq:// application URI is not recognized.

A simple workaround is to add shell command to extra the URI and open the list. On MacOS add the following to your ~/.zshrc coniguration

# open a specific Taskwarrior task in Logseq 
function taskopen() { 
    open $(task $1 | grep "Logseq URI" | sed -r 's/^Logseq URI//') 
}

You can now automatically open Logseq directly to the specific task using the command

$ taskopen 1

By combining the power of Logseq with Taskwarrior and bugwarrior I am now able get a prioritized list of active tasks with quick search and filtering without spending time creating complex Datalog queries.

For more details and advanced configuration option refer to the bugwarrior logseq service integration documentation.

References

A privacy-first, open-source knowledge base
A privacy-first, open-source platform for knowledge management and collaboration.
Taskwarrior
Bugwarrior — Bugwarrior 1.8.0 documentation
Logseq — Bugwarrior 1.8.0 documentation