diff --git a/.gitignore b/.gitignore index 92be537..5dfb2c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *~ *.swp +*.*swp .vstags *.tdy *.bak @@ -15,4 +16,4 @@ .history/ # Built Visual Studio Code Extensions -*.vsix \ No newline at end of file +*.vsix diff --git a/README.md b/README.md index cd43066..917afad 100755 --- a/README.md +++ b/README.md @@ -16,3 +16,5 @@ Miscellaneous scripts, e.g. set screen brightness from command line (bug workaro * Backup and restore scripts for packages installed on Solus OS * Set up a Solus OS development environment (update needed) * Backup and restore scripts for Linux systems +* obsidian_hide_inlineTitle.py - Change all Obsidian vaults to hide inline titles +* obsidian_get_inlineTitle_values.py - Get the value of inlineTitle in all Obsidian vaults diff --git a/obsidian_get_inlineTitle_values.py b/obsidian_get_inlineTitle_values.py new file mode 100755 index 0000000..a3a59ec --- /dev/null +++ b/obsidian_get_inlineTitle_values.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 + +import os +import json + +# Find all app.json config files for Obsidian +# in all subdirectories of the specified directory +# and show the value of showInlineTitle +# Assisted by ChatGPT + + +def get_show_inline_title_from_obsidian_folders(parent_directory): + try: + # Loop through all folders and subfolders in the parent directory + for root, dirs, files in os.walk(parent_directory): + # Check if the current directory is named ".obsidian" + if '.obsidian' in dirs: + obsidian_folder_path = os.path.join(root, '.obsidian') + # Look for a file named "app.json" in this folder + app_json_path = os.path.join(obsidian_folder_path, 'app.json') + if os.path.exists(app_json_path): + # Open the JSON file for reading + with open(app_json_path, 'r') as json_file: + data = json.load(json_file) + # Check if 'showInlineTitle' key exists + # and print its value + if 'showInlineTitle' in data: + print( + f"In '{app_json_path}': showInlineTitle is {data['showInlineTitle']}") + else: + print( + f"In '{app_json_path}': showInlineTitle key does not exist.") + + except FileNotFoundError: + print(f"Error: Directory '{parent_directory}' not found.") + except json.JSONDecodeError: + print(f"Error: Invalid JSON file found in '{parent_directory}'.") + + +# Get the parent directory path from user input +parent_directory = input("Enter the parent directory path: ") +get_show_inline_title_from_obsidian_folders(parent_directory) diff --git a/obsidian_hide_inlineTitle.py b/obsidian_hide_inlineTitle.py new file mode 100755 index 0000000..761730c --- /dev/null +++ b/obsidian_hide_inlineTitle.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +import os +import json + +# Find all app.json config files for Obsidian +# in all subdirectories of the specified directory +# and change showInlineTitle to false +# Assisted by ChatGPT + + +def obsidian_hide_inline_title(parent_directory): + try: + # Loop through all folders and subfolders in the parent directory + for root, dirs, files in os.walk(parent_directory): + # Check if the current directory is named ".obsidian" + if '.obsidian' in dirs: + obsidian_folder_path = os.path.join(root, '.obsidian') + # Look for a file named "app.json" in this folder + app_json_path = os.path.join(obsidian_folder_path, 'app.json') + if os.path.exists(app_json_path): + # app_json_path = os.path.join( + # obsidian_folder_path, 'app.json') + # Open the JSON file for reading + with open(app_json_path, 'r') as json_file: + data = json.load(json_file) + # Check if 'showInlineTitle' key exists + # and change its value if it's 'true' + if 'showInlineTitle' in data and data['showInlineTitle'] == True: + data['showInlineTitle'] = False + # Open the same JSON file for writing + # and update its content + with open(app_json_path, 'w') as json_file: + json.dump(data, json_file, indent=4) + print( + f"Value of 'showInlineTitle' changed to false in '{app_json_path}'.") + else: + print( + f"No action needed in '{app_json_path}'. 'showInlineTitle' either doesn't exist or is already false.") + + except FileNotFoundError: + print(f"Error: Directory '{parent_directory}' not found.") + except json.JSONDecodeError: + print(f"Error: Invalid JSON file found in '{parent_directory}'.") + + +# Get the parent directory path from user input +parent_directory = input("Enter the parent directory path: ") +obsidian_hide_inline_title(parent_directory) diff --git a/reset_kde.fish b/reset_kde.fish deleted file mode 100755 index 4c934eb..0000000 --- a/reset_kde.fish +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/fish - -set HOME /home/$USER - -if set -q HOME - echo HOME variable defined as $HOME -end - -if string length -q -- $HOME - - echo "Backup up $HOME/.config" - cp -r $HOME/.config $HOME/.config.bak - - echo "Deleting KDE config files" - set fileList Trolltech.conf akregatorrc baloofilerc bluedevilglobalrc kactivitymanagerd-statsrc - set -a fileList kactivitymanagerdrc kactivitymanagerd-pluginsrc kateschemarc kcmfonts kcminputrc kconf_updaterc kded5rc - set -a fileList kdeglobals kfontinstuirc kglobalshortcutsrc khotkeysrc kmixctrlrc kmixrc - set -a fileList kscreenlockerrc ksmserverrc ksplashrc ktimezonedrc kwinrc kwinrulesrc plasma-localerc - set -a fileList plasma-nm plasma-org.kde.plasma.desktop-appletsrc plasmarc plasmashellrc - set -a fileList powermanagementprofilesrc startupconfig startupconfigfiles startupconfigkeys - set -a fileList krunnerrc touchpadxlibinputrc systemsettingsrc kxkbrc PlasmaUserFeedback - set -a fileList kde.org/* kiorc klipperrc knfsshare kuriikwsfilterrc kwalletmanager5rc kwalletrc - set -a fileList plasma.emojierrc plasmanotifyrc PlasmaUserFeedback powerdevilrc kgammarc - set -a fileList kded_device_automounterrc device_automounter_kcmrc klaunchrc - set -a fileList trashrc kactivitymanagerd-switcher gtkrc-2.0 gtkrc baloofileinformationrc - set -a fileList breezerc - - rm $fileList - echo "Deletion completed" - - -else - - echo "HOME variable not defined" - -end