toggle-chrome-opacity.py (786B)
1 def update_line_at_97(file_path): 2 line_to_insert = " \"100:class_g = 'Chromium'\",\n" 3 alternate_line = " \"0:class_g = 'Chromium'\",\n" 4 5 with open(file_path, 'r') as file: 6 lines = file.readlines() 7 8 # Ensure there are at least 97 lines in the file 9 while len(lines) < 97: 10 lines.append("\n") # Append new lines as needed 11 12 # Check the current content of line 97 and update accordingly 13 if lines[96].strip() == line_to_insert.strip(): 14 lines[96] = alternate_line # Replace with the alternate line 15 else: 16 lines[96] = line_to_insert # Ensure line 97 contains the correct text 17 18 with open(file_path, 'w') as file: 19 file.writelines(lines) 20 21 file_path = "/home/andrew/.config/picom.conf" 22 update_line_at_97(file_path)