-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
57 lines (49 loc) · 1.38 KB
/
install.sh
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
#!/bin/bash
CONFIG_DIR="$HOME/.config/floflis/flomem"
#SCRIPT_DIR="/usr/lib"
SCRIPT_NAME="flomem"
# Function to drop sudo privileges whenever it isn't needed anymore
drop_sudo() {
# Drop sudo privileges
if [ "$(id -u)" = "0" ]; then
exec su -c "$0" "$SUDO_USER"
fi
}
# Function to create the config directory and files
create_config() {
mkdir -p "$CONFIG_DIR"
cp config.sh "$CONFIG_DIR/config.sh"
chmod +x "$CONFIG_DIR/config.sh"
}
# Function to create the action scripts
create_action_scripts() {
cp action.89.sh "$CONFIG_DIR/action.89.sh"
chmod +x "$CONFIG_DIR/action.89.sh"
cp action.95.sh "$CONFIG_DIR/action.95.sh"
chmod +x "$CONFIG_DIR/action.95.sh"
}
# Function to create the memory monitor script
create_monitor_script() {
sudo cp -f "$SCRIPT_NAME" "/usr/lib/"
sudo chmod +x "/usr/lib/$SCRIPT_NAME"
}
# Function to create a desktop entry for autostart
create_desktop_entry() {
mkdir -p "$HOME/.config/autostart"
cat > "$HOME/.config/autostart/flomem.desktop" << EOF
[Desktop Entry]
Type=Application
Name=Floflis Memory Monitor
Exec=/usr/lib/$SCRIPT_NAME
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
EOF
chmod +x "$HOME/.config/autostart/flomem.desktop"
}
create_config
create_action_scripts
create_monitor_script
create_desktop_entry
drop_sudo
echo "It seems that Floflis Memory Monitor has been installed successfully!"