From 6383fabcb8ac13b5a5b12da1eb52f381831c00f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Tue, 21 Apr 2020 03:58:16 -0300 Subject: [PATCH] Create erctl, clean up session management. --- utils/.local/bin/erctl | 11 +++++++++++ wayland/.config/sway/config | 5 ++--- wayland/.local/bin/sway_exit_prompt | 8 ++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 utils/.local/bin/erctl create mode 100755 wayland/.local/bin/sway_exit_prompt diff --git a/utils/.local/bin/erctl b/utils/.local/bin/erctl new file mode 100755 index 0000000..7b06620 --- /dev/null +++ b/utils/.local/bin/erctl @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# ericonr's script for system tasks + +# detect session manager; +# systemd -> systemctl +# non-systemd -> loginctl +command -v systemctl >/dev/null 2>&1 && CTL=systemctl +CTL=${CTL:-loginctl} + +exec $CTL "$@" diff --git a/wayland/.config/sway/config b/wayland/.config/sway/config index e76cfcf..57d2a19 100644 --- a/wayland/.config/sway/config +++ b/wayland/.config/sway/config @@ -42,8 +42,7 @@ bindsym $mod+Shift+c reload # Restart sway inplace (can be used to upgrade sway) bindsym $mod+Shift+r restart # Exit sway -set $exit_command "swaynag -t warning -m 'You pressed the exit shortcut.' -b 'Exit session' 'swaymsg exit' -b 'Suspend device' 'systemctl suspend' -b 'Shut down' 'poweroff'" -bindsym $mod+Shift+e exec $exit_command +bindsym $mod+Shift+e exec sway_exit_command ## Input settings input * { @@ -173,7 +172,7 @@ bindsym --locked $mod+Mod1+a output * dpms on bindsym --locked $mod+Mod1+z output * dpms off # Sleep when closed behavior # TODO: create script to make this multi-platform -bindswitch --reload lid:on exec systemctl suspend +bindswitch --reload lid:on exec erctl suspend ## Layout # Split in horizontal orientation diff --git a/wayland/.local/bin/sway_exit_prompt b/wayland/.local/bin/sway_exit_prompt new file mode 100755 index 0000000..dd83585 --- /dev/null +++ b/wayland/.local/bin/sway_exit_prompt @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +exec swaynag \ + -t warning \ + -m 'You pressed the exit shortcut.' \ + -b 'Exit session' 'swaymsg exit' \ + -b 'Suspend device' 'erctl suspend' \ + -b 'Shut down' 'erctl poweroff'