From 925fcf770a67135d790bbfef04b5e8f653518646 Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Fri, 20 Sep 2024 12:16:58 -0400 Subject: [PATCH] adding freecad desktop launcher --- README.md | 17 +++++++++++++++++ freecad.desktop | 7 +++++++ user_updater.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 freecad.desktop create mode 100644 user_updater.py diff --git a/README.md b/README.md index e69de29..c462795 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,17 @@ +## Software + +### FreeCAD + +FreeCAD stores config in two places on Ubuntu: +* ~/.config/FreeCAD +* ~/.local/share/FreeCAD + +The desktop launcher expects to find FreeCAD in `/home/user/Documents/Software/freecad/RC1/FreeCAD_RC1.AppImage` + +Desktop Launcher + +To make the appimage show up and launch from the desktop launcher, a .desktop file needs to be created in the location `~/.local/share/applications` + +1. Do a git pull into that folder +2. Run the python script that updates all the desktop launcher files to use the current logged-in user + diff --git a/freecad.desktop b/freecad.desktop new file mode 100644 index 0000000..be2e4ce --- /dev/null +++ b/freecad.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=FreeCAD +Exec=/home/userhere/Documents/Software/freecad/rc1/FreeCAD_RC1.AppImage +Icon=/home/userhere/.local/share/applications/freecad.png +Terminal=false diff --git a/user_updater.py b/user_updater.py new file mode 100644 index 0000000..9aec3b1 --- /dev/null +++ b/user_updater.py @@ -0,0 +1,29 @@ +import os +import getpass + +def replace_word_in_files(target_word, replacement_word, folder_path="."): + # Loop through all files in the specified folder + for filename in os.listdir(folder_path): + if filename.endswith(".desktop"): # Only process text files + file_path = os.path.join(folder_path, filename) + with open(file_path, 'r') as file: + file_content = file.read() + + # Replace the target word with the replacement word + new_content = file_content.replace(target_word, replacement_word) + + # Write the new content back to the file + with open(file_path, 'w') as file: + file.write(new_content) + + print(f"Replaced '{target_word}' with '{replacement_word}' in {filename}") + +if __name__ == "__main__": + # Get the current Ubuntu username + username = getpass.getuser() + + # Replace 'TARGET_WORD' in all text files with the username + target_word = "userhere" + + replace_word_in_files(target_word, username) +