-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_appimage
executable file
·144 lines (95 loc) · 3.41 KB
/
get_appimage
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#
# tarball2appimage by LinuxDicasPro
#
####################################
destdir=~/__APPIMAGE__
test -e "../_APPIMAGE" && destdir="../_APPIMAGE" # Opcional
###########################################
arch="x86_64"
prg="Telegram"
link="https://github.com/telegramdesktop/tdesktop/releases"
###########################################
for i in {1..35}; { printf '─'; }; printf "\n"
printf "Search latest version: "
########
version="$(grep -Eom1 "([0-9]+[.]){2}[0-9]+" <(grep -Em1 "Latest" <(links -dump "$link")))"
########
printf "\033[1;32m$version\033[m\n"
for i in {1..35}; { printf '─'; }; printf "\n"
test -z "$version" && {
echo "update script. version not found!"
exit 1
}
set -e
test ! -e $destdir && mkdir -p $destdir
cd $destdir
test -e "$prg-$version-$arch.AppImage" && {
echo "appimage found!"
exit 0
}
test ! -e "appimagetool-x86_64.AppImage" && {
link_tool="https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage"
wget -c -q --show-progress "$link_tool"
chmod +x "appimagetool-x86_64.AppImage"
}
#########
link_prg="https://github.com/telegramdesktop/tdesktop/releases/download/v${version}/tsetup.${version}.tar.xz"
link_svg="https://raw.githubusercontent.com/LinuxDicasPro/Telegram_AppImage/refs/heads/master/telegram.png"
#########
wget -c -q --show-progress "$link_prg"
file_prg=${link_prg##*/}
cwd=$PWD
rm -rf "$prg.AppDir"
mkdir -p "$prg.AppDir"
cd "$prg.AppDir"
echo -e "\nextract $file_prg ..."
printf "$file_prg\t["
tar -xf "$cwd/$file_prg" --checkpoint=400 --checkpoint-action=exec='printf ='
echo -e "]\n"
wget -c -q --show-progress -O "$prg.png" "$link_svg"
####################################
appimage_name="Telegram"
comment="Telegram Desktop Chat Client"
categories="Network;"
####################################
echo "[Desktop Entry]
Name=$appimage_name
GenericName=$appimage_name
Comment=$comment
Exec=$prg -- %u
Icon=$prg
Type=Application
Terminal=false
Categories=$categories" > "$prg.desktop"
echo "#!/bin/bash
rm -rf ~/.local/share/applications/org.telegram.desktop*.desktop
cd \$APPDIR
desktopfile=~/.local/share/applications/$prg.desktop
iconfile=~/.local/share/icons/telegram.png
autostart=~/.config/autostart/$prg.desktop
test ! -e \"\$desktopfile\" && cp $prg.desktop ~/.local/share/applications/
test ! -e \"\$iconfile\" && cp $prg.png ~/.local/share/icons/telegram.png
test ! -e \"\$autostart\" && cp $prg.desktop ~/.config/autostart/
if ! grep -q \"\$APPIMAGE\" \"\$desktopfile\"; then
sed -i \"s:Exec=.*:Exec=\$APPIMAGE:\" \"\$desktopfile\"
sed -i \"s:Icon=.*:Icon=\$iconfile:\" \"\$desktopfile\"
sed -i \"s:Exec=.*:Exec=\$APPIMAGE -autostart:\" \"\$autostart\"
sed -i \"s:Icon=.*:Icon=\$iconfile:\" \"\$autostart\"
/usr/bin/update-desktop-database -q || true
test -e usr/share/icons/hicolor/icon-theme.cache && {
test -x /usr/bin/gtk-update-icon-cache && /usr/bin/gtk-update-icon-cache ~/.local/share/pixmaps/ 2>&1 >&- || true
}
fi
cd \$APPDIR/$prg
./$prg \"\$@\"" > AppRun
chmod +x AppRun
cd ..
printf "\n"; for ((i=0; i<$COLUMNS; i++)); { printf '─'; }; echo -e "\n"
env ARCH=$arch ./appimagetool-x86_64.AppImage "$prg.AppDir"
mv "${appimage_name// /_}-$arch.AppImage" "$prg-$version-$arch.AppImage"
printf "\n"; for ((i=0; i<$COLUMNS; i++)); { printf '─'; }; echo -e "\n"
rm -rf "$prg.AppDir"
cd ..
echo "appimage saved in $destdir/$prg-$version-$arch.AppImage"
exit 0