-
Notifications
You must be signed in to change notification settings - Fork 0
/
wine-prefix-remover.sh
executable file
·71 lines (59 loc) · 2.13 KB
/
wine-prefix-remover.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
### Constant declarations ###
WINEPREFIXFOLDER="$HOME/.wine-prefix"
### Function declarations ###
# Declare function to show usage of this script
show-usage () {
$SUBSCRIPT/highlighted-output.sh \
"Usage: $0 winehq|bottles"
}
### Variable declarations ###
THISSCRIPTPATH=$(readlink -f $0)
THISDIRPATH=$(dirname $THISSCRIPTPATH)
SUBSCRIPT=$THISDIRPATH/.scripts
INSTALLATIONVARIANT=$1
### Procedures ###
source $SUBSCRIPT/parameter-count-check.sh
source $SUBSCRIPT/root-protection.sh
root-protection || { show-usage && exit 1; }
parameter-count-check $# 1 || { show-usage && exit 1; }
$SUBSCRIPT/check-for-software-existence.sh fzf || exit 1
case "$INSTALLATIONVARIANT" in
"winehq")
$SUBSCRIPT/check-for-software-existence.sh winetricks || exit 1
wineprefix=$(ls -1v $WINEPREFIXFOLDER | grep -v 'tmp-downloads' \
| fzf --phony --no-multi --layout=reverse --border --header="Which bottle do you want to remove cleanly?" \
| xargs printf "%q\n")
if [ "$wineprefix" != "" ]; then
$SUBSCRIPT/highlighted-output.sh \
"Do you really want to remove \"$wineprefix\"?"
$SUBSCRIPT/press-any-key-helper.sh
WINEPREFIX=$WINEPREFIXFOLDER/$wineprefix winetricks --unattended --force annihilate
else
echo "ERROR! No wine prefix chosen. Did nothing."
exit 1
fi
;;
"bottles")
$SUBSCRIPT/check-for-software-existence.sh flatpak || exit 1
bottle=$(ls -1v $(flatpak run --command=bottles-cli com.usebottles.bottles info bottles-path) \
| fzf --phony --no-multi --layout=reverse --border --header="Which bottle do you want to remove cleanly?" \
| xargs printf "%q\n")
if [ "$bottle" != "" ]; then
$SUBSCRIPT/highlighted-output.sh \
"Do you really want to remove \"$bottle\"?"
$SUBSCRIPT/press-any-key-helper.sh
flatpak kill com.usebottles.bottles
rm -vrf "$(flatpak run --command=bottles-cli com.usebottles.bottles info bottles-path)/$bottle"
else
echo "ERROR! No bottle chosen. Did nothing."
exit 1
fi
;;
*)
echo "ERROR! You passed a wrong parameter! Aborting!"
show-usage
exit 1
;;
esac
exit 0