3

We use ksnip as a company-standard cross platform screenshot annotation tool. When switching to Wayland, I can take only screenshots via the portal, which is not very efficient.

Is it possible to launch ksnip automatically after taking a screenshot with the gnome / wayland screenshot tool which is default in Ubuntu 22.04 ? (how is that tool called?)

Currently, as a workaround, I can take a screenshot, copy to clipboard, open ksnip, annoate, export which is very cumbersome.

Alex
  • 1,062

2 Answers2

3

I think I will bind an additional shortcut for opening ksnip with the clipboard contents to the following script:

#!/bin/bash
xclip -selection clipboard -t image/png -o | ksnip -e -

dbus-send --session
--dest=org.freedesktop.portal.Desktop
--type=method_call
/org/freedesktop/portal/desktop
org.freedesktop.portal.Desktop.Activate
"string:org.ksnip.ksnip.desktop"
"uint32:0"

Save this to (for example) /usr/local/bin/ksnip-from-clipboard and make it executable (chmod +x)

Thus I can take a screenshot using the standard tool, copy to clipboard (Ctrl+C) and press my new short cut (Is used Ctrl+Shift+Alt+K)

At Settings > Keyboard > Keyboard Shortcuts > View and Customize Shortcuts

Add custom short cut

An improvement would be to also simulate pressing Ctrl+C in that shortcut.

But xdotool key 'ctrl+c' did not work for me.

Alex
  • 1,062
1

One way is to set new shortcut for:

ksnip -t

Which captures a screenshot and opens/shows it directly in ksnip portal. Press share button as your usual workflow.

Btw, there are other ways ksnip can be combined in series with other tools as long it can open and save files from command line. Check ksnip -h.

2nd option create a script that watches screenshots folder and launches ksnip to edit new files. Similar to this one: Autostart program whenever a file is added to a folder

user.dz
  • 49,295
  • 2
    ksnip -t is better than nothing, but it captures a full screen screenshot which needs to be cropped later. The wayland tool is already nice, the question is if there can be some postprocessing added. I am also wondering what is the command for the wayland tool, because that does not show up in the short cut list. it's just the "screenshot action" – Alex Dec 11 '22 at 11:37
  • 1
    @Alex It doesn't look to be separate tool from gnome-shell. The only approach I could think of right now, is a gnome-shell extension (java-script based) that target and customize that screenshot component. Extend it to open or share captured image with another user set tool. – user.dz Dec 15 '22 at 14:34
  • 1
    I found an okayisch workaround in my answer https://askubuntu.com/a/1445519/39966 – Alex Dec 15 '22 at 16:40