From 228a7e8dbf498bd7fa4494af7a03590a6775fe3e Mon Sep 17 00:00:00 2001 From: coolneng Date: Fri, 30 Apr 2021 00:00:50 +0200 Subject: [PATCH] Save emacs session before shutdown with a script --- scripts/.local/share/scripts/power-manager | 16 ++++++++++++++++ sway/.config/sway/config | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 scripts/.local/share/scripts/power-manager diff --git a/scripts/.local/share/scripts/power-manager b/scripts/.local/share/scripts/power-manager new file mode 100755 index 0000000..66670f1 --- /dev/null +++ b/scripts/.local/share/scripts/power-manager @@ -0,0 +1,16 @@ +#!/bin/sh + +usage() { + echo "Usage: power-manager " + echo "operation: poweroff|reboot" +} + +if [ $# -lt 1 ]; then + usage + exit 1 +fi + +operation=$1 + +emacsclient --eval '(doom/save-session "~/.emacs.d/.local/etc/workspaces/autosave")' && + systemctl "$operation" diff --git a/sway/.config/sway/config b/sway/.config/sway/config index e764f70..b3f7796 100644 --- a/sway/.config/sway/config +++ b/sway/.config/sway/config @@ -286,8 +286,8 @@ bindsym $mod+Shift+p mode "$Pause-break" set $Pause-break (p) poweroff, (r) reboot mode "$Pause-break" { - bindsym s exec --no-startup-id systemctl poweroff , mode "default" - bindsym r exec --no-startup-id systemctl reboot, mode "default" + bindsym s exec --no-startup-id ~/.local/share/scripts/power-manager "poweroff", mode "default" + bindsym r exec --no-startup-id ~/.local/share/scripts/power-manager "reboot", mode "default" bindsym Return mode "default" bindsym Escape mode "default"