Blame env-builder-data/build/script/packet/opentoonz-master.files/launch-opentoonz.sh

e14835
#!/bin/sh
e14835
b0fa99
SCRIPT_DIR=$(cd `dirname "$0"`; pwd)
e14835
BASE_DIR=`dirname "$SCRIPT_DIR"`
e14835
abfde6
export LD_LIBRARY_PATH="$BASE_DIR/lib:$BASE_DIR/lib/opentoonz:$BASE_DIR/lib64:$LD_LIBRARY_PATH"
caca5f
export XCURSOR_PATH="$BASE_DIR/share/icons:$XCURSOR_PATH:/usr/local/share/icons:/usr/share/icons"
caca5f
export QT_XKB_CONFIG_ROOT="$QT_XKB_CONFIG_ROOT:/usr/local/share/X11/xkb:/usr/share/X11/xkb"
e14835
f49009
# fix stuff
f49009
CONFIG_DIR="$HOME/.config/OpenToonz"
f49009
if [ ! -d "$CONFIG_DIR" ]; then
f49009
    echo "fix config: copy stuff".
f49009
    mkdir -p "$CONFIG_DIR"
f49009
    cp -r "$BASE_DIR/share/opentoonz/stuff" "$CONFIG_DIR"
f49009
f49009
    echo "fix config: create SystemVar.ini" 
f49009
    cat << EOF > "$CONFIG_DIR/SystemVar.ini"
f49009
[General]
f49009
OPENTOONZROOT="$HOME/.config/OpenToonz/stuff"
f49009
OpenToonzPROFILES="$HOME/.config/OpenToonz/stuff/profiles"
f49009
TOONZCACHEROOT="$HOME/.config/OpenToonz/stuff/cache"
f49009
TOONZCONFIG="$HOME/.config/OpenToonz/stuff/config"
f49009
TOONZFXPRESETS="$HOME/.config/OpenToonz/stuff/fxs"
f49009
TOONZLIBRARY="$HOME/.config/OpenToonz/stuff/library"
f49009
TOONZPROFILES="$HOME/.config/OpenToonz/stuff/profiles"
f49009
TOONZPROJECTS="$HOME/.config/OpenToonz/stuff/projects"
f49009
TOONZROOT="$HOME/.config/OpenToonz/stuff"
7a1a1f
TOONZSTUDIOPALETTE="$HOME/.config/OpenToonz/stuff/studiopalette"
f49009
EOF
f49009
f49009
else
f49009
    # fix paths
f49009
    INI="$HOME/.config/OpenToonz/SystemVar.ini"
f49009
    if [ -e "$INI" ]; then
f49009
        [ -e "$INI.bak" ] || cp "$INI" "$INI.bak"
f49009
7a1a1f
        # fix path to studiopalette
7a1a1f
        FX_PATH_OLD="$CONFIG_DIR/stuff/projects/studiopalette"
7a1a1f
        FX_PATH_NEW="$CONFIG_DIR/stuff/studiopalette"
7a1a1f
        FX_LINE_OLD="TOONZFXPRESETS=\"$FX_PATH_OLD\""
7a1a1f
        FX_LINE_NEW="TOONZFXPRESETS=\"$FX_PATH_NEW\""
7a1a1f
        if [ ! -z "`grep "$FX_LINE_OLD" "$INI"`" ] \
7a1a1f
         && ( [ ! -d "$FX_PATH_OLD" ] || [ -z "`ls -A "$FX_PATH_OLD"`" ] ); then
7a1a1f
            echo "fix config: fix path to studiopalette"
7a1a1f
            cat "$INI" \
7a1a1f
              | sed "s|$FX_LINE_OLD|$FX_LINE_NEW|g" \
7a1a1f
              > "$INI.out"
7a1a1f
            cp "$INI.out" "$INI"
7a1a1f
            rm -f "$INI.out"
7a1a1f
        fi
7a1a1f
f49009
        # fix path to fxs
f49009
        FX_PATH_OLD="$CONFIG_DIR/stuff/projects/fxs"
f49009
        FX_PATH_NEW="$CONFIG_DIR/stuff/fxs"
f49009
        FX_LINE_OLD="TOONZFXPRESETS=\"$FX_PATH_OLD\""
f49009
        FX_LINE_NEW="TOONZFXPRESETS=\"$FX_PATH_NEW\""
f49009
        if [ ! -z "`grep "$FX_LINE_OLD" "$INI"`" ] \
f49009
         && ( [ ! -d "$FX_PATH_OLD" ] || [ -z "`ls -A "$FX_PATH_OLD"`" ] ); then
f49009
            echo "fix config: fix path to fxs" 
f49009
            cat "$INI" \
f49009
              | sed "s|$FX_LINE_OLD|$FX_LINE_NEW|g" \
f49009
              > "$INI.out"
f49009
            cp "$INI.out" "$INI"
f49009
            rm -f "$INI.out"
f49009
        fi
f49009
f49009
        # fix path to library
f49009
        LIBRARY_PATH_OLD="$CONFIG_DIR/stuff/projects/library"
f49009
        LIBRARY_PATH_NEW="$CONFIG_DIR/stuff/library"
f49009
        LIBRARY_LINE_OLD="TOONZLIBRARY=\"$LIBRARY_PATH_OLD\""
f49009
        LIBRARY_LINE_NEW="TOONZLIBRARY=\"$LIBRARY_PATH_NEW\""
f49009
        if [ ! -z "`grep "$LIBRARY_LINE_OLD" "$INI"`" ] \
f49009
         && ( [ ! -d "$LIBRARY_PATH_OLD" ] || [ -z "`ls -A "$LIBRARY_PATH_OLD"`" ] ); then
f49009
            echo "fix config: fix path to library" 
f49009
            cat "$INI" \
f49009
              | sed "s|$LIBRARY_LINE_OLD|$LIBRARY_LINE_NEW|g" \
f49009
              > "$INI.out"
f49009
            cp "$INI.out" "$INI"
f49009
            rm -f "$INI.out"
f49009
        fi
f49009
    fi
d3f373
3de954
    # update library
3de954
    echo "update stuff" 
3de954
    mkdir -p "$CONFIG_DIR/stuff/config"
3de954
    mkdir -p "$CONFIG_DIR/stuff/profiles"
3de954
    cp -ur "$BASE_DIR/share/opentoonz/stuff/library" "$CONFIG_DIR/stuff/" 
d3f373
    cp -ur "$BASE_DIR/share/opentoonz/stuff/config/qss" "$CONFIG_DIR/stuff/config/" 
d3f373
    cp -ur "$BASE_DIR/share/opentoonz/stuff/config/loc" "$CONFIG_DIR/stuff/config/" 
3de954
    cp -ur "$BASE_DIR/share/opentoonz/stuff/profiles/layouts" "$CONFIG_DIR/stuff/profiles/" 
3de954
    cp -ur "$BASE_DIR/share/opentoonz/stuff/config/current.txt" "$CONFIG_DIR/stuff/config/" 
f49009
fi
f49009
e14835
cd "$BASE_DIR/bin"
38afb9
./opentoonz "$@"