-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers
72 lines (68 loc) · 1.74 KB
/
helpers
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
#!/bin/sh
# Helper functions to be called by htmlscript applications
ProgressDialog() {
if [ "$1" = "--close" ]; then
$QDBUS $PROGRESS_DIALOG org.kde.kdialog.ProgressDialog.close
unset PROGRESS_DIALOG
return
fi
if [ -e /usr/lib64/qt6/bin/qdbus ]; then
QDBUS=/usr/lib64/qt6/bin/qdbus
elif [ -e /usr/lib/qt6/bin/qdbus ]; then
QDBUS=/usr/lib/qt6/bin/qdbus
elif [ -e /usr/bin/qdbus ]; then
QDBUS=/usr/bin/qdbus
else
pkexec dnf install --assumeyes qt6-qttools-dbus
if [ -e /usr/lib64/qt6/bin/qdbus ]; then
QDBUS=/usr/lib64/qt6/bin/qdbus
elif [ -e /usr/lib/qt6/bin/qdbus ]; then
QDBUS=/usr/lib/qt6/bin/qdbus
fi
fi
if [ -z "$QDBUS" ]; then
# If the user denied installing qt6-qttools-dbus or
# installation failed, ignore it, we only need it to
# control the progress indicator, so it isn't vital
QDBUS=true
fi
PROGRESS_DIALOG=$(kdialog --title $"OpenMandriva" --progressbar "$1" 0)
$QDBUS $PROGRESS_DIALOG org.kde.kdialog.ProgressDialog.showCancelButton false
}
install_if_needed() {
if ! rpm -q $1 &>/dev/null; then
if [ -n "$2" ]; then
APP="$2"
else
APP="$1"
fi
ProgressDialog $"Installing $APP"
pkexec dnf install --assumeyes "$1"
ProgressDialog --close
if ! rpm -q $1 &>/dev/null; then
kdialog --title $"OpenMandriva" --msgbox $"Installation failed."
exit 1
fi
fi
}
kcmshell() {
KCMSHELL=""
if [ "$KDE_SESSION_VERSION" = "5" ]; then
if which kcmshell5 &>/dev/null; then
KCMSHELL=kcmshell5
elif which kcmshell6 &>/dev/null; then
KCMSHELL=kcmshell6
fi
else
if which kcmshell6 &>/dev/null; then
KCMSHELL=kcmshell6
elif which kcmshell5 &>/dev/null; then
KCMSHELL=kcmshell5
fi
fi
if [ -z "$KCMSHELL" ]; then
install_if_needed kf6-kcmutils
KCMSHELL=kcmshell6
fi
$KCMSHELL "$@"
}