Skip to content

feat: use spectacle for kde on wayland#84

Open
davidramiro wants to merge 1 commit intodshoreman:developfrom
davidramiro:develop
Open

feat: use spectacle for kde on wayland#84
davidramiro wants to merge 1 commit intodshoreman:developfrom
davidramiro:develop

Conversation

@davidramiro
Copy link
Copy Markdown

First of all, thanks for the great tool. Been using it on X11 for a while now and since I am now on Wayland, at least for KDE I could provide a way to use spectacle for selection and capture.

One upside is that spectacle allows for on-the-fly editing within the capture region. Downside is that we rely on pressing either the enter key or the Save or Copy button on the spectacle region capture.

Let me know if that works for you!

@davidramiro davidramiro force-pushed the develop branch 3 times, most recently from bed11fc to 8be8433 Compare December 13, 2025 14:27
Comment thread src/_capture.bash

spectacle "${args[@]}" "$1"

if [ ! -f "$1" ]; then
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're wondering about this check, if the users clicks on 'Copy' instead of pressing enter or using 'Save', no file gets created and we use the clipboard instead.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! On first glance... Problem is that's not the only time the file won't exist.

What if you abort? Slurp throws out a non-zero status if it fails for any reason, so Nextshot aborts. Spectacle seems to always report success though, regardless of which button was used… and so it continues, blissfully unaware that what's actually in the clipboard might not be a screenshot.

Whatever it was, it just shared it. There's no special status for pressing Esc either, so we can't even abort when you cancel the selection entirely.


Is there a good way to solve this?

We could use check_clipboard in the conditional which would at least prevent accidental text leaks, but it still doesn't guarantee the clipboard image came from Spectacle…

Copy link
Copy Markdown
Owner

@dshoreman dshoreman Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tl;dr: This might be much less of a problem, so I'm inclined to ignore (or create a new issue for) it so it doesn't block merge.


Long version:
Done some more testing in a vm that won't stop locking up, and apparently forgot my own code. from_checkout already enforces the image/png type; check_clipboard won't be necessary:

$ nextshot -a
Waiting for selection...
After selection (and optional edits), press [ENTER] or click on 'Save' or 'Copy'.
Clipboard content is not available as requested type "image/png"
Use "wl-paste --list-types" to view available types.

Aborted due to error

It still won't help if the clipboard does have an image, but the closest we could get to that might be listening for its dbus signal. ScreenshotFailed doesn't get fired for a quit but we could abort if Spectacle exits without a ScreenshotTaken signal. Feels like a lot of effort though…

@dshoreman
Copy link
Copy Markdown
Owner

Thanks! I haven't used Spectacle before so I setup a Fedora/KDE VM to test. Seems it does have a useReleaseToCapture option in the rc/gui, we just can't set it with a CLI flag.

The bigger problem might be Spectacle's apparent lack of any exit status beyond 0. Not too sure what to do about that issue, there's only a couple nitpicks otherwise. Looks good!

Copy link
Copy Markdown
Owner

@dshoreman dshoreman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the lengthy review! I'm mostly curious of your thoughts on solving the clipboard issue (or maybe I'm just overthinking it?)

Are you able to sign the commit(s)? If you're short for time don't worry about all the nitpicks, I can deal with those when I merge 👍

Comment thread src/_capture.bash
grim "${args[@]}" "$1"
}

shoot_wayland_plasma() {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename to shoot_plasma and move it above shoot_wayland? wayland_plasma is probably redundant with X11 slowly being dropped

Comment thread src/_capture.bash
}

shoot_wayland_plasma() {
local args
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local args
local args=(-b -n)

Since every call needs the background/no-notify flags we can set the common args inline here, unless shellcheck complains… Should be ok though.

Comment thread src/_capture.bash
local args
if [ "$mode" = "selection" ]; then
echo "After selection (and optional edits), press [ENTER] or click on 'Save' or 'Copy'." >&2
args=(-brn -o)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
args=(-brn -o)
args+=(-r)

same for the other cases too - -o will be better in the command which leaves only the mode option

Comment thread src/_capture.bash
args=(-bfn -o)
fi

spectacle "${args[@]}" "$1"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
spectacle "${args[@]}" "$1"
spectacle "${args[@]}" -o "$1"

Comment thread src/_capture.bash

spectacle "${args[@]}" "$1"

if [ ! -f "$1" ]; then
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! On first glance... Problem is that's not the only time the file won't exist.

What if you abort? Slurp throws out a non-zero status if it fails for any reason, so Nextshot aborts. Spectacle seems to always report success though, regardless of which button was used… and so it continues, blissfully unaware that what's actually in the clipboard might not be a screenshot.

Whatever it was, it just shared it. There's no special status for pressing Esc either, so we can't even abort when you cancel the selection entirely.


Is there a good way to solve this?

We could use check_clipboard in the conditional which would at least prevent accidental text leaks, but it still doesn't guarantee the clipboard image came from Spectacle…

Comment thread src/_env.bash
Comment on lines 35 to +41
is_wayland() {
[ "$NEXTSHOT_ENV" = "wayland" ]
}

is_plasma() {
[ "$DESKTOP_SESSION" = "plasma" ]
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_plasma first so it doesn't break up is_wayland and is_wayland_detected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants