noctalia-shell icon indicating copy to clipboard operation
noctalia-shell copied to clipboard

[FEATURE] Add possibility to screenshot a window

Open inkurey-22 opened this issue 4 months ago • 9 comments

Submission checklist

  • [x] I have searched existing issues and confirmed this has not been requested before.
  • [x] I have checked existing pull requests for similar changes.

Feature type

New functionality

Feature summary

Add a screenshot-window, screenshot-window pick... to the shell commands

Motivation / use case

I (and so do other people i guess ?) want to screenshot a specific window/application. Screenshot region works well enough most of the time but being able to directly take the focused window or picking one is a nice "little" improvement.

Proposed solution

Add new screenshot commands to noctalia msg that capture a specific window (focused by the compositor, ask the user to pick one or directly pass an id (i think all windows have a kind of ID, at least in hyprland)

Alternatives considered

No response

References / related projects

No response

Additional context

No response

inkurey-22 avatar Jul 11 '26 16:07 inkurey-22

This would be useful for me as well.

dommcdev avatar Jul 12 '26 23:07 dommcdev

Based on my experience, it is very difficult to accurately calculate tiled window positions through IPC on the current Niri, and my plugin even has to patch Niri just to run.

Pulsar33550336 avatar Jul 20 '26 02:07 Pulsar33550336

That would be awesome to have also capturing monitor when clicking on it instead of the current way that we have to click on the monitor button to confirm.

msmafra avatar Aug 01 '26 13:08 msmafra

I understand that getting window geometry universally across WMs is hard. But what if Noctalia just exposes an IPC command like

screenshot-region wxh@x,y
screenshot-region DP-1 wxh@x,y

Users who already use hyprctl or custom Lua scripts can calculate the window position themselves and pass it to Noctalia. This keeps the core simple and puts the WM-specific logic in the user's hands. This would be a good Unix philosophy approach and solve the issue for advanced users immediately.

gamedragon avatar Sep 11 '26 03:09 gamedragon

One wild idea might be: offload the responsibility of getting window positions to plugins 😄

Pulsar33550336 avatar Sep 11 '26 06:09 Pulsar33550336

I'm waiting for this too!

linuxmobile avatar Sep 27 '26 18:09 linuxmobile

For Niri users, a script to use in the meantime:

#!/usr/bin/env bash
screenshot_dir="$HOME/Pictures/Screenshots"

niri msg action screenshot-window && sleep 0.05 # Wait a bit for file to appear
unset -v latest
# Loop through to skip ls-unsafety
for file in "$screenshot_dir"/*; do
  [[ $file -nt $latest ]] && latest=$file
done
noctalia msg annotate "$latest"

Save it somewhere and use a niri binding:

Mod+Shift+W { spawn-sh "path/to/the/script"; }

Probably gets slow if you don't ever clean up your screenshots though 😅

tokebe avatar Sep 30 '26 16:09 tokebe

For Niri users, a script to use in the meantime:

#!/usr/bin/env bash screenshot_dir="$HOME/Pictures/Screenshots"

niri msg action screenshot-window && sleep 0.05 # Wait a bit for file to appear unset -v latest

Loop through to skip ls-unsafety

for file in "$screenshot_dir"/*; do [[ $file -nt $latest ]] && latest=$file done noctalia msg annotate "$latest" Save it somewhere and use a niri binding:

Mod+Shift+W { spawn-sh "path/to/the/script"; } Probably gets slow if you don't ever clean up your screenshots though 😅

Or this that won't loop into the folder

#!/usr/bin/env bash

get_niri_window_and_capture() {
    local screenshot_path
    local get_current_time
    local different_path

    shift
    different_path="${1}"
    get_current_time="$(date +'%Y-%m-%d_%H-%M-%S')"

    if [[ -z "${different_path}" ]]; then
        screenshot_path="${XDG_PICTURES_DIR}/Screenshots/Screenshot_${get_current_time}.png"
    else
        if [[ -d "${different_path}" ]]; then
            screenshot_path="${different_path}/Screenshot_${get_current_time}.png"
        else
            printf "Path provided seems not valid: %s\n" "${different_path}"
            exit 1
        fi
    fi

    printf "Capture will be stored at %s\n" "${screenshot_path}"
    niri msg action screenshot-window --path "${screenshot_path}" && sleep 0.05 # Wait a bit for file to appear

    if [[ -r "${screenshot_path}" ]]; then
        noctalia msg annotate "${screenshot_path}"
    else
        printf "Couldn't find or access the file %s to annotate\n" "${screenshot_path}"
        exit 1
    fi

}
get_niri_window_and_capture "${@}"

msmafra avatar Sep 30 '26 19:09 msmafra

Hello, if anyone build from source, can you test in your compositor? Thanks

I have tested on umbriel and got feedback saying working on hyprland too, some other compositors are left to get feedback from

EDIT:- Enjoy and I Thank you all the testers, couldn't made it work on all compositor without the testers.

AdityaKr015 avatar Oct 06 '26 01:10 AdityaKr015