-
Notifications
You must be signed in to change notification settings - Fork 2
/
suspend-hyprland-fix.sh
66 lines (54 loc) · 1.45 KB
/
suspend-hyprland-fix.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
#!/bin/bash
# Check if the script is run as root
if [ "$(id -u)" -ne 0 ]; then
echo "must be run as root. Please use sudo."
exit 1
fi
# Create the suspend-hyprland.sh script
cat > /usr/local/bin/suspend-hyprland.sh << 'EOF'
#!/bin/bash
case "$1" in
suspend)
killall -STOP Hyprland
;;
resume)
killall -CONT Hyprland
;;
esac
EOF
# Make the script executable
chmod +x /usr/local/bin/suspend-hyprland.sh
# Create the hyprland-suspend.service systemd service file
cat > /etc/systemd/system/hyprland-suspend.service << 'EOF'
[Unit]
Description=Suspend hyprland
Before=systemd-suspend.service
Before=systemd-hibernate.service
Before=nvidia-suspend.service
Before=nvidia-hibernate.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-hyprland.sh suspend
[Install]
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service
EOF
# Create the hyprland-resume.service systemd service file
cat > /etc/systemd/system/hyprland-resume.service << 'EOF'
[Unit]
Description=Resume hyprland
After=systemd-suspend.service
After=systemd-hibernate.service
After=nvidia-resume.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/suspend-hyprland.sh resume
[Install]
WantedBy=systemd-suspend.service
WantedBy=systemd-hibernate.service
EOF
# Reload the systemd daemon and enable the newly created services
systemctl daemon-reload
systemctl enable hyprland-suspend
systemctl enable hyprland-resume
echo "Installation complete!"