-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·127 lines (110 loc) · 4.24 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·127 lines (110 loc) · 4.24 KB
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
#!/usr/bin/env bash
# install.sh — Installe Session Timeline dans le menu Applications.
# Pose un .desktop principal + un .desktop "Désinstaller", l'icône SVG, et un wrapper
# graphique de désinstallation utilisable depuis Activités sans terminal.
set -euo pipefail
# $HOME est interpolé dans des heredocs et des fichiers .desktop. On refuse
# toute valeur qui rendrait cette interpolation exploitable (LDAP/NIS/CI où
# un admin malveillant peut fixer HOME à `/tmp";rm -rf ~;"`).
case "$HOME" in
""|[!/]*)
echo "Erreur : HOME doit être un chemin absolu (HOME=$HOME)" >&2
exit 1
;;
*[\"\'\`\$\\]*|*$'\n'*|*$'\r'*|*$'\t'*)
echo "Erreur : HOME contient des caractères non sûrs (HOME=$HOME)" >&2
exit 1
;;
esac
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BIN_SRC="$DIR/target/release/session-timeline"
ICON_SRC="$DIR/assets/session-timeline.svg"
APP_NAME="Session Timeline"
APP_ID="session-timeline"
if [ ! -f "$BIN_SRC" ]; then
echo "Compilation initiale (peut prendre quelques minutes)…"
cd "$DIR" && cargo build --release
fi
mkdir -p "$HOME/.local/bin"
mkdir -p "$HOME/.local/share/applications"
mkdir -p "$HOME/.local/share/icons/hicolor/scalable/apps"
# 1) Lien symbolique vers le binaire
ln -sf "$BIN_SRC" "$HOME/.local/bin/$APP_ID"
# 2) Icône
cp "$ICON_SRC" "$HOME/.local/share/icons/hicolor/scalable/apps/$APP_ID.svg"
# 3) Wrapper GUI de désinstallation (zenity)
cat > "$HOME/.local/bin/${APP_ID}-uninstall-gui" <<'GUIEOF'
#!/usr/bin/env bash
set -u
ZENITY="$(command -v zenity || true)"
KDIALOG="$(command -v kdialog || true)"
NOTIFY="$(command -v notify-send || true)"
APP="Session Timeline"
ID="session-timeline"
ask() {
if [ -n "$ZENITY" ]; then
zenity --question --no-wrap --title="Désinstaller $APP" \
--text="Voulez-vous vraiment désinstaller $APP ?\n\nLe daemon de suivi (s'il est installé) sera également arrêté."
elif [ -n "$KDIALOG" ]; then
kdialog --yesno "Voulez-vous vraiment désinstaller $APP ?"
else return 0; fi
}
inform() {
if [ -n "$ZENITY" ]; then zenity --info --no-wrap --title="Désinstallation terminée" --text="$1"
elif [ -n "$KDIALOG" ]; then kdialog --msgbox "$1"
elif [ -n "$NOTIFY" ]; then notify-send "$APP" "$1"; fi
}
if ask; then
systemctl --user disable --now screen-state-tracker.service 2>/dev/null || true
rm -f "$HOME/.config/systemd/user/screen-state-tracker.service"
rm -f "$HOME/.local/bin/screen-state-tracker"
systemctl --user daemon-reload 2>/dev/null || true
rm -f "$HOME/.local/share/applications/$ID.desktop"
rm -f "$HOME/.local/share/applications/$ID-uninstall.desktop"
rm -f "$HOME/.local/share/icons/hicolor/scalable/apps/$ID.svg"
rm -f "$HOME/.local/bin/$ID"
rm -f "$HOME/.local/bin/${ID}-uninstall"
update-desktop-database "$HOME/.local/share/applications/" 2>/dev/null || true
gtk-update-icon-cache "$HOME/.local/share/icons/hicolor" 2>/dev/null || true
inform "$APP a été désinstallé."
rm -f "$0"
fi
GUIEOF
chmod +x "$HOME/.local/bin/${APP_ID}-uninstall-gui"
# 4) CLI uninstall (alias vers le wrapper GUI)
cat > "$HOME/.local/bin/${APP_ID}-uninstall" <<EOF
#!/usr/bin/env bash
exec "$HOME/.local/bin/${APP_ID}-uninstall-gui" "\$@"
EOF
chmod +x "$HOME/.local/bin/${APP_ID}-uninstall"
# 5) .desktop principal
cat > "$HOME/.local/share/applications/$APP_ID.desktop" <<EOF
[Desktop Entry]
Type=Application
Name=$APP_NAME
Comment=Visualisation de l'historique d'utilisation du système
Exec=$HOME/.local/bin/$APP_ID
Icon=$APP_ID
Categories=System;Utility;Monitor;
Terminal=false
StartupNotify=true
StartupWMClass=$APP_ID
EOF
# 6) .desktop uninstaller
cat > "$HOME/.local/share/applications/$APP_ID-uninstall.desktop" <<EOF
[Desktop Entry]
Type=Application
Name=Désinstaller $APP_NAME
Comment=Retire $APP_NAME du menu système
Exec=$HOME/.local/bin/${APP_ID}-uninstall-gui
Icon=edit-delete
Categories=System;Settings;
Terminal=false
EOF
update-desktop-database "$HOME/.local/share/applications/" 2>/dev/null || true
gtk-update-icon-cache "$HOME/.local/share/icons/hicolor" 2>/dev/null || true
echo
echo "✓ Session Timeline installé."
echo " → Cherche « Session Timeline » dans le menu Activités."
echo " → Pour désinstaller : tape « désinstall » dans Activités, ou lance"
echo " « session-timeline-uninstall » dans un terminal."