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 <noreply@anthropic.com>
This commit is contained in:
Fabio Scotto di Santolo
2026-05-16 23:26:45 +02:00
parent e5a2b4ee41
commit 63cd774f6f
7 changed files with 97 additions and 5 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -0,0 +1,4 @@
[preferred]
default=gtk
org.freedesktop.impl.portal.Screenshot=wlr
org.freedesktop.impl.portal.ScreenCast=wlr

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -7,7 +7,11 @@ set -eu
SWAY_PACKAGES="
cliphist
flameshot
grim
jq
kanshi
slurp
swayfx
swaybg
swayidle