Skip to content

Commit

Permalink
Separate out the lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
rywng committed Feb 12, 2025
1 parent 04234fc commit b853d40
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
21 changes: 21 additions & 0 deletions .config/sway/scripts/lock.sh
Original file line number Diff line number Diff line change
@@ -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
16 changes: 1 addition & 15 deletions .config/sway/scripts/logout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down

0 comments on commit b853d40

Please sign in to comment.