Code Monkey home page Code Monkey logo

Comments (9)

Acly avatar Acly commented on June 25, 2024 1

The short answer is: as long as this remains an external plugin, it will always be a bit hacky.

Krita doesn't support external native plugins from a different location than its own installation path. When it's all bundled up in a AppImage or flatpack, it makes things difficult. Alternatively, if you installed via package manager, there are many distributions, with many package manager, which install it in different ways - not much better.

So there will be a flatpack or package version only if someone decides to make one.

Regarding shortcut: you can probably put the startup command in a .sh file and double-click it? I've never used a desktop shortcut on Linux in my life, why would you do that if you can enter mysterious cryptic commands instead ^^

You can also repack it into an AppImage, but when I tried that on a Fedora on my Laptop instead of the old Ubuntu that Krita is build on it threw some errors because some tool is newer version and became more pedantic and detected some issues, etc. etc. ... so unfortunately I cannot recommend that solution either.

It's tough trying to convince people to give up windows when there's so many bars of entry for a beginner.

I've used Linux for years (both private and at work) and I've never been convinced to give up Windows either :D

Seriously though, I do understand installation is no very streamlined, but don't have a good idea that doesn't involve a lot of recurring effort.

from krita-ai-tools.

SimonHeggie avatar SimonHeggie commented on June 25, 2024

Then once I have the app running; how can I get the same things i had with the flatpack? IE: how can I install this properly so it's in the proper place that it belongs? Set up the shortcut etc?

I think with a lot of this stuff; it's hard to teach new people to set this stuff up without a very clear and straightforward guide or methodology.

Ultimately I'd like to be able to suggest this solution along with Linux to more people but it's hard if the setup process requires a lot of overhead in investigating the process.

For some of us artists our heads are already 100% full of technical and creative theory!! It's tough trying to convince people to give up windows when there's so many bars of entry for a beginner.

from krita-ai-tools.

SimonHeggie avatar SimonHeggie commented on June 25, 2024

Thanks for the explanation Acly.

Understanding that there doesn't seem much that can be done on the structure of the project.

As much as I chuckled at the mysterious cryptic commands thing; I think perhaps this where you can do the most good with the smallest effort; There a probably a lot of people like me who just need the smallest bit of help with stuff we're used to like App shortcuts, and where the custom installation should go. A couple of clicks and keystrokes to set everything up far less daunting with comprehensive instructions. Even if you just explained it in what ever is your distro of choice; something like that for you may be trivial compared to the average artist trying to set it up themselves.

I genuinely believe that with the lower memory and software overhead of linux and the growing number of highly capable opensource software solutions including yours; that Linux as a VFX desktop platform is not only possible but preferable in a lot of cases. It's just a lot of little things like ensuring people can install and open up software with less clicks.

Understand if you're a little low on time or the other addons require more attention. Hopefully if I find out how to set this up myself I can offer to update the readme to offer than information if you're up for it.

-S

from krita-ai-tools.

SimonHeggie avatar SimonHeggie commented on June 25, 2024

I thought I'd try my hardest to attempt to script the terminal instructions for this myself so I could at least share the easy install method with others in the mean time. It's a lot to copy but perhaps one copy and paste into terminal is preferable to the headache of trying to learn how to do it manually. I wish I could make it a script but I guess chmod is terminal only.

Here's goes:

Create the installation directory (in the user's home directory to avoid permission issues (hacky I know, lol))

mkdir -p ~/Krita && cd ~/Krita

Define URLs

KRITA_URL="https://binary-factory.kde.org/job/Krita_Stable_Appimage_Build/lastSuccessfulBuild/artifact/krita-5.2.1-e88f114a1c-x86_64.appimage"
SEGMENTATION_PLUGIN_URL=$(curl -s https://api.github.com/repos/Acly/krita-ai-tools/releases/latest | grep browser_download_url | grep tar.gz | cut -d '"' -f 4)

Download Krita AppImage if not already downloaded or if a newer version is available

if [ ! -f krita.appimage ] || [ ! -s krita.appimage ]; then
wget -N -O krita.appimage "$KRITA_URL"
fi

Download Segmentation Plugin if not already downloaded or if a newer version is available

if [ ! -f krita_segmentation_plugin.tar.gz ] || [ ! -s krita_segmentation_plugin.tar.gz ]; then
wget -N -O krita_segmentation_plugin.tar.gz "$SEGMENTATION_PLUGIN_URL"
fi

Make the Krita AppImage executable

chmod +x krita.appimage

Extract Krita AppImage and the segmentation plugin

./krita.appimage --appimage-extract
tar -xf krita_segmentation_plugin.tar.gz -C squashfs-root/

Obvious problem you can see; Github can get latest but I can't seem to get latest for Krita so I'm assuming my script will not work very shortly. If I could at least find a version of Krita 5.2 on Github, maybe I can begin to make this function correctly... But I'm determined to make this easy to access on Linux.

from krita-ai-tools.

SimonHeggie avatar SimonHeggie commented on June 25, 2024

Sorry for some reason github does wasn't to show the comments this as code... Let me know if you know how to get around it! 'Code' button doesn't help...

I have adjusted my script to store meta instead of the tar and appimage in order to optimise space. I guess I should try to find a github mirror of Krita so I can fix that problem.

`# Create the installation directory (in the user's home directory to avoid permission issues)
mkdir -p ~/Krita && cd ~/Krita

Define URLs

KRITA_URL="https://binary-factory.kde.org/job/Krita_Stable_Appimage_Build/lastSuccessfulBuild/artifact/krita-5.2.1-e88f114a1c-x86_64.appimage"
SEGMENTATION_PLUGIN_URL=$(curl -s https://api.github.com/repos/Acly/krita-ai-tools/releases/latest | grep browser_download_url | grep tar.gz | cut -d '"' -f 4)

Function to update metadata file

update_metadata() {
local filename=$1
local metadata_file=$2
local size=$(stat -c%s "$filename")
echo "$filename $size" > "$metadata_file"
}

Function to check if file is up to date

is_up_to_date() {
local filename=$1
local metadata_file=$2
if [ -f "$metadata_file" ]; then
local saved_metadata=$(cat "$metadata_file")
local current_metadata="$filename $(stat -c%s "$filename")"
[ "$saved_metadata" = "$current_metadata" ]
else
return 1 # Not up to date if metadata file doesn't exist
fi
}

Download and extract Krita AppImage if not up to date

KRITA_METADATA="krita_metadata.txt"
if ! is_up_to_date "krita.appimage" "$KRITA_METADATA"; then
wget -N -O krita.appimage "$KRITA_URL"
chmod +x krita.appimage
./krita.appimage --appimage-extract
update_metadata "krita.appimage" "$KRITA_METADATA"
fi

Download and extract Segmentation Plugin if not up to date

SEGMENTATION_PLUGIN_METADATA="segmentation_plugin_metadata.txt"
if ! is_up_to_date "krita_segmentation_plugin.tar.gz" "$SEGMENTATION_PLUGIN_METADATA"; then
wget -N -O krita_segmentation_plugin.tar.gz "$SEGMENTATION_PLUGIN_URL"
tar -xf krita_segmentation_plugin.tar.gz -C squashfs-root/
update_metadata "krita_segmentation_plugin.tar.gz" "$SEGMENTATION_PLUGIN_METADATA"
fi
`

from krita-ai-tools.

SimonHeggie avatar SimonHeggie commented on June 25, 2024

Annnnd I can see why you were suggesting to build from scratch ahaha.

only way we can use Github to ensure one command to fit all future updates for getting latest.

I'm thinking I may need to adjust the script to build from source after all...

EDIT:

Btw, I know my script is broken atm. Need to get it to wait while the downloads happen then execute. Currently working on a revision.

from krita-ai-tools.

Acly avatar Acly commented on June 25, 2024

Not sure what you mean by "build from source", that would be very linuxy, but have you ever built Krita before?
(btw code block is three backticks ```)

Anyway I think your best bet if you want to make it more accessible is to automate creating a AppImage/flatpack with the plugin included (maybe using GitHub Workflows).

from krita-ai-tools.

SimonHeggie avatar SimonHeggie commented on June 25, 2024

Cheers. I got my script working; I'm no programmer either, I just asked GPT to do it. Lol.

#!/bin/bash

# Create the installation directory (in the user's home directory)
INSTALL_DIR=~/Krita
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"

# Define the base URL for Krita downloads
BASE_KRITA_URL="https://binary-factory.kde.org/job/Krita_Stable_Appimage_Build/lastSuccessfulBuild/artifact/"

# Download the webpage and parse it to find the link to the latest Krita AppImage
KRITA_URL=$(curl -s $BASE_KRITA_URL | grep -o 'krita-.*\.appimage"' | head -1 | sed 's/"$//')

# Complete the URL for Krita AppImage
FULL_KRITA_URL="${BASE_KRITA_URL}${KRITA_URL}"

# Download the latest Krita AppImage if it doesn't already exist
if [ ! -f "$INSTALL_DIR/krita.appimage" ] || [ ! -s "$INSTALL_DIR/krita.appimage" ]; then
    wget -O "$INSTALL_DIR/krita.appimage" "$FULL_KRITA_URL"
fi

# Make the Krita AppImage executable
chmod +x "$INSTALL_DIR/krita.appimage"

# Extract Krita AppImage
"$INSTALL_DIR/krita.appimage" --appimage-extract

# Define URL for the latest segmentation plugin
SEGMENTATION_PLUGIN_URL=$(curl -s https://api.github.com/repos/Acly/krita-ai-tools/releases/latest | grep browser_download_url | grep tar.gz | cut -d '"' -f 4)

# Download the segmentation plugin if it doesn't already exist
if [ ! -f "$INSTALL_DIR/krita_segmentation_plugin.tar.gz" ] || [ ! -s "$INSTALL_DIR/krita_segmentation_plugin.tar.gz" ]; then
    wget -O "$INSTALL_DIR/krita_segmentation_plugin.tar.gz" "$SEGMENTATION_PLUGIN_URL"
fi

# Extract the segmentation plugin
tar -xf "$INSTALL_DIR/krita_segmentation_plugin.tar.gz" -C squashfs-root/

# Create a desktop shortcut for Krita
DESKTOP_FILE=~/.local/share/applications/krita.desktop
echo "[Desktop Entry]" > "$DESKTOP_FILE"
echo "Type=Application" >> "$DESKTOP_FILE"
echo "Name=Krita" >> "$DESKTOP_FILE"
echo "Icon=$INSTALL_DIR/squashfs-root/usr/share/icons/hicolor/512x512/apps/krita.png" >> "$DESKTOP_FILE"
echo "Exec=env APPDIR=$INSTALL_DIR/squashfs-root APPIMAGE=1 $INSTALL_DIR/squashfs-root/AppRun %U" >> "$DESKTOP_FILE"
echo "Terminal=false" >> "$DESKTOP_FILE"
echo "Categories=Graphics;" >> "$DESKTOP_FILE"
echo "StartupWMClass=krita" >> "$DESKTOP_FILE"

echo "Installation of Krita completed."

Only a couple more things to fix;

-Trying to get it to store a meta file with the last version number downloaded to determine whether a download is necessary

-Delete the AppImage and Tar file when done to optimize file size.

-For some reason desktop shortcut is not showing in arch menu under 'graphics' but still shows up via a search which means it can still be pinned to the dashbar; so not ideal, but close enough for this artist.

-Move the install somewhere smarter. I hear great things about /OPT, but for some reason file transfer crawls to a very slow speed in MB per second.

Still it's working and can be set up easily this way.
Not bad for a Linux noob! :D

Might keep it relatively to myself till I iron out some wrinkles.

-S

from krita-ai-tools.

SimonHeggie avatar SimonHeggie commented on June 25, 2024

Done.

For you Acly I have taken the time to write an install script which will provided pretty much everything your average desktop user is going to need to for the next couple of releases until something breaks. But maybe this can be used to bring you more Linux users in the hopes you get more support.

Here's the install:

echo "Installing Krita to ~/.Applications/Krita (hidden in your home directory)"
INSTALL_DIR=~/.Applications/Krita
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"

echo "Getting the latest download for Krita and Segmentation Tools"
BASE_KRITA_URL="https://binary-factory.kde.org/job/Krita_Stable_Appimage_Build/lastSuccessfulBuild/artifact/"
KRITA_PAGE=$(curl -s $BASE_KRITA_URL)
LATEST_KRITA_APPIMAGE=$(echo "$KRITA_PAGE" | grep -o 'krita-.*\.appimage"' | head -1 | sed 's/"$//')
LATEST_PLUGIN=$(curl -s https://api.github.com/repos/Acly/krita-ai-tools/releases/latest | grep browser_download_url | grep tar.gz | cut -d '"' -f 4)

echo "Checking to see if your version of Krita is up to date?"
if [ ! -f "$LATEST_KRITA_APPIMAGE" ]; then
    echo "Downloading new Krita"
    wget -O "$LATEST_KRITA_APPIMAGE" "${BASE_KRITA_URL}${LATEST_KRITA_APPIMAGE}"
    chmod +x "$LATEST_KRITA_APPIMAGE"
    "./$LATEST_KRITA_APPIMAGE" --appimage-extract
else
    echo "Latest Krita is already installed; moving on."
fi

echo "Updating the desktop file with correct paths"
EXTRACTED_DESKTOP_FILE="$INSTALL_DIR/squashfs-root/org.kde.krita.desktop"
ICON_PATH="$INSTALL_DIR/squashfs-root/krita.png"
if [ -f "$EXTRACTED_DESKTOP_FILE" ]; then
    echo "Pointing shortcut to Krita and tools"
    sed -i 's|^Exec=.*|Exec=env APPDIR='$INSTALL_DIR'/squashfs-root APPIMAGE=1 '$INSTALL_DIR'/squashfs-root/AppRun %U|' "$EXTRACTED_DESKTOP_FILE"
    sed -i 's|^Icon=.*|Icon='$ICON_PATH'|' "$EXTRACTED_DESKTOP_FILE"
    cp "$EXTRACTED_DESKTOP_FILE" ~/.local/share/applications/
else
    echo "Extracted desktop file not found, it could have been moved."
fi

echo "Checking if segmentation plugin is outdated"
if [ ! -f "$(basename "$LATEST_PLUGIN")" ]; then
    echo "Downloading new plugin"
    wget -O "$(basename "$LATEST_PLUGIN")" "$LATEST_PLUGIN"
    tar -xf "$(basename "$LATEST_PLUGIN")" -C squashfs-root/
else
    echo "Latest segmentation plugin is already installed."
fi

echo "DONE! Installed Krita with Segmentation tools built in."
echo "For more info go here: https://github.com/Acly/krita-ai-tools"

And the uninstall script:

# Ask for confirmation to uninstall Krita
read -p "Really, uninstall Krita? [Y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    # Define directories and files
    INSTALL_DIR=~/.Applications/Krita
    DESKTOP_FILE=~/.local/share/applications/org.kde.krita.desktop
    RESOURCE_DIR=~/.local/share/krita
    LOG_FILES=(~/.local/share/krita.log ~/.local/share/krita-sysinfo.log)

    # Ask whether to remove all related resources and log files
    echo "Uninstall all related resources and log files? [Y/N]"
    read -p "" -n 1 -r
    echo
    if [[ $REPLY =~ ^[Yy]$ ]]; then
        # Full Uninstall: Remove Krita, resource folders, and log files
        rm -rf "$INSTALL_DIR" "$DESKTOP_FILE" "$RESOURCE_DIR" "${LOG_FILES[@]}"
        echo "Full uninstall completed, including resources and log files."
    else
        # Standard Uninstall: Remove Krita and desktop file, preserve resources and logs
        rm -rf "$INSTALL_DIR" "$DESKTOP_FILE"
        echo "Uninstall completed, resources and log files preserved."
    fi
else
    echo "Uninstall aborted."
fi

I get now that you really just have to use terminal; because even something this complex you can simple copy and paste and walk off get a coffee and come back and everything is set up correctly with your segmentation tools.

Don't know about anyone else but this made my life easier!

-S

from krita-ai-tools.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.