flameshot-org / flameshot

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

Copying selection to clipboard is not working (neither Ctrl+C hotkey nor the button) #2982

Open isak102 opened 1 year ago

isak102 commented 1 year ago

Flameshot Version

Output of flameshot -v: Flameshot v12.1.0 (-) Compiled with Qt 5.15.5

Also tried cloning from git and manually compiling, had the same issue

Installation Type

Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...), User repository (AUR), Flatpak from Flathub, Compiled from source

Operating System type and version

Arch Linux 6.0.8-arch1-1

Description

Selecting a screenshot in flameshot gui and then pressing Ctrl+C to copy the selection to keyboard doesnt work. Pressing Ctrl+C just exits flameshot. The same thing happens when clicking the button in the interface to copy to clipboard.

I tried installing flameshot as a flatpak and there it worked properly if I ran flameshot as a daemon, but running flameshot gui had the same behaviour, copying didn't work.

Steps to reproduce

  1. run flameshot gui
  2. Make selection
  3. Copy the selection to clipboard, either by pressing Ctrl+C or by clicking the button on screen
  4. Nothing happens

Screenshots or screen recordings

No response

System Information

  1. Arch Linux, 6.0.8-arch1-1
  2. Output of xrandr:
    eDP-1 connected primary (normal left inverted right x axis y axis)
    1920x1080     60.01 +  60.01    59.97    59.96    59.93
    1680x1050     60.01    59.95    59.88
    1400x1050     59.98
    1600x900      59.99    59.94    59.95    59.82
    1280x1024     60.01    60.02
    1440x900      60.01
    1400x900      59.96    59.88
    1280x960      60.00
    1440x810      60.00    59.97
    1368x768      59.88    59.85
    1280x800      59.99    60.01    59.97    59.81    59.91
    1280x720      60.00    60.01    59.99    59.86    59.74
    1024x768      60.01    60.04    60.00
    960x720       60.00
    928x696       60.05
    896x672       60.01
    1024x576      59.95    59.96    59.90    59.82
    960x600       59.93    60.00
    960x540       59.96    59.99    59.63    59.82
    800x600       60.01    60.00    60.32    56.25
    840x525       60.01    59.88
    864x486       59.92    59.57
    700x525       59.98
    800x450       59.95    59.82
    640x512       60.02
    700x450       59.96    59.88
    640x480       60.01    60.00    59.94
    720x405       59.51    58.99
    684x384       59.88    59.85
    640x400       59.88    59.98
    640x360       59.86    59.83    59.84    59.32
    512x384       60.00
    512x288       60.00    59.92
    480x270       59.63    59.82
    400x300       60.32    56.34
    432x243       59.92    59.57
    320x240       60.05
    360x202       59.51    59.13
    320x180       59.84    59.32
    HDMI-1 connected 2496x1404+0+0 (normal left inverted right x axis y axis) 598mm x 336mm
    1920x1080     74.99*+  59.96    72.03    60.02    50.01    48.00    60.00    50.00    59.94    59.93
    1680x1050     59.95    59.88
    1400x1050     74.76    59.98
    1600x900      59.94    59.95    59.82
    1280x1024     75.02    60.02
    1440x900      59.90
    1400x900      59.96    59.88
    1280x960      60.00
    1440x810      59.97
    1368x768      59.88    59.85
    1280x800      59.99    59.97    59.81    59.91
    1152x864      75.00
    1280x720      60.00    59.99    59.86    60.00    50.00    59.94    59.74
    1024x768      75.05    60.04    75.03    70.07    60.00
    960x720       75.00    60.00
    928x696       75.00    60.05
    896x672       75.05    60.01
    1024x576      59.95    59.96    59.90    59.82
    960x600       59.93    60.00
    832x624       74.55
    960x540       59.96    59.99    59.63    59.82
    800x600       75.00    70.00    65.00    60.00    72.19    75.00    60.32    56.25
    840x525       60.01    59.88
    864x486       59.92    59.57
    720x576       50.00
    700x525       74.76    59.98
    800x450       59.95    59.82
    720x480       60.00    59.94
    640x512       75.02    60.02
    700x450       59.96    59.88
    640x480       60.00    72.81    75.00    66.67    60.00    59.94
    720x405       59.51    58.99
    720x400       70.08
    684x384       59.88    59.85
    640x400       59.88    59.98
    576x432       75.00
    640x360       59.86    59.83    59.84    59.32
    512x384       75.03    70.07    60.00
    512x288       60.00    59.92
    416x312       74.66
    480x270       59.63    59.82
    400x300       72.19    75.12    60.32    56.34
    432x243       59.92    59.57
    320x240       72.81    75.00    60.05
    360x202       59.51    59.13
    320x180       59.84    59.32
    DP-1 disconnected (normal left inverted right x axis y axis)
  3. I'm using DWM as a window manager, on Xorg
stefanocudini commented 1 year ago

same problem over ubuntu 18 and flameshot >= 12

mmahmoudian commented 1 year ago

@isak102 can it be related to this?

https://github.com/flameshot-org/flameshot/issues/2496#issuecomment-1144308628

isak102 commented 1 year ago

@isak102 can it be related to this?

#2496 (comment)

Yes it is related to that, it works properly if flameshot is ran as a daemon first. Judging by that comment this is the intended behaviour so I’ll close this issue

mmahmoudian commented 1 year ago

No it is not intended behavior. The daemon should keep running as long as it is needed (for pin or for clipboard). If it does not work it is definitely a bug

isak102 commented 1 year ago

@mmahmoudian The daemon keeps running when I start it with flameshot, it doesn’t quit after I use flameshot gui if that was what you meant. I just meant that I need to start the flameshot daemon once before I can start using flameshot gui to copy to clipboard.

mmahmoudian commented 1 year ago

The flameshot starts the daemon and if you have started the daemon by running just the flameshot, it should keep running (sitting in the tray area). If you want the daemon to get terminated, you in principal should enable the following option, and then only launch Flameshot with flameshot gui (at the moment it does not work properly all the time, so you might want to kill the process every now and then. We will look into it)

image

fnobis commented 1 year ago

I am facing the same issue, seems to be reported here as well: https://github.com/flameshot-org/flameshot/issues/3107 I am running on ubuntu 22.04

matejdro commented 1 year ago

Is there a way to enable verbose logging or something?

I've also started experiencing this on one machine. I can't find the cause for it, but it happens with both official 12.1.0 and git build v12.1.0 (3ededae5).

mauamolat commented 1 year ago

Same issue. Cannot paste image copied to clipboard

mmahmoudian commented 1 year ago

@mauamolat

Cannot paste image copied to clipboard

This issue is about not being able to add it to clipboard. In your case what you are saying is that the screenshot is in your clipboard but cannot be pasted elsewhere. That can be many thing, most of which is irrelevant to Flameshot.

@matejdro

Is there a way to enable verbose logging or something?

No, at the momebt the best user can get is what is provided in terminal

mauamolat commented 1 year ago

@mauamolat

Cannot paste image copied to clipboard

This issue is about not being able to add it to clipboard. In your case what you are saying is that the screenshot is in your clipboard but cannot be pasted elsewhere. That can be many thing, most of which is irrelevant to Flameshot.

@matejdro

Is there a way to enable verbose logging or something?

No, at the momebt the best user can get is what is provided in terminal

I found the issue. It doesn't work with .jpg as default image file but only with .png

matejdro commented 1 year ago

I found the issue in my case: It's the update checking.

I traced the code and I found that daemon freezes upon reaching that line: https://github.com/flameshot-org/flameshot/blob/3ededae5745761d23907d65bbaebb283f6f8e3f2/src/core/flameshotdaemon.cpp#L94. Thus, daemon is never initialized and can never receive screenshots to copy to the clipboard.

Disabling update checking fixes the issue for me.

v1sages commented 1 year ago

When running flameshot from terminal in i3wm or other window managers, you may receive this error after trying to copy to system clipboard: flameshot: info: Capture saved to clipboard. qt.qpa.clipboard: QXcbClipboard::setMimeData: Cannot set X11 selection owner

Version + Kernel info: Flameshot v12.1.0 (-) Compiled with Qt 5.15.5 6.2.10-arch1-1 Ensure dunst or an alternate notification manager/daemon is running if you are using i3wm on your system; recommend cloning the official dunstrc from official dunst repo. A system I was using was not copying flameshot screen captures to the system clipboard, cloned official dunstrc and managed to re-enable clipboard pasting functionality.

arakis commented 10 months ago

I run into the same problem. My advice t othe dev is, just run the messaging in a separate thread/asynchronous, so that in case, the message daemon will not respond/not available, flameshot will not hang for round about 60s.

ihaddy commented 9 months ago

I ran into a variation on this issue with flameshot v11 and v12 where it'd "save to clipboard" but i could never paste from it, i'd have to open my clipboard manager (clipman on ubuntu 22.04 with xfce4) and click it and then i could control V to paste it, i got tired of having to constantly do so many clicks just to paste a flameshot captured print screen so i wrote a python script and keybound it and it works now to give me flameshot and controlV to paste with no additional clicks or keystroke

note this assumes you also have copyQ installed as a new clipboard manager, should work alongside your current clipboard manager but you could replace it with it no problem too

import subprocess
import os
import tempfile
import time

# Function to get the first image item from CopyQ
def get_first_image_item():
    process = subprocess.run(['copyq', 'read', 'image/png', '0'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if process.stderr:
        print("Error reading image item from CopyQ:", process.stderr.decode())
    return process.stdout if process.stdout else None

# Function to save the image to a temporary file
def save_image(data):
    try:
        with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as tmpfile:
            tmpfile.write(data)
            print("Saved image to:", tmpfile.name)
            return tmpfile.name
    except Exception as e:
        print("Error saving image:", e)
        return None

# Get the first image item from CopyQ
image_data = get_first_image_item()

if image_data:
    # Save the image to a temporary file
    image_path = save_image(image_data)

    if image_path:
        # Use xclip to load the image into the clipboard
        subprocess.run(['xclip', '-selection', 'clipboard', '-t', 'image/png', '-i', image_path])

        # Wait a little for xclip to process the image
        time.sleep(1)

        # Simulate a paste operation. Make sure the focus is on the target window before this step.
        subprocess.run(['xdotool', 'key', 'ctrl+v'])

        # Clean up the temporary file
        os.unlink(image_path)
else:
    print("No image data received from CopyQ.")
port19x commented 9 months ago

The flameshot starts the daemon and if you have started the daemon by running just the flameshot, it should keep running (sitting in the tray area). If you want the daemon to get terminated, you in principal should enable the following option, and then only launch Flameshot with flameshot gui (at the moment it does not work properly all the time, so you might want to kill the process every now and then. We will look into it)

image

This (running flameshot in the background) worked for me while other workarounds such as toggling jpg on and off did not. Thx