From 77470bd03e43cd3762b122b1321a494f830d26ff Mon Sep 17 00:00:00 2001 From: Josue Zamudio Date: Tue, 27 Oct 2026 18:32:33 -0700 Subject: [PATCH] fix(portal): screen-capture script, portal backend, swaync autostart screen-capture.sh was a single non-executable line containing a `slur` typo, so it never ran and nothing referenced it; rewritten as a working region capture to ~/Pictures plus clipboard. xdg-desktop-portal/portals.conf pins the wlr backend for sway, and swaync is pulled in via graphical-session.target.wants so the portal's Requisite=graphical-session.target is satisfied (the reason screen sharing previously never started). --- .config/sway/scripts/screen-capture.sh | 34 +++++++++++++++++-- .../swaync.service | 1 + .config/xdg-desktop-portal/portals.conf | 22 ++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) mode change 100644 => 100755 .config/sway/scripts/screen-capture.sh create mode 120000 .config/systemd/user/graphical-session.target.wants/swaync.service create mode 100644 .config/xdg-desktop-portal/portals.conf diff --git a/.config/sway/scripts/screen-capture.sh b/.config/sway/scripts/screen-capture.sh old mode 100644 new mode 100755 index aa2fe68..cb009f4 --- a/.config/sway/scripts/screen-capture.sh +++ b/.config/sway/scripts/screen-capture.sh @@ -1,3 +1,33 @@ -#!/bin/bash +#!/bin/sh +# Region screenshot -> ~/Pictures + clipboard. +# +# This file used to contain a single broken line (`slur`, and it was not +# executable): the typo meant `slurp` never ran, and nothing referenced it +# anyway -- the $mod+shift+p keybind in config.d/keybinds has its own inline +# pipeline. Fixed and kept as the shared implementation so the behaviour is +# identical wherever it gets wired up. +# +# Usage: screen-capture.sh [region|output|full] (default: region) +# (no "window" mode: slurp offers region, `-o` output and `-p` point selection +# only -- it cannot pick a window) -slur +set -u + +outdir="${XDG_PICTURES_DIR:-$HOME/Pictures}" +mkdir -p "$outdir" +file="$outdir/$(date +%F-%H%M%S).png" + +case "${1:-region}" in + region) geom=$(slurp) || exit 1 # Esc cancels + [ -n "$geom" ] || exit 1 + grim -g "$geom" "$file" ;; + output) geom=$(slurp -o -f '%g') || exit 1 # pick a monitor + [ -n "$geom" ] || exit 1 + grim -g "$geom" "$file" ;; + full) grim "$file" ;; + *) echo "usage: $(basename "$0") [region|output|full]" >&2; exit 2 ;; +esac + +[ -s "$file" ] || { echo "capture failed" >&2; exit 1; } +wl-copy < "$file" +notify-send -i "$file" "Screenshot saved" "$file" diff --git a/.config/systemd/user/graphical-session.target.wants/swaync.service b/.config/systemd/user/graphical-session.target.wants/swaync.service new file mode 120000 index 0000000..9c6a60f --- /dev/null +++ b/.config/systemd/user/graphical-session.target.wants/swaync.service @@ -0,0 +1 @@ +/usr/lib/systemd/user/swaync.service \ No newline at end of file diff --git a/.config/xdg-desktop-portal/portals.conf b/.config/xdg-desktop-portal/portals.conf new file mode 100644 index 0000000..813d6df --- /dev/null +++ b/.config/xdg-desktop-portal/portals.conf @@ -0,0 +1,22 @@ +# Portal implementation pinning for the SWAY session. +# +# Without this file xdg-desktop-portal fell back to the deprecated `UseIn` key +# and picked hyprland.portal at random ("Choosing hyprland.portal ... via the +# deprecated UseIn key"), while the sway config also started the wlr portal -- +# two implementations registered at once. +# +# Base is Arch's own /usr/share/xdg-desktop-portal/sway-portals.conf. +# GlobalShortcuts is added because neither wlr nor gtk implements it, and +# easyeffects requests it (journal: "Unknown method CreateSession or interface +# org.freedesktop.impl.portal.GlobalShortcuts"). + +[preferred] +default=gtk +org.freedesktop.impl.portal.ScreenCast=wlr +org.freedesktop.impl.portal.Screenshot=wlr +# gtk's Inhibit uses org.gnome.SessionManager / org.freedesktop.ScreenSaver, +# neither of which sway implements; "none" lets apps use Wayland's +# idle-inhibit protocol, which sway does implement. +org.freedesktop.impl.portal.Inhibit=none +org.freedesktop.impl.portal.GlobalShortcuts=hyprland +org.freedesktop.impl.portal.InputCapture=hyprland