Jump to content

Linux OSBot Launcher


Recommended Posts

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.

image.png.6d291a72ca02ba70fce7c6d2a180f4e0.png

 

 

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.

DKt414i.png
$ sh install.sh

  1. Creates a script at /usr/local/bin/osbot which finds and launches the latest osbot.jar in the home directory.
  2. Makes the script executable
  3. Copies osbot_icon.png to /usr/share/icons/osbot_icons/osbot_icon.png and gives it the correct permissions
  4. Creates the desktop entry ~/.local/share/applications/osbot.desktop and gives it the correct permissions
  5. 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:

  1. Read the comments of this post to see if it's not malicious code.
  2. Create a folder somewhere and download the image on this post into it and rename it to osbot_icon.png
  3. Right click in the folder -> Open in terminal
  4. 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.
  5. 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:

image.png.97f7ca421c5ee5c75fa0201b3efd6920.png

Edited by Bobbey
Make image png
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...