flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:
https://flameshot.org
GNU General Public License v3.0
23.92k stars 1.52k forks source link

[Discussion] Flameshot as an Annotation Tool #273

Open HannanAkbar opened 5 years ago

HannanAkbar commented 5 years ago

Ardesia, Open Sankore, Compiz Annotate, Shutter, Gromit-mpx, Pylote... I tried all of these screen annotation tools, but they depend on X and old composite managers and don't support Wayland.

Flameshot is arguably the most powerful and modern tool for screenshot and screen annotation. It's not built for screen annotation, but it's a lot more usable.

It would be great to fork Flameshot and turn it into an annotation tool, FlameDraw, FlameAnnotate or something else. We can start by taking off some functionality and heavy lifting.

I am not a C++ developer and I don't know my way around the codebase, but I would love to contribute however I could. Are you guys willing to take part in the project?

tmccombs commented 4 years ago

I'm interested in this, because I'd like to be able to take a screenshot in sway with slurp/grim and thin annotate it using something like flameshot.

nachovizzo commented 4 years ago

So, I agree with you, flameshot is the best tool available. I was used to the "Annotate" tool in compiz, but since I've switched to i3wm this is not possible anymore.

After HOURS of research, and trying multiple tools with no success(like gromit) I decided to make flameshot work for my case.

Since the design of the app itself is extremely good, you can actually write your own scripts in bash to force the tool to work for you.

This is how I did it

  1. Install xdotool (e.g sudo apt install xdotool)
  2. Copy this script
    
    #!/usr/bin/env bash
    # @file      full_screen.sh
    # @author    Ignacio Vizzo     [ivizzo@uni-bonn.de]
    #
    # Copyright (c) 2019 Ignacio Vizzo, all rights reserved
    WIDTH=$(xrandr --query | awk -F '[ x,+]' '/\<connected\>/{print $4}')
    HEIGHT=$(xrandr --query | awk -F '[ x,+]' '/\<connected\>/{print $5}')

Launch the snapshot gui

flameshot gui && sleep 0.05

Save the current mouse location

eval $(xdotool getmouselocation --shell)

Move the mouse to the top left corner and drag it to to the right bottom corner

xdotool mousemove 0 0 xdotool mousedown 1 # pres and hold xdotool mousemove ${WIDTH} ${HEIGHT} xdotool mouseup 1 # release click

Restore mouse to previous location

xdotool mousemove ${X} ${Y}


3. Attach that script to a keybiding(this is up to you, and depends on your DE). In my case, i3wm, I just had to add this line ` bindsym $mod+a exec "$HOME/scripts/flameshot/full_screen.sh"`

This basically turns flameshot into an annotation tool, just don't save the screenshot, press `Esc` whenever you finish annotating. Enjoy!

PS: You can do some scripting as well, for example, change the configuration on the fly before launching the tool.
RaulDurand commented 3 years ago

After HOURS of research, and trying multiple tools with no success(like gromit) I decided to make flameshot work for my case.

That is great!

I am wondering if this functionality can be implemented natively in flameshot.

zeorin commented 3 years ago

@nachovizzo that's a cool script! I expanded on it to also support pre-selecting the active window or letting the user manually select a window:

Usage:

./scriptname.sh (full screen)
./scriptname.sh activewindow (currently active window)
./scriptname.sh selectwindow (manually select a window)
#!/bin/sh

if [ "$1" = "activewindow" ]; then
    # Get active window geometry
    eval $(xdotool getactivewindow getwindowgeometry --shell)
elif [ "$1" = "selectwindow" ]; then
    # Let the user select a window and get its geometry
    eval $(xdotool selectwindow getwindowgeometry --shell)
else
    # Get screen geometry
    WIDTH=$(xrandr --query | awk -F '[ x,+]' '/\<connected\>/{print $3}')
    HEIGHT=$(xrandr --query | awk -F '[ x,+]' '/\<connected\>/{print $4}')
    X=0
    Y=0
fi

# Get mouse position
eval $(echo $(xdotool getmouselocation --shell) | sed "s/\(X\|Y\)/MOUSE\1/g")

# Launch the screenshot gui
flameshot gui && sleep 0.05

# Move the mouse to the top left corner and drag it to to the right bottom corner
xdotool mousemove $X $Y
xdotool mousedown 1 # press and hold
xdotool mousemove_relative $WIDTH $HEIGHT
xdotool mouseup 1 # release

# Restore mouse to previous location
xdotool mousemove $MOUSEX $MOUSEY
nachovizzo commented 3 years ago

Awesome @zeorin !

mmahmoudian commented 2 years ago

The solution @zeorin provided didn't fully work for me as in KDE the mousedown 1 was not staring a dragging behavior, so after spending some time I realized that moving one pixel and then moving to the final position actually works:

xdotool mousemove $X $Y
xdotool mousedown 1 # press and hold
xdotool mousemove_relative 1 1
xdotool mousemove_relative $WIDTH $HEIGHT
xdotool mouseup 1 # release

Inspired by his code, I added a Select_window functionality to my dmenu_shot program. The lines that helped me were mousedown and mouseup, so thank you @zeorin.

veracioux commented 2 years ago

I have proposed a solution in this discussion: #1974. Please leave your votes/suggestions there.

velocity-ed commented 2 years ago

+1 for this. Please add native hide gui support for flameshot. This would be great to work out of the box without having to apply this hack. Please add an option in preferences or a start up parameter in the CLI. The benefits are huge for live screencasts so the presenter can annotate WITHOUT a distracting GUI.

zeorin commented 2 years ago

I have an updated script:

#!/bin/sh

if [ "$1" = "activewindow" ]; then
    # Get active window geometry
    eval $(xdotool getactivewindow getwindowgeometry --shell)
    REGION="${WIDTH}x${HEIGHT}+${X}+${Y}"
elif [ "$1" = "selectwindow" ]; then
    # Let the user select a window and get its geometry
    eval $(xdotool selectwindow getwindowgeometry --shell)
    REGION="${WIDTH}x${HEIGHT}+${X}+${Y}"
else
    # Get current screen
    SCREEN=$(xdotool get_desktop)
    REGION="screen${SCREEN}"
fi

# Launch the screenshot gui
flameshot gui --region "$REGION"
Massimo-B commented 3 months ago

I have an updated script:

Awesome, thanks for that. But I still think this should be also implemented natively in Flameshot.

HuangJiaLian commented 3 months ago

I have an updated script:

#!/bin/sh

if [ "$1" = "activewindow" ]; then
  # Get active window geometry
  eval $(xdotool getactivewindow getwindowgeometry --shell)
  REGION="${WIDTH}x${HEIGHT}+${X}+${Y}"
elif [ "$1" = "selectwindow" ]; then
  # Let the user select a window and get its geometry
  eval $(xdotool selectwindow getwindowgeometry --shell)
  REGION="${WIDTH}x${HEIGHT}+${X}+${Y}"
else
  # Get current screen
  SCREEN=$(xdotool get_desktop)
  REGION="screen${SCREEN}"
fi

# Launch the screenshot gui
flameshot gui --region "$REGION"

I don't know why flameshot gui --region "$REGION" gives me Segmentation fault (core dumped) on Linux Mint.

Here is my solution to add two custom global keyboard shortcuts. Both shortcuts save image to Pictures folder, and copy to clipboard as well. Full path should be used here.

For selection and whole screen screenshot I used this shortcut.

bash -c 'flameshot gui -c -p "/home/USERNAME/Pictures/Selection-$(date +%Y-%m-%d_%H-%M-%S).png"' > /dev/null 2>&1

image

For window screenshot, I use the default application.

bash -c 'gnome-screenshot -w -c -f "/home/USERNAME/Pictures/Window-$(date +%Y-%m-%d_%H-%M-%S).png"'

image