Bobbey Posted April 3 Share Posted April 3 (edited) I was getting annoyed by osbot installing updates to the home directory and me having to give it executable permissions over and over and looking for the correct file to launch. Therefore I've written a script that creates an application entry so you can just search with the SUPER key on your keyboard and then typing "osbot". The installed script will find the latest jar in your home folder and launch that. Tested on Ubuntu. May work on Fedora, Debian and their derivatives. Note: before installing, make sure there is any osbot jar present in the home directory /home/username/osbot x.x.x.jar Installer Note: the installer requires "osbot_icon.png" in the working directory. This icon needs to be 48x48 or 64x64 or 128x128 etc. You can use this image for example. Don't forget to rename it after downloading. $ sh install.sh Creates a script at /usr/local/bin/osbot which finds and launches the latest osbot.jar in the home directory. Makes the script executable Copies osbot_icon.png to /usr/share/icons/osbot_icons/osbot_icon.png and gives it the correct permissions Creates the desktop entry ~/.local/share/applications/osbot.desktop and gives it the correct permissions Reloads the application database Logs can be found at /tmp/osbot_launcher.log Spoiler #!/bin/bash # Create the script file at /usr/local/bin/osbot sudo tee /usr/local/bin/osbot >/dev/null <<'EOF' #!/bin/bash # Log file path LOG_FILE="/tmp/osbot_launcher.log" # Function to log messages log() { echo "$(date +"%Y-%m-%d %H:%M:%S") - $*" >> "$LOG_FILE" } # Start logging log "Starting OSBot Launcher" # Function to compare versions version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } # Log the home directory for debugging log "Home directory: $HOME" # Search for osbot jar files in the home directory while IFS= read -r -d '' jar_file; do # Log the found jar file for debugging log "Found JAR file: $jar_file" # Extract version from the filename filename=$(basename "$jar_file") version="${filename%.jar}" version="${version#osbot }" # Log the version for debugging log "Found version: $version" # If highest_version is empty or the current version is greater, update highest_version and highest_version_file if [ -z "$highest_version" ] || version_gt "$version" "$highest_version"; then highest_version="$version" highest_version_file="$jar_file" log "New highest version: $highest_version" log "New highest version file: $highest_version_file" fi done < <(find "$HOME" -maxdepth 1 -name "osbot*.jar" -print0) # If no valid jar files found, exit with an error if [ -z "$highest_version_file" ]; then log "No valid osbot jar files found in the home directory." exit 1 fi # Log the execution of the JAR file log "Executing JAR file: $highest_version_file" # Execute the highest version osbot jar file java -jar "$highest_version_file" >> "$LOG_FILE" 2>&1 # Log completion log "OSBot Launcher completed" EOF # Give executable permissions to the script sudo chmod +x /usr/local/bin/osbot # Copy osbot_icon.png to /usr/share/icons/osbot_icons/osbot_icon.png sudo mkdir -p /usr/share/icons/osbot_icons sudo cp osbot_icon.png /usr/share/icons/osbot_icons/osbot_icon.png # Set correct permissions for the icon file sudo chmod 644 /usr/share/icons/osbot_icons/osbot_icon.png # Create ~/.local/share/applications/osbot.desktop tee ~/.local/share/applications/osbot.desktop >/dev/null <<'EOF' [Desktop Entry] Name=OSBot Launcher Comment=Launch OSBot with the latest version Exec=osbot Icon=/usr/share/icons/osbot_icons/osbot_icon.png Terminal=false Type=Application Categories=Utility; EOF # Set correct permissions for the desktop file chmod 644 ~/.local/share/applications/osbot.desktop # Reload application database update-desktop-database ~/.local/share/applications/ Uninstaller $ sh uninstall.sh Spoiler #!/bin/bash # Remove the script file from /usr/local/bin sudo rm -f /usr/local/bin/osbot # Remove the icon file and directory sudo rm -rf /usr/share/icons/osbot_icons # Remove the .desktop file rm -f ~/.local/share/applications/osbot.desktop Noob guide: Read the comments of this post to see if it's not malicious code. Create a folder somewhere and download the image on this post into it and rename it to osbot_icon.png Right click in the folder -> Open in terminal Type "nano installer.sh" and copy the installer code from this post and right click in the terminal. CTRL + O and CTRL + X to save the script. Type "sh installer.sh" This image is uploaded to osbot and is converted to webp. It's here in case imgur removes the other image: Edited April 5 by Bobbey Make image png Quote Link to comment Share on other sites More sharing options...
Muffins Posted April 3 Share Posted April 3 great addition, thanks! Quote Link to comment Share on other sites More sharing options...
TheCongregation Posted April 4 Share Posted April 4 That's really cool Quote Link to comment Share on other sites More sharing options...