/
kgpg
88 lines (74 loc) · 2.95 KB
/
kgpg
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
#!/bin/sh
APP=kdeutils
REPO="ivan-hc/KDE-utils-appimage"
# CREATE THE FOLDER
mkdir /opt/$APP
cd /opt/$APP
# ADD THE REMOVER
echo '#!/bin/sh' >> /opt/$APP/remove
echo "rm -R -f /usr/share/applications/AM-$APP*.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove
chmod a+x /opt/$APP/remove
# DOWNLOAD THE ARCHIVE
mkdir tmp
cd ./tmp
version=$(curl -Ls https://api.github.com/repos/$REPO/releases | jq '.' | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1)
wget $version
echo "$version" >> /opt/$APP/version
cd ..
mv ./tmp/*mage ./$APP
chmod a+x /opt/$APP/$APP
rmdir ./tmp
# LINK
ln -s /opt/$APP/$APP /usr/local/bin/$APP
# SCRIPT TO UPDATE THE PROGRAM
cat >> /opt/$APP/AM-updater << 'EOF'
#!/usr/bin/env bash
APP=kdeutils
REPO="ivan-hc/KDE-utils-appimage"
version0=$(cat /opt/$APP/version)
version=$(curl -Ls https://api.github.com/repos/$REPO/releases | jq '.' | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1)
if [ $version = $version0 ]; then
echo "Update not needed!"
else
notify-send "A new version of $APP is available, please wait"
mkdir /opt/$APP/tmp
cd /opt/$APP/tmp
wget $version
if ls . | grep mage; then
cd ..
if test -f ./tmp/*mage; then rm ./version
fi
echo $version >> ./version
mv --backup=t ./tmp/*mage ./$APP
chmod a+x /opt/$APP/$APP
rm -R -f ./tmp ./*~
fi
notify-send "$APP is updated!"
fi
EOF
chmod a+x /opt/$APP/AM-updater
# LAUNCHERS AND ICONS
mkdir icons
./kdeutils --appimage-extract > /dev/null
cp ./squashfs-root/usr/share/icons/hicolor/22x22/apps/* /opt/$APP/icons/ 2>/dev/null
cp ./squashfs-root/usr/share/icons/hicolor/24x24/apps/* /opt/$APP/icons/ 2>/dev/null
cp ./squashfs-root/usr/share/icons/hicolor/32x32/apps/* /opt/$APP/icons/ 2>/dev/null
cp ./squashfs-root/usr/share/icons/hicolor/48x48/apps/* /opt/$APP/icons/ 2>/dev/null
cp ./squashfs-root/usr/share/icons/hicolor/64x64/apps/* /opt/$APP/icons/ 2>/dev/null
cp ./squashfs-root/usr/share/icons/hicolor/128x128/apps/* /opt/$APP/icons/ 2>/dev/null
cp ./squashfs-root/usr/share/icons/hicolor/256x256/apps/* /opt/$APP/icons/ 2>/dev/null
cp ./squashfs-root/usr/share/icons/hicolor/512x512/apps/* /opt/$APP/icons/ 2>/dev/null
cp ./squashfs-root/usr/share/icons/hicolor/scalable/apps/* /opt/$APP/icons/ 2>/dev/null
cd /opt/$APP/icons
for file in *.png; do mv -- "$file" "${file%%.png}"; done
cd ..
mkdir /opt/$APP/launchers
cp ./squashfs-root/usr/share/applications/* /opt/$APP/launchers/ 2>/dev/null
cd /opt/$APP/launchers
for file in *; do mv ./$file ./AM-$APP-$file
done
sed -i "s#Exec=#Exec=/opt/kdeutils/kdeutils #g" /opt/$APP/launchers/*.desktop
sed -i "s#Icon=#Icon=/opt/kdeutils/icons/#g" /opt/$APP/launchers/*.desktop
cp /opt/$APP/launchers/*.desktop /usr/share/applications/
rm -R -f /opt/$APP/launchers
rm -R -f /opt/$APP/squashfs-root