-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·119 lines (100 loc) · 3.25 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
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
#!/bin/bash
# Detect user and computer name
USER_NAME=$(whoami)
COMPUTER_NAME=$(hostname)
INSTALL_DIR="/usr/local/bin"
SERVICE_FILE="/etc/systemd/system/littlewin.service"
install_dependencies() {
echo "Detecting distribution and installing dependencies..."
local dependencies="libx11-dev cmake gcc make"
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu | debian)
echo "Detected Debian-based distribution."
sudo apt update
for dep in $dependencies; do
if dpkg-query -l "$dep" &>/dev/null; then
echo "$dep is already installed."
else
echo "Installing $dep..."
sudo apt install -y "$dep"
fi
done
;;
rhel | fedora | centos | almalinux | rocky)
echo "Detected RHEL-based distribution."
sudo dnf check-update || sudo yum check-update
sudo dnf install -y libX11-devel cmake gcc make || sudo yum install -y libX11-devel cmake gcc make
;;
arch | manjaro)
echo "Detected Arch-based distribution."
sudo pacman -Syu --noconfirm
sudo pacman -S --noconfirm libx11 cmake gcc make
;;
*)
echo "Unsupported distribution: $ID"
exit 1
;;
esac
else
echo "Unable to detect distribution. Ensure dependencies are installed manually."
exit 1
fi
}
build_and_install() {
echo "Building the project..."
cmake .
make
echo "Installing littlewin to $INSTALL_DIR..."
sudo cp littlewin "$INSTALL_DIR/"
sudo chmod +x "$INSTALL_DIR/littlewin"
}
create_systemd_service() {
echo "Creating systemd service for littlewin..."
if [ -f "$SERVICE_FILE" ]; then
echo "Service already exists. Removing old service..."
sudo systemctl stop littlewin.service
sudo systemctl disable littlewin.service
sudo rm "$SERVICE_FILE"
fi
sudo bash -c "cat > $SERVICE_FILE" <<EOL
[Unit]
Description=littlewin window manager
After=graphical.target
[Service]
ExecStart=$INSTALL_DIR/littlewin
User=$USER_NAME
Environment=DISPLAY=:1
Environment=XDG_SESSION_TYPE=$XDG_SESSION_TYPE # Pass the session type environment variable
Restart=always
RestartSec=3
[Install]
WantedBy=default.target
EOL
sudo systemctl daemon-reload
sudo systemctl enable littlewin.service
sudo systemctl start littlewin.service
}
activate_dynamic_workspaces() {
if [ "$XDG_CURRENT_DESKTOP" == "GNOME" ]; then
echo "GNOME desktop detected. Activating dynamic workspaces..."
gsettings set org.gnome.mutter dynamic-workspaces true
echo "Dynamic workspaces activated."
elif [ "$XDG_CURRENT_DESKTOP" == "KDE" ]; then
echo "KDE desktop detected. Enabling dynamic virtual desktops..."
# Disable fixed desktop count and allow dynamic desktops
kwriteconfig5 --file kwinrc NumberOfDesktops 0 # 0 means dynamic desktop count
kwriteconfig5 --file kwinrc CurrentDesktop 1 # Start with desktop 1
qdbus org.kde.KWin /KWin reconfigure # Apply changes
echo "Dynamic virtual desktops enabled in KDE."
else
echo "Dynamic workspaces configuration is not applicable for $XDG_CURRENT_DESKTOP."
fi
}
echo "Starting installation of littlewin..."
install_dependencies
build_and_install
create_systemd_service
activate_dynamic_workspaces
echo "Installation complete! littlewin is set to run at login."