summarylogtreecommitdiffstats
path: root/foobar2000.sh
blob: 429ef904cc1edc54aa03fb9e73c9a5f95876a976 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

progName="foobar2000"
progRealPath="/usr/share/$progName"
progHome="$HOME/.$progName"
progBin="$progName.exe"
progPrefix="$HOME/.local/share/wineprefixes/$progName"

# Symlink stuff
mkdir -p "$progHome" || exit 1
mkdir -p "$HOME/.local/share/wineprefixes" || exit 1
# Delete broken symlinks
find -L "$progHome" -type l -delete
# Update existing symlinks, add new symlinks
cp -urs "$progRealPath/"* "$progHome" 2> /dev/null

# Switches: use -something instead of /something to avoid confusion with Unix paths
# Also convert Unix paths to Windows paths.
declare -a args

for arg; do
    if [[ "${arg:0:1}" = "-" ]]; then
        args+=("${arg/#-//}")
    else
        args+=("$(winepath -w "$arg")")
    fi
done

# wine "$progHome/$progBin" "${args[@]}"
WINEPREFIX="$progPrefix" wine "$progHome/$progBin" "${args[@]}"