From b853d408228e794e60848ead8a9a0d4c6302178c Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 12 Feb 2025 13:35:40 +0800 Subject: [PATCH] Separate out the lock file --- .config/sway/scripts/lock.sh | 21 +++++++++++++++++++++ .config/sway/scripts/logout.sh | 16 +--------------- README.md | 3 +++ 3 files changed, 25 insertions(+), 15 deletions(-) create mode 100755 .config/sway/scripts/lock.sh diff --git a/.config/sway/scripts/lock.sh b/.config/sway/scripts/lock.sh new file mode 100755 index 0000000..4c65dd0 --- /dev/null +++ b/.config/sway/scripts/lock.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +playerctl stop || true + +bright=$(xbacklight -get) + +flock ~/.config/sway/locks/swayidle echo Successfully acquired lock + +swayidle -w \ + timeout 5 "xbacklight -set 0" resume "xbacklight -set $bright" \ + timeout 10 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' & + +idlepid=$! + +flock ~/.config/sway/locks/swaylock swaylock + +kill $idlepid +swaymsg "output * power on" +xbacklight -set $bright diff --git a/.config/sway/scripts/logout.sh b/.config/sway/scripts/logout.sh index ba607bb..a29f0a6 100755 --- a/.config/sway/scripts/logout.sh +++ b/.config/sway/scripts/logout.sh @@ -12,21 +12,7 @@ choices=("suspend" "poweroff" "reboot" "lock") choice=$(printf "%s\n" "${choices[@]}" | fuzzel -d --prompt "🔌: ") if test "$choice" = lock; then - sleep 0.3 - # playerctl stop - - bright=$(xbacklight -get) - - swayidle -w \ - timeout 5 "xbacklight -set 0" resume "xbacklight -set $bright" \ - timeout 10 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' & - idlepid=$! - - swaylock - - kill $idlepid - swaymsg "output * power on" - xbacklight -set $bright + $(dirname $0)/lock.sh elif test -n "$choice"; then systemctl $choice fi diff --git a/README.md b/README.md index 45fbd53..805359c 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ This list may be out-dated, check `.config/` folder for more. | ----------------------------- | --------------------------------------------------------------------------------------- | | `acpilight` | CLI for managing backlight | | `gui-apps/qt6ct` | To configure qt themes | +| `gui-apps/swaybg` | Set wallpaper for sway | +| `gui-apps/swayidle` | Auto suspend and lock | +| `gui-apps/swaylock` | Locking in sway | | `kde-frameworks/breeze-icons` | Icons for qt | | `pipewire` | Sound and screen sharing under Wayland | | `playerctld` | Control players, and show current playing |