This commit is contained in:
CaCO3 2024-08-19 00:56:23 +02:00
parent 943d485ef1
commit 74b8e50393
2 changed files with 26 additions and 13 deletions

View File

@ -1,11 +1,14 @@
[Desktop Entry] [Desktop Entry]
Categories=Graphics;3DGraphics;Engineering; Categories=Graphics;3DGraphics;Engineering;
Comment[de_CH]=
Comment= Comment=
Exec=/home/gruinelli/appImages/bambustudio Exec=/home/gruinelli/appImages/bambustudio
GenericName[de_CH]=3D Printing Software
GenericName=3D Printing Software GenericName=3D Printing Software
Icon=/home/gruinelli/appImages/bambustudio.png Icon=/home/gruinelli/appImages/bambustudio.png
Keywords=3D;Printing;Slicer;slice;3D;printer;convert;gcode;stl;obj;amf;SLA Keywords=3D;Printing;Slicer;slice;3D;printer;convert;gcode;stl;obj;amf;SLA
MimeType=model/stl;model/3mf;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;application/x-amf;x-scheme-handler/bambustudio; MimeType=model/stl;model/3mf;model/3mf;
Name[de_CH]=BambuStudio
Name=BambuStudio Name=BambuStudio
NoDisplay=false NoDisplay=false
Path= Path=

View File

@ -14,13 +14,16 @@ githubApi = "https://api.github.com/repos"
applications = { applications = {
"freecad": { "org": "FreeCAD", # https://github.com/FreeCAD/FreeCAD-Bundle/releases "freecad": { "org": "FreeCAD", # https://github.com/FreeCAD/FreeCAD-Bundle/releases
"repo": "FreeCAD-Bundle", "repo": "FreeCAD-Bundle",
"assetRegex": "FreeCAD_weekly-builds-.*-x86_64-.*AppImage$" }, "assetRegex": "FreeCAD_weekly-builds-.*-x86_64-.*AppImage$" },
"bambustudio": { "org": "bambulab", # https://github.com/bambulab/BambuStudio/releases "bambustudio": { "org": "bambulab", # https://github.com/bambulab/BambuStudio/releases
"repo": "BambuStudio", "repo": "BambuStudio",
"assetRegex": "Bambu_Studio_linux_ubuntu_24.*AppImage$" }, "assetRegex": "Bambu_Studio_linux_ubuntu_24.*AppImage$" },
} }
# get script path
scriptFolder = os.path.dirname(os.path.realpath(__file__))
# Cortesy: https://gist.github.com/yanqd0/c13ed29e29432e3cf3e7c38467f42f51 # Cortesy: https://gist.github.com/yanqd0/c13ed29e29432e3cf3e7c38467f42f51
def download(url: str, fname: str, chunk_size=1024): def download(url: str, fname: str, chunk_size=1024):
@ -67,29 +70,36 @@ def main(app):
if assetName: if assetName:
# if file exists # if file exists
if os.path.isfile(assetName): if os.path.isfile(scriptFolder + "/" + assetName):
log.info("Application " + app + " is already up-to-date (" + assetName + ")") log.info("Application " + app + " is already up-to-date (" + assetName + ")")
else: # Download it else: # Download it
# Eg. https://github.com/FreeCAD/FreeCAD-Bundle/releases/download/weekly-builds/FreeCAD_weekly-builds-38467-conda-Linux-x86_64-py311.AppImage # Eg. https://github.com/FreeCAD/FreeCAD-Bundle/releases/download/weekly-builds/FreeCAD_weekly-builds-38467-conda-Linux-x86_64-py311.AppImage
log.debug("url: " + assetUrl) log.debug("url: " + assetUrl)
# Download to file with progress bar # Download to file with progress bar
download(assetUrl, assetName + ".tmp") download(assetUrl, scriptFolder + "/" + assetName + ".tmp")
# Rename # Rename
os.rename(assetName + ".tmp", assetName) os.rename(scriptFolder + "/" + assetName + ".tmp", assetName)
# todo remove old appimages # todo remove old appimages
# chmod # chmod
os.chmod(assetName, 0o755) os.chmod(scriptFolder + "/" + assetName, 0o755)
# rm link # get user home directory
if os.path.isfile(app): home = os.path.expanduser("~")
os.remove(app)
# link # link
os.symlink(assetName, app) if os.path.isfile(scriptFolder + "/" + app):
os.remove(scriptFolder + "/" + app)
os.symlink(scriptFolder + "/" + assetName, scriptFolder + "/" + app)
# Add link to start menu
desktopLink = home + "/.local/share/applications/" + app + ".desktop"
if os.path.isfile(desktopLink):
os.remove(desktopLink)
os.symlink(scriptFolder + "/" + app + ".desktop", desktopLink)
# log.info("Application " + app + " updated") # log.info("Application " + app + " updated")