forked from petchema/playonlinux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze_menus
executable file
·48 lines (43 loc) · 1.43 KB
/
analyze_menus
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
#!/bin/bash
# Required: lp64
PREFIX="$1"
RELATIVEPATH="$2"
if [ -z "$PREFIX" ]; then
echo "Usage: $0 <prefixname> [<relative program path>]"
echo "relative program path: unix path from drive C root"
echo " (eg. 'Program Files/GOG.com/Lure of Temptress/')"
exit 1
fi
WINEPREFIX="$HOME/.PlayOnLinux/wineprefix/$PREFIX"
if [ ! -d "$WINEPREFIX" ]; then
echo "Prefix \`$PREFIX' does not exist."
exit 1
fi
if [ -d "$WINEPREFIX/drive_c/users/Public/Start Menu" ]; then
MENUNAME='Start Menu'
elif [ -d "$WINEPREFIX/drive_c/users/Public/Menu Démarrer" ]; then
MENUNAME='Menu Démarrer'
else
echo "Could not find global menu data"
exit 1
fi
for user in "Public" "`id -un`"; do
cd "$WINEPREFIX/drive_c/users/$user/$MENUNAME" &&
find . -type f -a -name '*.lnk' -print| \
while read lnkname; do
# echo "----------"
# echo "$lnkname"
LABEL="${lnkname##*/}"
LABEL="${LABEL%.lnk}"
IFS='' LP_OUT="$(lp64 $lnkname)"
BIN="$(echo $LP_OUT|perl -ne 'chomp; if(/^ID List:\s*(.*)/) { print $1 }')"
# echo "raw bin: $BIN"
BIN="${BIN//\\//}"
# echo "forward slashes bin: $BIN"
BIN="${BIN#*drive_c/}"
[ -n "$RELATIVEPATH" ] && BIN="${BIN#$RELATIVEPATH}"
# echo "relative bin: $BIN"
ARGS="$(echo $LP_OUT|perl -ne 'chomp; if(/^cmdline args:\s*(.*)/) { print $1 }')"
echo -e " * $LABEL\t[\"$BIN\" $ARGS]"
done
done