This repository has been archived by the owner on Apr 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk-itch-shortcut
executable file
·68 lines (59 loc) · 1.75 KB
/
mk-itch-shortcut
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
#!/usr/bin/env bash
shortcut_Name=""
shortcut_Comment=""
shortcut_Exec=""
shortcut_Icon=""
cd "$1"
getItchInfo(){
receipt=$(zcat .itch/receipt.json.gz)
shortcut_Name=$(echo $receipt | jq -r '.game.title')
shortcut_Comment=$(echo $receipt | jq -r '.game.shortText')
}
findExec(){
exec_x86_64=$(find "$PWD" -iname "$shortcut_Name.x86_64" | head -n 1)
# exec_x86=$(find "$PWD" -name "$shortcut_Name.x86" | head -n 1)
exec_sh=$(find "$PWD" -iname "$shortcut_Name.sh" | head -n 1)
exec_bin=$(find "$PWD" -executable -type f ! -iname "*$shortcut_Name*" | head -n 1)
exec_exe=$(find "$PWD" -iname "$shortcut_Name.exe" | head -n 1)
if [ "$exec_x86_64" ]; then
shortcut_Exec=$exec_x86_64
# elif [ "$exec_x86" ]; then
# shortcut_Exec=$exec_x86
elif [ "$exec_sh" ]; then
shortcut_Exec=$exec_sh
elif [ "$exec_bin" ]; then
shortcut_Exec=$exec_bin
elif [ "$exec_exe" ]; then
shortcut_Exec="wine $exec_exe"
fi
}
findIcon(){
icon_unity=$(find "$PWD" -name "UnityPlayer.png" | head -n 1)
icon_img=$(find "$PWD" -name "*.png" | head -n 1)
if [ "$icon_unity" ]; then
shortcut_Icon=$icon_unity
elif [ "$exec_exe" ]; then
wrestool -x -t 14 $exec_exe --output=icon.ico
icotool -x -i 6 icon.ico --output=icon.png
rm icon.ico
shortcut_Icon="$PWD/icon.png"
elif [ "$icon_img" ]; then
shortcut_Icon=$icon_img
fi
}
genEntry(){
echo "[Desktop Entry]"
echo "Type=Application"
echo "Name=$shortcut_Name"
echo "Comment=$shortcut_Comment"
echo "Icon=$shortcut_Icon"
echo "Terminal=false"
echo "Exec=$shortcut_Exec"
echo "Categories=Game"
}
echo "Generating application shortcut for $1"
getItchInfo
findExec
findIcon
genEntry > "$HOME/.local/share/applications/$shortcut_Name.desktop"
echo "Done. Entry located at: ~/.local/share/applications/$shortcut_Name.desktop"