34 lines
829 B
Bash
Executable File
34 lines
829 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
user="$USER"
|
|
|
|
sleep_lock_service_file="/etc/systemd/system/screenlocker.service"
|
|
|
|
screenlocker_file_contents="[Unit]
|
|
Description=Starts i3lock on suspend
|
|
Before=sleep.target
|
|
|
|
[Service]
|
|
User=x1phosura
|
|
Type=forking
|
|
Environment=DISPLAY=:0
|
|
ExecStart=/home/x1phosura/.config/i3/screenlocker.sh
|
|
|
|
[Install]
|
|
WantedBy=sleep.target"
|
|
|
|
|
|
if [ "$1" = "set" ]; then
|
|
sudo touch "$sleep_lock_service_file"
|
|
echo "$screenlocker_file_contents" | sudo tee "$sleep_lock_service_file"
|
|
sudo systemctl enable screenlocker.service
|
|
printf "Screenlocking upon closed lid enabled.\n"
|
|
elif [ "$1" = "unset" ]; then
|
|
sudo systemctl disable screenlocker.service
|
|
sudo rm "$sleep_lock_service_file"
|
|
printf "Screenlocking upon closed lid disabled.\n"
|
|
else
|
|
printf "Invalid arguments. Use 'set' or 'unset'.\n"
|
|
fi
|
|
|