#!/usr/bin/env python3 """ Add "Evaluate Diet" routine to Tasker project - 21:00 (9:00 PM) notification - Open Note button - Mark Done button """ import re def add_diet_routine(input_file, output_file): with open(input_file, 'r', encoding='utf-8') as f: content = f.read() # Find the highest profile and task IDs profile_ids = re.findall(r') insert_point = content.rfind('') # Profile 1: Time trigger (21:00) profile_trigger = f''' 1762631944649 1762935025169 8 {new_profile_trigger_id} {new_task_show_id} Trigger Diet Notification ''' # Profile 2: Event listener for "Open Diet Note" button profile_event_open = f''' 1762862939813 1762935050872 8 {new_profile_event_open_id} 63 Event: Open Diet Note 1825107102 0 Event Behaviour Filter: cmd_open_diet_note java.lang.String anpar java.lang.String ancomm java.lang.String cmd_open_diet_note java.lang.String false java.lang.Boolean false java.lang.Boolean false java.lang.Boolean anmessage java.lang.String true java.lang.Boolean <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%ancomm Everything to the right of =:= Everything to the right of =:=</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1>%anmessage Whole AutoNotification Message Whole AutoNotification Message</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2>%anpar() Array of single words to the left of =:= Array of single words to the left of =:=</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2></StringArray> [Ljava.lang.String; 10000 java.lang.Integer message_var command_var command_params_var config_notification_command plugininstanceid plugintypeid java.lang.String true java.lang.Boolean e1a87f0a-2e17-4b02-ab14-479198b7aeb1 java.lang.String com.joaomgcd.autonotification.intent.IntentCommandEvent java.lang.String com.joaomgcd.autonotification com.joaomgcd.autonotification.activity.ActivityConfigConditionTaskerEvent ''' # Profile 3: Event listener for "Mark Done" button profile_event_done = f''' 1762934954023 1762935062373 8 {new_profile_event_done_id} {new_task_done_id} Event: Mark Diet Done 1825107102 0 Event Behaviour Filter: cmd_mark_diet_done java.lang.String anpar java.lang.String ancomm java.lang.String cmd_mark_diet_done java.lang.String false java.lang.Boolean false java.lang.Boolean false java.lang.Boolean anmessage java.lang.String true java.lang.Boolean <StringArray sr=""><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0>%ancomm Everything to the right of =:= Everything to the right of =:=</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES0><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1>%anmessage Whole AutoNotification Message Whole AutoNotification Message</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES1><_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2>%anpar() Array of single words to the left of =:= Array of single words to the left of =:=</_array_net.dinglisch.android.tasker.RELEVANT_VARIABLES2></StringArray> [Ljava.lang.String; 10000 java.lang.Integer message_var command_var command_params_var config_notification_command plugininstanceid plugintypeid java.lang.String true java.lang.Boolean 6cbbccc1-1242-4f6a-861e-cfe4b82309fd java.lang.String com.joaomgcd.autonotification.intent.IntentCommandEvent java.lang.String com.joaomgcd.autonotification com.joaomgcd.autonotification.activity.ActivityConfigConditionTaskerEvent ''' # Task 1: Show Diet Notification task_show = f''' 1762631971435 1762935044696 {new_task_show_id} Show Diet Notification 100 166160670 16 java.lang.String Title: Evaluate Your Diet Text: Time to review your eating today! Action on Touch: cmd_open_diet_note Status Bar Text Size: 16 Id: notif_diet_evening Separator: , Button 1: cmd_open_diet_note Label 1: Open Note Button 2: cmd_mark_diet_done Label 2: Mark Done java.lang.String cmd_open_diet_note java.lang.String cmd_open_diet_note java.lang.String cmd_mark_diet_done java.lang.String Open Note java.lang.String Mark Done java.lang.String false java.lang.Boolean false java.lang.Boolean Time to review your eating today! java.lang.String Evaluate Your Diet java.lang.String StatusBarTextSize config_notification_title config_notification_text config_notification_action config_notification_action_button1 config_notification_action_label1 config_notification_action_button2 config_notification_action_label2 notificaitionid plugininstanceid plugintypeid java.lang.String true java.lang.Boolean notif_diet_evening java.lang.String 2c3b7c1e-0ee9-4d73-bf77-2b1311cf1a26 java.lang.String com.joaomgcd.autonotification.intent.IntentNotification java.lang.String com.joaomgcd.autonotification com.joaomgcd.autonotification.activity.ActivityConfigNotify ''' # Task 2: Mark Diet Done (dismiss notification) task_done = f''' 1762934967274 1762935062373 {new_task_done_id} Mark Diet Done 6 2046367074 <null> java.lang.String false java.lang.Boolean false java.lang.Boolean Id: notif_diet_evening java.lang.String notificaitionid plugininstanceid plugintypeid java.lang.String true java.lang.Boolean notif_diet_evening java.lang.String 2d6b7e1a-427b-442e-9f39-356480bf35d3 java.lang.String com.joaomgcd.autonotification.intent.IntentCancelNotification java.lang.String com.joaomgcd.autonotification com.joaomgcd.autonotification.activity.ActivityConfigCancelNotification ''' # Combine all new elements new_elements = profile_trigger + profile_event_open + profile_event_done + task_show + task_done # Insert before content = content[:insert_point] + new_elements + '\n' + content[insert_point:] # Update project pids (profile IDs) content = re.sub( r'([^<]+)', lambda m: f'{m.group(1)},{new_profile_trigger_id},{new_profile_event_open_id},{new_profile_event_done_id}', content, count=1 ) # Update project tids (task IDs) content = re.sub( r'([^<]+)', lambda m: f'{m.group(1)},{new_task_show_id},{new_task_done_id}', content, count=1 ) # Write output with open(output_file, 'w', encoding='utf-8') as f: f.write(content) print(f"✓ Added 'Evaluate Diet' routine") print(f" - Trigger time: 21:00 (9:00 PM)") print(f" - Profile IDs: {new_profile_trigger_id}, {new_profile_event_open_id}, {new_profile_event_done_id}") print(f" - Task IDs: {new_task_show_id}, {new_task_done_id}") print(f" - Commands: cmd_open_diet_note, cmd_mark_diet_done") print(f" - Notification ID: notif_diet_evening") print(f"✓ Output written to {output_file}") if __name__ == '__main__': input_file = '/Users/vincentverbruggen/Personal/Personal/Areas/Tasker/Routine_Reminders.prj.xml' output_file = '/Users/vincentverbruggen/Personal/Personal/Areas/Tasker/Routine_Reminders.prj.xml' add_diet_routine(input_file, output_file)