TaskWarrior automatically modify UDA

332 Views Asked by At

I have a question. Let's say that I have created User Defined Attribute attr with values A,B,C. How to configure taskwarrior to automatically change the attr value from A to B when I enter

task x start

and change attr from B to C when

task x done

1

There are 1 best solutions below

1
On

Disadvantage of suggested solution:

  1. You continuously need to have a script running in the background.
  2. There can occur a small delay between your task x start command, and the change of UDA attr
  3. It is a bit of a tedious method, perhaps you can also accomplish your goal using solely taskwarrior commands/settings.
  4. It is made for fun and I can currently not offer any security or proper functioning guarantees. I tested and use it on WSL Ubuntu 16.04.

Assumptions:

If you enter task x start the attribute Start is set to a valid date.

Solution:

You can have a script running in the background that reads the properties of all tasks, and as soon as it detects a valid date in the Start attribute of a tasks, and a value of B in the UDA attr then it sets the UDA attr to C by executing the command task x modify attr:C command.

I made a script/small project that sorts on a custom setting of project and urgency, and it contains the functionalities of:

  • Running in the background from startup automatically,
  • Scanning the taskproperties and automatically applying the changes that are programmed in the script.

So in effect,

  1. You should modify/add the UDA attr here:
  2. And duplicate and change for example method private static void setCustomSort(ArrayList<Task> taskList) {1 on line 88 of the main

(For the 2nd step, between //get uuid and //create command you should add the condition that checks the task for a valid id. Then if it has, change the command that is generated to task modify attr:C)

The instructions to compile the java code and set up automation are listed here.