forked from Zren/plasma-applet-eventcalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·47 lines (40 loc) · 1.37 KB
/
install
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
# Version 5
# This script detects if the widget is already installed.
# If it is, it will use --upgrade instead and restart plasmashell.
packageNamespace=`kreadconfig5 --file="$PWD/package/metadata.desktop" --group="Desktop Entry" --key="X-KDE-PluginInfo-Name"`
packageServiceType=`kreadconfig5 --file="$PWD/package/metadata.desktop" --group="Desktop Entry" --key="X-KDE-ServiceTypes"`
restartPlasmashell=false
for arg in "$@"; do
case "$arg" in
-r) restartPlasmashell=true;;
--restart) restartPlasmashell=true;;
*) ;;
esac
done
isAlreadyInstalled=false
kpackagetool5 --type="${packageServiceType}" --show="$packageNamespace" &> /dev/null
if [ $? == 0 ]; then
isAlreadyInstalled=true
fi
### metadata.desktop => metadata.json
if command -v desktoptojson &> /dev/null ; then
genOutput=`desktoptojson --serviceType="plasma-applet.desktop" -i "$PWD/package/metadata.desktop" -o "$PWD/package/metadata.json"`
if [ "$?" != "0" ]; then
exit 1
fi
# Tabify metadata.json
sed -i '{s/ \{4\}/\t/g}' "$PWD/package/metadata.json"
fi
if $isAlreadyInstalled; then
# Eg: kpackagetool5 -t "Plasma/Applet" -u package
kpackagetool5 -t "${packageServiceType}" -u package
restartPlasmashell=true
else
# Eg: kpackagetool5 -t "Plasma/Applet" -i package
kpackagetool5 -t "${packageServiceType}" -i package
fi
if $restartPlasmashell; then
killall plasmashell
kstart5 plasmashell
fi