flameshot-org / flameshot

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

Flameshot won't copy to clipboard if started from CLI #3328

Open samrocketman opened 1 year ago

samrocketman commented 1 year ago

Flameshot Version

$ flameshot --version
Flameshot v12.1.0 ()
Compiled with Qt 5.15.3

Installation Type

Snap from Ubuntu software center

Operating System type and version

Ubuntu 22.04.3 LTS

Description

If you open flameshot gui without the flameshot daemon running (system tray icon), then copying to clipboard via CTRL+C fails. If the daemon is open, then copying to clipboard works.

This issue was created from a comment on a closed issue https://github.com/flameshot-org/flameshot/issues/635#issuecomment-1693404726

There's new information and repeatable steps.

Steps to reproduce

  1. Ensure flameshot is completely closed (no system tray icon).
  2. Start flameshot directly from the terminal via flameshot gui while there's not flameshot system tray icon.
  3. Use CTRL+C to copy to clipboard.

Note following the above steps copying to clipboard fails. If you open flameshot GUI from application menu and the system tray icon is open, then flameshot will copy to clipboard successfully.

Screenshots or screen recordings

No response

System Information

# Ubuntu 22.04.3 LTS
# Linux 6.2.0-31-generic x86_64
# GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
# Flameshot v12.1.0 ()
# snap    2.60.3

Using X11 for display instead of wayland.

m10d commented 1 year ago

I can confirm this appears to reproduce for me. using v12.1.0 via AppImage on ubuntu 22.04 using wayland (mostly default laptop). Note this means I'm forced into the "new gnome hotness" of having to "share" the screenshot with Flameshot each.and.every.time ... but that's not new.

have been using flameshot successfully on this system for some time. Running exclusively (I believe) as just flameshot gui - ie no system tray.

In the last day or three, copy to clipboard stopped working. Flameshot version | config | system-settings certainly did not change in that time. Coming here to try to figure out if my use case is covered in a bug somewhere, I find this - and lo and behold, simply starting flameshot from a new terminal before I take a screenshot, copy now works.

Other random info: the whole time, save to file did work. I don't use any custom clipboard mgr as in some of the other bugs.

carlopires commented 1 year ago

I confirmed this is happening for me using ubuntu 22.04 and flameshot v12.1.0. Flameshot is started with

$ XDG_SESSION_TYPE= QT_QPA_PLATFORM=wayland build/src/flameshot gui
qt.svg: Invalid path data; path truncated.
qt.svg: Invalid path data; path truncated.
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout

The after selecing a region and click to copy button I get nothing to paste from the clipboard.

$ XDG_SESSION_TYPE= QT_QPA_PLATFORM=wayland build/src/flameshot --version
Flameshot v12.1.0 (9557cd68)
Compiled with Qt 5.15.3
askfiy commented 1 year ago

i use arch linux, i same

CEHitchens commented 11 months ago

Similar experience for me, i.e. launching it via "flameshot gui" - not using the daemon / the system tray icon. https://github.com/flameshot-org/flameshot/issues/3328

Addendum: After having received a notification, saying: "This seems to be duplicate of https://github.com/flameshot-org/flameshot/issues/3383 and the solution to this round of Gnome's behavior is here:", I would like to point out that I linked to issue #3328 to show that it also happens with the latest Cinnamon desktop environment on Linux Mint 21.2.

kauz56 commented 11 months ago

Same issue here on debian trixie with xorg

bgoodr commented 9 months ago

Confirmed on Xubuntu 22.04.

Workaround by using flameshot & disown works, such that a subsequent execution of flameshot gui does update the clipboard, as seen by xclip -selection clipboard -t TARGETS -o.

git commit used

Built from scratch from sources today. Git HEAD commit:

commit 3d21e4967b68e9ce80fb2238857aa1bf12c7b905 (grafted, HEAD -> master, origin/master, origin/HEAD)
Author: Alex Pantechovskis <alex.pantec@gmail.com>
Date:   Sat Nov 25 22:30:54 2023 +0200

    Add "Open Save Path" in tray (#3388)

Run only with flameshot gui and CTRL+c but NOT first using flameshot & disown

(This is also first quitting the tray icon. On Xubuntu, that tray icon is in the upper right corner of the root X window, right-mouse-click, select Quit to exit it).

$ flameshot gui
qt.svg: Invalid path data; path truncated.
qt.svg: Invalid path data; path truncated.
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
$ 

Notice that is the three lines of stdout or stderr from flameshot gui

Run with flameshot & disown plus flameshot gui and CTRL+c

$ flameshot & disown
[2] 7316
$ flameshot gui
qt.svg: Invalid path data; path truncated.
qt.svg: Invalid path data; path truncated.
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
flameshot: info: Capture saved to clipboard.
$ 

Notice the flameshot: info: Capture saved to clipboard. line of output is shown.

Pasting the clipboard into a Google Doc pastes correctly.

C++ location of the output message

Grepping the code flameshot: info: Capture saved to clipboard. output line, I suspect it is coming from void saveToClipboard(const QPixmap& capture) in .../flameshot/src/utils/screenshotsaver.cpp.

I suspect this is just basic "X" behavior: Kill the app that pasted into the clipboard before a receiving X app has "read" it from the clipboard, and it gets lost. That is pure speculation, as a X11 guru will have to prove/disprove that speculation.

lsb_release output

$ lsb_release -r -i
Distributor ID: Ubuntu
Release:    22.04
$ 

xdpyinfo output

$ xdpyinfo | grep -B 99999 -m 1 'default screen number'
name of display:    :0.0
version number:    11.0
vendor string:    The X.Org Foundation
vendor release number:    12101004
X.Org version: 1.21.1.4
maximum request size:  16777212 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    7
supported pixmap formats:
    depth 1, bits_per_pixel 1, scanline_pad 32
    depth 4, bits_per_pixel 8, scanline_pad 32
    depth 8, bits_per_pixel 8, scanline_pad 32
    depth 15, bits_per_pixel 16, scanline_pad 32
    depth 16, bits_per_pixel 16, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
    depth 32, bits_per_pixel 32, scanline_pad 32
keycode range:    minimum 8, maximum 255
focus:  window 0x30000cb, revert to Parent
number of extensions:    31
    BIG-REQUESTS
    Composite
    DAMAGE
    DOUBLE-BUFFER
    DPMS
    DRI2
    DRI3
    GLX
    Generic Event Extension
    MIT-SCREEN-SAVER
    MIT-SHM
    NV-CONTROL
    NV-GLX
    Present
    RANDR
    RECORD
    RENDER
    SECURITY
    SHAPE
    SYNC
    X-Resource
    XC-MISC
    XFIXES
    XFree86-DGA
    XFree86-VidModeExtension
    XINERAMA
    XINERAMA
    XInputExtension
    XKEYBOARD
    XTEST
    XVideo
default screen number:    0
$ 
bgoodr commented 9 months ago

Here is my hackaround script (which I call ~/bin/flameshot_gui_workaround.sh) to use as a drop-in replacement for flameshot gui. All this does is run the flameshot tool as the background "tray" process, and then execute flameshot gui. Very similar to the flameshot & disown trick, but ensures a singleton process (only one) is resident:

#!/bin/bash

# See [[id:2784afec-cbd7-4c87-9347-75c89c926168][Add a hackaround wrapper for flameshot gui]]

# Launch flameshot as a singleton process:
#
#  Experimentally determined: This does not spawn more than one
#  instance of the flameshot process.
#
nohup flameshot >& /tmp/flameshot_gui_workaround.sh.log &
flameshot gui

In Xubuntu's settings (which AFAIK, is XFCE settings): Settings Manager --> Keyboard --> Application shortcuts, I set Print and Shift+Print to be associated with ~/bin/flameshot_gui_workaround.sh. Of course, don't forget to run chmod a+x ~/bin/flameshot_gui_workaround.sh.

wrvsrx commented 7 months ago

Will this bug be fixed? Currently I run a daemon to solve this issue.

santacodes commented 6 months ago

Not working on arch linux running X11(dwm). When is this issue expected to be fixed?

NandorKovacs commented 5 months ago

Same issue for me too.

WilsonNet commented 5 months ago

same here on arch with xorg flameshot & disown works here

samrocketman commented 5 months ago

https://wiki.ubuntu.com/ClipboardPersistence might be related

HEIlZMaker commented 4 months ago

yep same issue here on debian trixie

ziwindlu commented 2 months ago

if your flameshot very slow in save as file, maybe you should start the dunst, it will be cannot copy file to clipboard reason.

samrocketman commented 1 month ago

Useful comment https://github.com/flameshot-org/flameshot/issues/635#issuecomment-2302675095