New: Suspend script for laptops
This commit is contained in:
parent
29a5245604
commit
119bf89bcd
|
@ -6,7 +6,7 @@ if ! command -v ddcutil &>/dev/null && command -v light &>/dev/null; then
|
||||||
lvl="$(light -G)"
|
lvl="$(light -G)"
|
||||||
|
|
||||||
(swaylock; light -S "$lvl") &
|
(swaylock; light -S "$lvl") &
|
||||||
light -S 3
|
light -S 1
|
||||||
elif command -v ddcutil &>/dev/null; then
|
elif command -v ddcutil &>/dev/null; then
|
||||||
lvl="$(ddcutil getvcp 10 | awk '{
|
lvl="$(ddcutil getvcp 10 | awk '{
|
||||||
gsub(" ",""); # Remove spaces
|
gsub(" ",""); # Remove spaces
|
||||||
|
|
|
@ -429,6 +429,8 @@ bindswitch --reload --locked lid:on exec \
|
||||||
bindswitch --reload --locked lid:off exec \
|
bindswitch --reload --locked lid:off exec \
|
||||||
swaymsg output $laptop dpms on
|
swaymsg output $laptop dpms on
|
||||||
|
|
||||||
|
exec swayidle -w timeout 1200 '~/.config/sway/suspend_system.sh'
|
||||||
|
|
||||||
#bindswitch --reload --locked lid:on exec swaymsg output $laptop_screen disable
|
#bindswitch --reload --locked lid:on exec swaymsg output $laptop_screen disable
|
||||||
|
|
||||||
#bindswitch --reload --locked lid:on exec '[ $(swaymsg -t get_outputs | grep name | wc -l) == 1 ] && ($sleep) || ($notify "Clamshell mode" "Laptop screen off" && swaymsg output $laptop_screen disable)'
|
#bindswitch --reload --locked lid:on exec '[ $(swaymsg -t get_outputs | grep name | wc -l) == 1 ] && ($sleep) || ($notify "Clamshell mode" "Laptop screen off" && swaymsg output $laptop_screen disable)'
|
||||||
|
|
6
sway/suspend_system.sh
Executable file
6
sway/suspend_system.sh
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
if [[ "$(cat /proc/acpi/button/lid/LID0/state | awk '{print $2}')" == closed ]]
|
||||||
|
then
|
||||||
|
sudo /usr/local/bin/send_sleep_email.sh
|
||||||
|
systemctl suspend
|
||||||
|
fi
|
27
sway/template.send_sleep_email.sh
Normal file
27
sway/template.send_sleep_email.sh
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
declare -r TFILE="$(mktemp)"
|
||||||
|
|
||||||
|
cat <<EMAIL > "$TFILE"
|
||||||
|
From: Systemd-chan <systemd@mami2.moe>
|
||||||
|
To: Emiliko Mirror <emiliko@mami2.moe>
|
||||||
|
Subject: Sleep triggered on $(hostname)
|
||||||
|
Date: $(date)
|
||||||
|
|
||||||
|
Dear Emiliko,
|
||||||
|
|
||||||
|
$(hostname) went to sleep @ $(date)
|
||||||
|
|
||||||
|
============================== Battery ==============================
|
||||||
|
$(battery_status.sh)
|
||||||
|
=====================================================================
|
||||||
|
|
||||||
|
yours (truly),
|
||||||
|
Systemd
|
||||||
|
EMAIL
|
||||||
|
|
||||||
|
curl --silent --ssl-reqd \
|
||||||
|
--url 'smtps://smtp.gmail.com:465' \
|
||||||
|
--user 'systemd%40mami2.moe:app_password_here' \
|
||||||
|
--mail-from 'systemd@mami2.moe' \
|
||||||
|
--mail-rcpt 'emiliko@mami2.moe' \
|
||||||
|
--upload-file "$TFILE"
|
Loading…
Reference in a new issue