From d535c9ffd2b2340ae82207dd509a0c8c1545e986 Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Sat, 16 May 2026 23:26:45 +0200 Subject: [PATCH] sway: screenshots, polkit floating, flatpak dark theme Screenshots - Swap xfce4-screenshooter for flameshot + grim/slurp/jq; xfce4 used the X11 selection so clipboard didn't round-trip to Wayland clients. Print invokes flameshot's editor; Shift/Alt+Print are quick grim-based captures via a small wrapper script. Flameshot is now autostarted so the first capture isn't slow. Polkit - Add for_window rules so the xfce-polkit dialog (and any other polkit agent) always opens floating. Flatpak dark theme - Write /etc/flatpak/overrides/global with GTK_THEME=Yaru-Blue-dark for legacy GTK apps, plus a sway-portals.conf so the Settings portal is served by xdg-desktop-portal-gtk (wlr doesn't implement it). That lets libadwaita apps see color-scheme=prefer-dark. cleanup-sway: track the new package set. Co-Authored-By: Claude Opus 4.7 --- ansible/inventory/group_vars/void.yml | 5 ++- .../profile_desktop_common/tasks/main.yml | 22 ++++++++++ .../files/sway-portals.conf | 4 ++ .../roles/profile_desktop_sway/tasks/main.yml | 10 +++++ dotfiles/desktop/.config/sway/config | 17 ++++++-- .../desktop/.config/sway/scripts/screenshot | 40 +++++++++++++++++++ scripts/cleanup-sway.sh | 4 ++ 7 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 ansible/roles/profile_desktop_sway/files/sway-portals.conf create mode 100755 dotfiles/desktop/.config/sway/scripts/screenshot diff --git a/ansible/inventory/group_vars/void.yml b/ansible/inventory/group_vars/void.yml index 87796f2..ae181c1 100644 --- a/ansible/inventory/group_vars/void.yml +++ b/ansible/inventory/group_vars/void.yml @@ -174,8 +174,12 @@ desktop_i3_packages: desktop_sway_packages: - cliphist - dunst + - flameshot + - grim + - jq - kanshi - rofi + - slurp - swayfx - swaybg - swayidle @@ -183,7 +187,6 @@ desktop_sway_packages: - SwayOSD - Waybar - wl-clipboard - - xfce4-screenshooter - xdg-desktop-portal-wlr - xorg-server-xwayland diff --git a/ansible/roles/profile_desktop_common/tasks/main.yml b/ansible/roles/profile_desktop_common/tasks/main.yml index 91b0d24..2983dc6 100644 --- a/ansible/roles/profile_desktop_common/tasks/main.yml +++ b/ansible/roles/profile_desktop_common/tasks/main.yml @@ -464,6 +464,28 @@ - (desktop_flatpak_extensions | default([])) | length > 0 - item | length > 0 +- name: Ensure /etc/flatpak/overrides exists + tags: [packages, flatpak, theme] + ansible.builtin.file: + path: /etc/flatpak/overrides + state: directory + owner: root + group: root + mode: "0755" + when: (desktop_flatpak_packages | default([])) | length > 0 + +- name: Force dark GTK theme for Flatpak applications + tags: [packages, flatpak, theme] + ansible.builtin.copy: + dest: /etc/flatpak/overrides/global + content: | + [Environment] + GTK_THEME={{ desktop_flatpak_gtk_theme | default('Yaru-Blue-dark') }} + owner: root + group: root + mode: "0644" + when: (desktop_flatpak_packages | default([])) | length > 0 + - name: Bootstrap rustup toolchain installer tags: [packages] block: diff --git a/ansible/roles/profile_desktop_sway/files/sway-portals.conf b/ansible/roles/profile_desktop_sway/files/sway-portals.conf new file mode 100644 index 0000000..d55d092 --- /dev/null +++ b/ansible/roles/profile_desktop_sway/files/sway-portals.conf @@ -0,0 +1,4 @@ +[preferred] +default=gtk +org.freedesktop.impl.portal.Screenshot=wlr +org.freedesktop.impl.portal.ScreenCast=wlr diff --git a/ansible/roles/profile_desktop_sway/tasks/main.yml b/ansible/roles/profile_desktop_sway/tasks/main.yml index de3032b..d3163fa 100644 --- a/ansible/roles/profile_desktop_sway/tasks/main.yml +++ b/ansible/roles/profile_desktop_sway/tasks/main.yml @@ -37,6 +37,16 @@ mode: "0755" when: "'sway' in (desktop_sessions_enabled | default([]))" +- name: Configure xdg-desktop-portal backend preferences for sway + tags: [packages, services, sway, portal] + ansible.builtin.copy: + src: sway-portals.conf + dest: /etc/xdg/xdg-desktop-portal/sway-portals.conf + owner: root + group: root + mode: "0644" + when: "'sway' in (desktop_sessions_enabled | default([]))" + - name: Copy sway desktop dotfiles tags: [dotfiles, dotfiles:desktop, sway] ansible.builtin.copy: diff --git a/dotfiles/desktop/.config/sway/config b/dotfiles/desktop/.config/sway/config index 8280aee..6c5995f 100644 --- a/dotfiles/desktop/.config/sway/config +++ b/dotfiles/desktop/.config/sway/config @@ -62,6 +62,11 @@ gaps outer 4 smart_gaps on smart_borders on +# Window rules +for_window [app_id="(?i)polkit"] floating enable +for_window [class="(?i)polkit"] floating enable +for_window [title="^Authentication Required"] floating enable + # Autostart — XDG and session services exec dex --autostart --environment sway exec gnome-keyring-daemon --start --components=secrets @@ -85,6 +90,7 @@ exec /usr/libexec/xfce-polkit exec nm-applet exec blueman-applet exec udiskie +exec flameshot # Clipboard manager (Wayland-native) exec wl-paste --type text --watch cliphist store @@ -125,10 +131,13 @@ bindsym $mod+Shift+x exec ~/.config/sway/scripts/lockscreen # Kill focused window bindsym $mod+Shift+q kill -# Screenshot (xfce4-screenshooter via xdg-desktop-portal-wlr) -bindsym Print exec xfce4-screenshooter -bindsym Shift+Print exec xfce4-screenshooter -r -bindsym Alt+Print exec xfce4-screenshooter -w +# Screenshot +# Print → flameshot GUI (annotations, save + clipboard via portal) +# Shift+Print → grim+slurp region → clipboard +# Alt+Print → grim focused output → clipboard +bindsym Print exec flameshot gui --path "$HOME/Pictures/Screenshots" --clipboard +bindsym Shift+Print exec ~/.config/sway/scripts/screenshot region +bindsym Alt+Print exec ~/.config/sway/scripts/screenshot output # Focus bindsym $mod+$left focus left diff --git a/dotfiles/desktop/.config/sway/scripts/screenshot b/dotfiles/desktop/.config/sway/scripts/screenshot new file mode 100755 index 0000000..c63481b --- /dev/null +++ b/dotfiles/desktop/.config/sway/scripts/screenshot @@ -0,0 +1,40 @@ +#!/bin/sh +# Quick screenshot helpers for sway. Captures via grim, saves to disk and +# also copies to the Wayland clipboard. Use the flameshot binding for +# annotations / fancy capture. +# +# Usage: screenshot {full|region|output|window} + +set -eu + +mode="${1:-full}" +dir="$HOME/Pictures/Screenshots" +mkdir -p "$dir" +file="$dir/$(date +%Y%m%d_%H%M%S).png" + +case "$mode" in + full) + grim "$file" + ;; + region) + grim -g "$(slurp)" "$file" + ;; + output) + out=$(swaymsg -t get_outputs --raw \ + | jq -r '.[] | select(.focused) | .name') + grim -o "$out" "$file" + ;; + window) + geom=$(swaymsg -t get_tree \ + | jq -r '.. | select(.focused? == true) + | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)"') + grim -g "$geom" "$file" + ;; + *) + printf 'Usage: %s {full|region|output|window}\n' "$0" >&2 + exit 1 + ;; +esac + +wl-copy < "$file" +notify-send "Screenshot saved" "$file" -i image-x-generic >/dev/null 2>&1 || true diff --git a/scripts/cleanup-sway.sh b/scripts/cleanup-sway.sh index 82b9242..f16e0c5 100755 --- a/scripts/cleanup-sway.sh +++ b/scripts/cleanup-sway.sh @@ -7,7 +7,11 @@ set -eu SWAY_PACKAGES=" cliphist +flameshot +grim +jq kanshi +slurp swayfx swaybg swayidle