#!/usr/bin/env python3 """ Standardize Tasker XML project file - Consistent naming conventions - Link notification buttons to correct tasks via AutoNotification commands - Remove trailing spaces and inconsistencies """ import re import sys def standardize_tasker_xml(input_file, output_file): with open(input_file, 'r', encoding='utf-8') as f: content = f.read() # Standardize Profile names profile_replacements = { 'Launch Skincare Notification': 'Trigger Skincare Notification', 'Launch Prepare For Exercise Notification': 'Trigger Exercise Notification', 'Open Skincare Notification': 'Show Skincare Notification', 'Open Prepare Exercise Notification': 'Show Exercise Notification', 'Dismiss Exercise Notification': 'Mark Exercise Done', } for old, new in profile_replacements.items(): content = content.replace(f'{old}', f'{new}') # Standardize command names (used in AutoNotification event filters and button actions) command_replacements = { 'Open morning skincare': 'cmd_open_skincare_note', 'open skincare note': 'cmd_open_skincare_note', 'mark skincare done': 'cmd_mark_skincare_done', 'open exercise note': 'cmd_open_exercise_note', 'mark exercise done': 'cmd_mark_exercise_done', 'open diet note': 'cmd_open_diet_note', } for old, new in command_replacements.items(): # Remove trailing spaces from old commands old_variants = [old, old + ' ', old + ' '] for variant in old_variants: # Replace in command filters content = content.replace( f'{variant}', f'{new}' ) # Replace in button actions content = content.replace( f'{variant}', f'{new}' ) content = content.replace( f'{variant}', f'{new}' ) content = content.replace( f'{variant}', f'{new}' ) # Standardize notification IDs notif_id_replacements = { 'skincare morning': 'notif_skincare_morning', 'skincare morning ': 'notif_skincare_morning', 'prepare for exercise': 'notif_exercise_prep', } for old, new in notif_id_replacements.items(): content = content.replace( f'{old}', f'{new}' ) # Also update in BLURB text content = re.sub( f'Id: {re.escape(old)}([\\n<])', f'Id: {new}\\1', content ) # Standardize notification titles and texts (remove trailing spaces) content = re.sub( r'([^<]+?) +', r'\1', content ) content = re.sub( r'([^<]+?) +', r'\1', content ) # Update project name content = content.replace( 'Skincare Demo', 'Routine Reminders' ) # Fix BLURB descriptions to reflect standardized commands content = re.sub( r'Filter: mark skincare done[ ]*', 'Filter: cmd_mark_skincare_done', content ) content = re.sub( r'Filter: mark exercise done[ ]*', 'Filter: cmd_mark_exercise_done', content ) content = re.sub( r'Button 1: open skincare note', 'Button 1: cmd_open_skincare_note', content ) content = re.sub( r'Button 2: mark skincare done', 'Button 2: cmd_mark_skincare_done', content ) content = re.sub( r'Button 1: open exercise note', 'Button 1: cmd_open_exercise_note', content ) content = re.sub( r'Button 2: mark exercise done', 'Button 2: cmd_mark_exercise_done', content ) content = re.sub( r'Button 1: open diet note', 'Button 1: cmd_open_diet_note', content ) content = re.sub( r'Action on Touch: Open morning skincare[ ]*', 'Action on Touch: cmd_open_skincare_note', content ) # Write output with open(output_file, 'w', encoding='utf-8') as f: f.write(content) print(f"✓ Standardized {input_file}") print(f"✓ Output written to {output_file}") if __name__ == '__main__': input_file = '/Users/vincentverbruggen/Personal/Personal/Areas/Tasker/Skincare_Demo_Standardized.prj.xml' output_file = '/Users/vincentverbruggen/Personal/Personal/Areas/Tasker/Routine_Reminders.prj.xml' standardize_tasker_xml(input_file, output_file)