commit 83d33e9494e66389ceab05dab4bc76fcaf652147 Author: shvedes Date: Fri Oct 11 14:49:58 2024 +0200 Init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a86349 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +uninstall.sh +install.sh.bak +*.tar.xz diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d8fb607 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) [year] [fullname] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the \"Software\"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..0b19c83 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Adobe Photoshop CC 2021 on Linux + +## Disclaimer + +By providing this software, I do not give any guarantees of its work. This script was inspired by the work of [LinSoftWin](https://github.com/LinSoftWin/Photoshop-CC2022-Linux). This is only its adaptation. This script will be maintained and developed until I get bored and/or have free time. PR is welcome. + +## Showcase + +![image](https://github.com/user-attachments/assets/715d7b83-d872-4e68-983e-daa6704e79ab) +![image](https://github.com/user-attachments/assets/ad8c7477-4682-4edc-8665-4f5b5380a382) + +### What works + +- Drag and drop +- Mime type (right click menu, see [here](https://github.com/user-attachments/assets/eb5f7ab3-fb75-47e7-841b-a763ca5e3382)) +- GPU acceleration + +**Tested on:** +- Arch Linux +- KDE Plasma 6.1.5 (Wayland) +- wine 9.19 +- AMD GPU + +### Known issues + +- When hovering on toolbar item to see its instructions, black bars may appear around +- Wine's experimental wayland driver is completely broken + +## Installation + +```bash +git clone https://github.com/shvedes/photoshop-linux +cd photoshop-linux +./install.sh +``` +## To Do + +- [ ] Uninstall script +- [ ] More checks in the install script +- [ ] Ability for the user to select a default installation folder diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..507c64e --- /dev/null +++ b/install.sh @@ -0,0 +1,267 @@ +#!/usr/bin/env bash + +# Adapted script from LinSoftWin/Photoshop-CC2022-Linux + +export WINEPREFIX="$1" +export XDG_DATA_HOME="$HOME/.local/share" + +LOG_NORMAL="\e[1;97m" +LOG_ERROR="\e[1;31m" +LOG_SUCCESS="\e[1;32m" +LOG_RESET="\e[0m" + +TEMP_DIR="$(mktemp -d)" +FILENAME="Photoshop.tar.xz" + +trap 'on_error ${LINENO} "$BASH_COMMAND"' ERR +trap on_interrupt SIGINT + +on_interrupt() { + echo -e "\n${LOG_NORMAL}User intrrupt! Cleaning up..${LOG_RESET}" + + if [ -f "./$FILENAME" ]; then + rm "$FILENAME" + elif [ -d "./Adobe Photoshop 2021" ]; then + rm -rf "./Adobe Photoshop 2021" + fi + + [ -d "$WINEPREFIX" ] && rm -rf "$WINEPREFIX" + rm -rf "$TEMP_DIR" + exit 0 +} + +on_error() { + local lineno="$1" + local command="$2" + echo -e "${LOG_ERROR}[LOG] error in the line ${lineno}${LOG_RESET}: command '$command'" + exit 1 +} + +check_dependencies() { + declare -A packages=( + ["curl"]="curl" + ["wine"]="wine" + ["winetricks"]="winetricks" + ["magick"]="imagemagick" + ) + + local missed_packages=() + + for bin in "${!packages[@]}"; do + if ! command -v "$bin" > /dev/null; then + missed_packages+=("${packages[$bin]}") + fi + done + + if [ ${#missed_packages[@]} -eq 0 ]; then + echo -e "${LOG_SUCCESS}[LOG] All dependencies are installed${LOG_RESET}" && sleep 1 + else + echo -e "${LOG_ERROR}Missing dependencies:${LOG_NORMAL} ${missed_packages[@]}${LOG_RESET}" + exit 1 + fi +} + +setup_wine() { + + mkdir "$WINEPREFIX" + + echo -e "${LOG_NORMAL}[LOG] Folder $WINEPREFIX created${LOG_RESET}" + echo -e "${LOG_NORMAL}[LOG] Initializing wine and setting up winetricks.. It may take some time${LOG_RESET}" + + wineboot &> /dev/null + winetricks fontsmooth=rgb win10 gdiplus msxml3 msxml6 atmlib corefonts dxvk win10 vkd3d d3d12 vkd3d &> /dev/null + + echo -e "${LOG_NORMAL}[LOG] Downloading Visual C++ runtime...${LOG_RESET}" + + # 2015-2022 x64 + curl -s "https://aka.ms/vs/17/release/vc_redist.x64.exe" -o "${TEMP_DIR}/vc_redist_2015_2022_x64.exe" + echo -e " ${LOG_SUCCESS}Downloaded vc_redist_2015_2022_x64.exe${LOG_RESET}" + + # 2015-2022 x86 + curl -s "https://aka.ms/vs/17/release/vc_redist.x86.exe" -o "${TEMP_DIR}/vc_redist_2015_2022_x86.exe" + echo -e " ${LOG_SUCCESS}Downloaded vc_redist_2015_2022_x86.exe${LOG_RESET}" + + # 2013 x64 + curl -sL "https://aka.ms/highdpimfc2013x64enu" -o "${TEMP_DIR}/vc_redist_2013_x64.exe" + echo -e " ${LOG_SUCCESS}Downloaded vc_redist_2013_x64.exe${LOG_RESET}" + + # 2013 x86 + curl -sL "https://aka.ms/highdpimfc2013x86enu" -o "${TEMP_DIR}/vc_redist_2013_x86.exe" + echo -e " ${LOG_SUCCESS}Downloaded vc_redist_2013_x86.exe${LOG_RESET}" + + # 2012 x64 + curl -s "https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe" -o "${TEMP_DIR}/vc_redist_2012_x64.exe" + echo -e " ${LOG_SUCCESS}Downloaded vc_redist_2012_x64.exe${LOG_RESET}" + + # 2012 x86 + curl -s "https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exe" -o "${TEMP_DIR}/vc_redist_2012_x86.exe" + echo -e " ${LOG_SUCCESS}Downloaded vc_redist_2012_x86.exe${LOG_RESET}" + + # 2010 x64 + curl -s "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe" -o "${TEMP_DIR}/vc_redist_2010_x64.exe" + echo -e " ${LOG_SUCCESS}Downloaded vc_redist_2010_x64.exe${LOG_RESET}" + # 2010 x86 + curl -s "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe" -o "${TEMP_DIR}/vc_redist_2010_x86.exe" + echo -e " ${LOG_SUCCESS}Downloaded vc_redist_2010_x86.exe${LOG_RESET}" + + echo -e "${LOG_NORMAL}[LOG] Installing Visual C++...${LOG_RESET}" + + # 2015-2022 x64 + wine "${TEMP_DIR}/vc_redist_2015_2022_x64.exe" /install /quiet /norestart &> /dev/null + echo -e " ${LOG_SUCCESS}Installed vc_redist_2015_2022_x64.exe${LOG_RESET}" + + # 2015-2022 x86 + wine "${TEMP_DIR}/vc_redist_2015_2022_x86.exe" /install /quiet /norestart &> /dev/null + echo -e " ${LOG_SUCCESS}Installed vc_redist_2015_2022_x86.exe${LOG_RESET}" + + # 2013 x64 + wine "${TEMP_DIR}/vc_redist_2013_x64.exe" /install /quiet /norestart &> /dev/null + echo -e " ${LOG_SUCCESS}Installed vc_redist_2013_x64.exe${LOG_RESET}" + + # 2013 x86 + wine "${TEMP_DIR}/vc_redist_2013_x86.exe" /install /quiet /norestart &> /dev/null + echo -e " ${LOG_SUCCESS}Installed vc_redist_2013_x86.exe${LOG_RESET}" + + # 2012 x64 + wine "${TEMP_DIR}/vc_redist_2012_x64.exe" /install /quiet /norestart &> /dev/null + echo -e " ${LOG_SUCCESS}Installed vc_redist_2012_x64.exe${LOG_RESET}" + + # 2012 x86 + wine "${TEMP_DIR}/vc_redist_2012_x86.exe" /install /quiet /norestart &> /dev/null + echo -e " ${LOG_SUCCESS}Installed vc_redist_2012_x86.exe${LOG_RESET}" + + # 2010 x64 + wine "${TEMP_DIR}/vc_redist_2010_x64.exe" /q /norestart &> /dev/null + echo -e " ${LOG_SUCCESS}Installed vc_redist_2010_x64.exe${LOG_RESET}" + + # 2010 x86 + wine "${TEMP_DIR}/vc_redist_2010_x86.exe" /q /norestart &> /dev/null + echo -e " ${LOG_SUCCESS}Installed vc_redist_2010_x86.exe${LOG_RESET}" + + winecfg -v win10 &> /dev/null +} + +download_ps() { + local url="https://spyderrock.com/kMnq2220-AdobePhotoshop2021.xz" + # https://github.com/LinSoftWin/Photoshop-CC2022-Linux + local checksum="8321b969161f2d2ad736067320d493c5b6ae579eaab9400cd1fda6871af2c033" + + if [ -f "./$FILENAME" ]; then + echo -e "${LOG_NORMAL}[LOG] Found existing archive. Comparing checksums${LOG_RESET}" + local actual_checksum="$(sha256sum $FILENAME | awk '{print $1}')" + + if [ "$actual_checksum" != "$checksum" ]; then + echo -e "${LOG_ERROR}[LOG] Corrupted archive!${LOG_NORMAL} Redownloading (1.1G)${LOG_RESET}" + rm "./$FILENAME" + curl -s "$url" -o "$FILENAME" + else + echo -e "${LOG_SUCCESS}[LOG] Done${LOG_SUCCESS}" + fi + else + echo -e "${LOG_NORMAL}[LOG] Downloading Photoshop (1.1G)${LOG_RESET}" + curl -s "$url" -o "$FILENAME" + echo -e "${LOG_SUCCESS}[LOG] Downloaded Photoshop${LOG_RESET}" + + actual_checksum="$(sha256sum $FILENAME | awk '{print $1}')" + echo -e "${LOG_NORMAL}[LOG] Verifying checksums${LOG_RESET}" + + if [[ "$actual_checksum" != "$checksum" ]]; then + echo -e "${LOG_ERROR}[ERROR] Checksums are not matched!${LOG_NORMAL} Try to remove '$FILENAME' and exec this script again${LOG_RESET}" + exit 1 + else + echo -e "${LOG_SUCCESS}[LOG] Done${LOG_RESET}" + fi + fi +} + +install_ps() { + echo -e "${LOG_NORMAL}[LOG] Extracting Photoshop${LOG_RESET}" + tar -xf "./$FILENAME" + + echo -e "${LOG_NORMAL}[LOG] Installing Photoshop${LOG_RESET}" + mv "Adobe Photoshop 2021" "$WINEPREFIX/drive_c/Program Files/Adobe Photoshop 2021" +} + +install_icon() { + if [ -d "/usr/share/icons/Papirus" ]; then + DESKTOP_ENTRY_ICON_NAME="photoshop" + elif [ -d "$XDG_DATA_HOME/icons/Papirus" ]; then + DESKTOP_ENTRY_ICON_NAME="photoshop" + else + DESKTOP_ENTRY_ICON_NAME="$XDG_DATA_HOME/icons/photoshop.png" + ICON_URL="https://cdn3d.iconscout.com/3d/premium/thumb/adobe-photoshop-file-3d-icon-download-in-png-blend-fbx-gltf-formats--logo-format-graphic-design-pack-development-icons-9831950.png" + curl -s "$ICON_URL" -o "${TEMP_DIR}/icon.webp" + magick "${TEMP_DIR}/icon.webp" "${TEMP_DIR}/icon.png" + + [ ! -d "$XDG_DATA_HOME/icons" ] && mkdir "$XDG_DATA_HOME/icons" + mv ${TEMP_DIR}/icon.png "$XDG_DATA_HOME/icons/photoshop.png" + fi +} + +install_desktop_entry() { + local path="$XDG_DATA_HOME/applications/photoshop.desktop" + + echo "[Desktop Entry]" > "$path" + echo "Name=Adobe Photoshop CC 2021" >> "$path" + echo "Exec=bash -c "$WINEPREFIX/drive_c/launcher.sh %F"" >> "$path" + echo "Type=Application" >> "$path" + echo "Comment=The industry-standard photo editing software (Wine)" >> "$path" + echo "Categories=Graphics" >> "$path" + echo "Icon=$DESKTOP_ENTRY_ICON_NAME" >> "$path" + echo "MimeType=image/psd;image/x-psd;image/png;image/jpg;image/jpeg;image/webp;image/heif;image/raw" >> "$path" + echo "StartupWMClass=photoshop.exe" >> "$path" +} + +install_launcher() { + echo -e "${LOG_NORMAL}[LOG] Installing launcher${LOG_RESET}" + + local path="$WINEPREFIX/drive_c/launcher.sh" + + echo "#!/usr/bin/env bash" > "$path" + echo " " >> "$path" + echo "WINEPREFIX=\"$WINEPREFIX\"" >> "$path" + echo "DXVK_LOG_PATH=\"\$WINEPREFIX/dxvk_cache\"" >> "$path" + echo "DXVK_STATE_CACHE_PATH=\"\$WINEPREFIX/dxvk_cache\"" >> "$path" + echo "PHOTOSHOP=\"\$WINEPREFIX/drive_c/Program Files/Adobe Photoshop 2021/photoshop.exe\"" >> "$path" + echo " " >> "$path" + echo "wine64 \"\$PHOTOSHOP\" \"\$@\" " >> "$path" + + chmod +x "$path" +} + +checks() { + if [ -z "$1" ]; then + echo -e "${LOG_NORMAL}Usage: ./install.sh ${LOG_RESET}" + exit 0 + else + if [ -d "$1" ]; then + echo -e "${LOG_ERROR}Install path alrady exists${LOG_RESET}" + read -p "$(tput setaf 3)Do you want to remove it? (y/n) $(tput sgr0)" answer + + case "$answer" in + y) + rm -rf "$WINEPREFIX" + ;; + n) + exit 1 + ;; + esac + else + if [[ "$1" != /* ]]; then + echo -e "${LOG_NORMAL}You need to specify absolute path, not relative${LOG_RESET}" + exit 1 + fi + fi + fi +} + +checks "$1" +check_dependencies +setup_wine +download_ps +install_ps +install_icon +install_desktop_entry +install_launcher + +echo -e "${LOG_SUCCESS}[LOG] Photoshop successfully installed${LOG_RESET}"