-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiconkeeper.sh
More file actions
executable file
·84 lines (69 loc) · 1.82 KB
/
iconkeeper.sh
File metadata and controls
executable file
·84 lines (69 loc) · 1.82 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
#!/bin/bash
CONFIG_FILE="$HOME/.config/plasma-org.kde.plasma.desktop-appletsrc"
BACKUP_DIR="$HOME/.config/iconkeeper/backups"
mkdir -p "$BACKUP_DIR"
usage() {
echo "Usage:"
echo " iconkeeper backup Create a new backup"
echo " iconkeeper list List available backups"
echo " iconkeeper restore <filename> Restore a specific backup"
echo " iconkeeper restore last Restore the most recent backup"
exit 1
}
backup() {
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
BACKUP_FILE="$BACKUP_DIR/appletsrc_backup_$TIMESTAMP"
cp "$CONFIG_FILE" "$BACKUP_FILE"
echo "Backup created: $BACKUP_FILE"
}
list_backups() {
echo "Available backups:"
ls -1 "$BACKUP_DIR"
}
restore() {
local target="$1"
if [ -z "$target" ]; then
echo "Please specify a backup filename or 'last'."
list_backups
exit 1
fi
if [ "$target" == "last" ]; then
target=$(ls -1t "$BACKUP_DIR" | head -n 1)
if [ -z "$target" ]; then
echo "No backups found."
exit 1
fi
echo "Restoring most recent backup: $target"
fi
BACKUP_PATH="$BACKUP_DIR/$target"
if [ ! -f "$BACKUP_PATH" ]; then
echo "Backup file not found: $BACKUP_PATH"
exit 1
fi
cp "$BACKUP_PATH" "$CONFIG_FILE"
echo "Restored backup: $BACKUP_PATH"
echo "Restarting Plasma Shell..."
kquitapp5 plasmashell
sleep 1
kstart5 plasmashell &
# Wait until plasmashell is detected as running
while ! pgrep -x plasmashell > /dev/null; do
sleep 0.5
done
echo "Plasma Shell restarted successfully."
}
# Main logic
case "$1" in
backup)
backup
;;
list)
list_backups
;;
restore)
restore "$2"
;;
*)
usage
;;
esac