Add area screenshots and preserve stacking on hover focus

This commit is contained in:
Samuel Onoja committed 2026-09-26 23:22:38 +01:00
1 parent 8dc895448d
commit 5d6c610fec
9 files changed
+98 -15

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@
# Unspecified monitors use automatic placement and preferred modes.
[commands]
terminal = ["foot"]
screenshot = ["ferese-screenshot"]
[input]
xkb_layout = "us"
@@ -17,7 +18,7 @@ opacity = 0.95
text_primary = "#F0F3FA"
text_muted = "#AAB4C7"
# Super+Enter opens Foot. Super+Shift+E logs out.
# Super+Enter opens Foot. Super+Shift+S selects a screenshot. Super+Shift+E logs out.
# See README.md for monitor profiles and additional bindings.
[[window_rules]]
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Select an area, save it in Pictures/Screenshots, and copy it to the clipboard.
set -euo pipefail
umask 077
fail() {
echo "ferese-screenshot: $*" >&2
if command -v notify-send >/dev/null; then
notify-send --app-name=Ferese --urgency=critical 'Screenshot failed' "$*" || true
fi
exit 1
}
for tool in slurp grim wl-copy flock; do
command -v "$tool" >/dev/null || fail "Required command not found: $tool"
done
: "${XDG_RUNTIME_DIR:?A Wayland login session is required}"
exec 9>"$XDG_RUNTIME_DIR/ferese-screenshot.lock"
flock -n 9 || exit 0
# Escape cancels without creating a file or changing the clipboard.
geometry=$(slurp) || exit 0
[[ -n $geometry ]] || exit 0
pictures=$(xdg-user-dir PICTURES 2>/dev/null) || pictures="$HOME/Pictures"
directory=${pictures:-$HOME/Pictures}/Screenshots
mkdir -p -- "$directory" || fail 'Could not create the screenshot directory.'
file=$(mktemp "$directory/Screenshot-$(date +%Y-%m-%d_%H-%M-%S)-XXXXXX.png") || fail 'Could not create the screenshot file.'
trap 'rm -f -- "$file"' EXIT
grim -g "$geometry" "$file" || fail 'Could not capture the screen. Log back into Ferese after enabling screen capture.'
trap - EXIT
# Do not pass the selector lock to wl-copy's background clipboard process.
wl-copy --type image/png <"$file" 9>&- || fail "Saved to $file, but could not copy to the clipboard."
if command -v notify-send >/dev/null; then
notify-send --app-name=Ferese 'Screenshot saved and copied' "$file" || true
fi
printf '%s\n' "$file"
+2
View File
@@ -26,6 +26,8 @@ export XDG_SESSION_DESKTOP=ferese
export XDG_SESSION_TYPE=wayland
export MOZ_ENABLE_WAYLAND=1
export QT_QPA_PLATFORM=wayland
# Used by the area screenshot shortcut; explicitly set 0 to disable capture.
export FERESE_ENABLE_SCREENCOPY=${FERESE_ENABLE_SCREENCOPY:-1}
export PATH="$release_dir:$PATH"
unset WAYLAND_SOCKET
if [[ $backend == drm ]]; then