From 811b94ed72e3a1fa503576fd649e94b3598a8ebb Mon Sep 17 00:00:00 2001 From: nnduc Date: Wed, 29 Jul 2026 20:10:58 +0700 Subject: [PATCH] sleep --- i3/config | 5 +++-- i3/scripts/lock-then-suspend | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 i3/scripts/lock-then-suspend diff --git a/i3/config b/i3/config index ffc6d3d..35201cb 100755 --- a/i3/config +++ b/i3/config @@ -11,7 +11,7 @@ set $mod Mod1 set $wallpaper_dir /sync/images/wallpapers -set $terminal 'wezterm' +set $terminal 'alacritty' # Font for window titles. Will also be used by the bar unless a different font # is used in the bar {} block below. font pango:NotoSans 12 @@ -38,7 +38,7 @@ exec --no-startup-id xset dpms 300 600 900 exec --no-startup-id xss-lock -- ~/.config/i3/scripts/lock $wallpaper_dir bindsym $mod+l exec ~/.config/i3/scripts/lock-now $wallpaper_dir -bindsym $mod+Shift+o exec systemctl suspend +bindsym $mod+Shift+o exec --no-startup-id ~/.config/i3/scripts/lock-then-suspend $wallpaper_dir bindsym $mod+Shift+p exec systemctl poweroff bindsym Print exec --no-startup-id bash -c 'f="$(xdg-user-dir PICTURES)/$(date +%s_scrot.png)" && scrot -s "$f" && xclip -selection clipboard -t image/png -i "$f" && notify-send "Screenshot saved" "$f"' @@ -47,6 +47,7 @@ bindsym $mod+Print exec --no-startup-id bash -c 'f="$(xdg-user-dir PICTURES)/$(d # and nm-applet is a desktop environment-independent system tray GUI for it. # applets +exec --no-startup-id snixembed --fork exec --no-startup-id picom --config ~/.config/picom/picom.conf exec --no-startup-id fcitx5 -d exec --no-startup-id nm-applet diff --git a/i3/scripts/lock-then-suspend b/i3/scripts/lock-then-suspend new file mode 100755 index 0000000..072d51f --- /dev/null +++ b/i3/scripts/lock-then-suspend @@ -0,0 +1,12 @@ +#!/bin/bash +wall_dir="${1:?wallpaper directory required}" +img=$(find "$wall_dir" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | shuf -n1) +tmp=/tmp/lockscreen.png +res=$(xrandr --current | awk '/ connected/ {getline; print $1; exit}') +: "${res:=1920x1080}" +if [ -n "$img" ] && convert "$img" -resize "${res}^" -gravity Center -extent "$res" "$tmp" 2>/dev/null; then + i3lock -i "$tmp" +else + i3lock -c 000000 +fi +systemctl suspend