bugaevc / wl-clipboard

Command-line copy/paste utilities for Wayland
GNU General Public License v3.0
1.62k stars 60 forks source link

Attempting to use wl-clipboard in an app launched from a KDE keyboard shortcut breaks clipboard copying #153

Closed Beyley closed 1 year ago

Beyley commented 1 year ago

If i attempt to copy to the clipboard from an app launched from a terminal, it works fine, but if i do it from an app launched from a KDE keyboard shortcut, then nothing seems to happen, googling has not provided much help here

its a very simple C# script im using https://gist.github.com/Beyley/b807d522019e2e681204c2ffeb5be616

bugaevc commented 1 year ago

Well, does it output anything? Any error messages? Can you get me WAYLAND_DEBUG logs?

Beyley commented 1 year ago

Well, does it output anything? Any error messages? Can you get me WAYLAND_DEBUG logs?

I was able to redirect the standard error to a file, and with WAYLAND_DEBUG=1, i got this

[4099618.237]  -> wl_display@1.get_registry(new id wl_registry@2)
[4099618.245]  -> wl_display@1.sync(new id wl_callback@3)
[4099623.372] wl_display@1.delete_id(3)
[4099623.379] wl_registry@2.global(1, "wl_compositor", 5)
[4099623.381]  -> wl_registry@2.bind(1, "wl_compositor", 2, new id [unknown]@4)
[4099623.385] wl_registry@2.global(2, "zwp_tablet_manager_v2", 1)
[4099623.386] wl_registry@2.global(3, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[4099623.387] wl_registry@2.global(5, "xdg_wm_base", 4)
[4099623.389]  -> wl_registry@2.bind(5, "xdg_wm_base", 1, new id [unknown]@5)
[4099623.390] wl_registry@2.global(6, "zwlr_layer_shell_v1", 3)
[4099623.391] wl_registry@2.global(7, "zxdg_decoration_manager_v1", 1)
[4099623.392] wl_registry@2.global(8, "wp_viewporter", 1)
[4099623.393] wl_registry@2.global(9, "wl_shm", 1)
[4099623.395]  -> wl_registry@2.bind(9, "wl_shm", 1, new id [unknown]@6)
[4099623.396] wl_registry@2.global(10, "wl_seat", 7)
[4099623.398]  -> wl_registry@2.bind(10, "wl_seat", 2, new id [unknown]@7)
[4099623.399] wl_registry@2.global(11, "zwp_pointer_gestures_v1", 3)
[4099623.400] wl_registry@2.global(12, "zwp_pointer_constraints_v1", 1)
[4099623.401] wl_registry@2.global(13, "zwp_relative_pointer_manager_v1", 1)
[4099623.402] wl_registry@2.global(14, "wl_data_device_manager", 3)
[4099623.403]  -> wl_registry@2.bind(14, "wl_data_device_manager", 1, new id [unknown]@8)
[4099623.404] wl_registry@2.global(15, "zwlr_data_control_manager_v1", 2)
[4099623.406]  -> wl_registry@2.bind(15, "zwlr_data_control_manager_v1", 2, new id [unknown]@9)
[4099623.407] wl_registry@2.global(16, "zwp_primary_selection_device_manager_v1", 1)
[4099623.408]  -> wl_registry@2.bind(16, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@10)
[4099623.409] wl_registry@2.global(17, "org_kde_kwin_idle", 1)
[4099623.410] wl_registry@2.global(18, "zwp_idle_inhibit_manager_v1", 1)
[4099623.411] wl_registry@2.global(19, "org_kde_plasma_shell", 8)
[4099623.412] wl_registry@2.global(20, "org_kde_kwin_appmenu_manager", 1)
[4099623.413] wl_registry@2.global(21, "org_kde_kwin_server_decoration_palette_manager", 1)
[4099623.414] wl_registry@2.global(23, "org_kde_plasma_virtual_desktop_management", 2)
[4099623.415] wl_registry@2.global(25, "org_kde_kwin_shadow_manager", 2)
[4099623.416] wl_registry@2.global(26, "org_kde_kwin_dpms_manager", 1)
[4099623.417] wl_registry@2.global(27, "org_kde_kwin_server_decoration_manager", 1)
[4099623.418] wl_registry@2.global(28, "kde_output_management_v2", 2)
[4099623.419] wl_registry@2.global(29, "kde_primary_output_v1", 2)
[4099623.420] wl_registry@2.global(30, "zxdg_output_manager_v1", 3)
[4099623.421] wl_registry@2.global(31, "wl_subcompositor", 1)
[4099623.422] wl_registry@2.global(32, "zxdg_exporter_v2", 1)
[4099623.423] wl_registry@2.global(33, "zxdg_importer_v2", 1)
[4099623.424] wl_registry@2.global(35, "xdg_activation_v1", 1)
[4099623.425] wl_registry@2.global(37, "wp_drm_lease_device_v1", 1)
[4099623.426] wl_registry@2.global(40, "wl_drm", 2)
[4099623.427] wl_registry@2.global(41, "zwp_linux_dmabuf_v1", 4)
[4099623.428] wl_registry@2.global(43, "kde_output_device_v2", 2)
[4099623.429] wl_registry@2.global(44, "kde_output_device_v2", 2)
[4099623.430] wl_registry@2.global(45, "wl_output", 4)
[4099623.431] wl_registry@2.global(46, "wl_output", 4)
[4099623.432] wl_registry@2.global(47, "zwp_text_input_manager_v2", 1)
[4099623.433] wl_registry@2.global(48, "zwp_text_input_manager_v3", 1)
[4099623.434] wl_registry@2.global(50, "org_kde_kwin_contrast_manager", 2)
[4099623.435] wl_registry@2.global(51, "org_kde_kwin_blur_manager", 1)
[4099623.436] wl_registry@2.global(52, "org_kde_kwin_slide_manager", 1)
[4099623.437] wl_callback@3.done(2036)
[4099623.439]  -> wl_display@1.sync(new id wl_callback@3)
[4099623.493] wl_display@1.delete_id(3)
[4099623.494] wl_seat@7.capabilities(7)
[4099623.495] wl_seat@7.name("")
[4099623.496] wl_callback@3.done(2036)
[4099623.498]  -> zwlr_data_control_manager_v1@9.get_data_device(new id zwlr_data_control_device_v1@3, wl_seat@7)
[4099623.500]  -> wl_display@1.sync(new id wl_callback@11)
[4099623.631] wl_display@1.delete_id(11)
[4099623.632] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190080)
[4099623.633] zwlr_data_control_offer_v1@4278190080.offer("text/html")
[4099623.634] zwlr_data_control_offer_v1@4278190080.offer("text/_moz_htmlcontext")
[4099623.635] zwlr_data_control_offer_v1@4278190080.offer("text/_moz_htmlinfo")
[4099623.636] zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8")
[4099623.637] zwlr_data_control_offer_v1@4278190080.offer("UTF8_STRING")
[4099623.638] zwlr_data_control_offer_v1@4278190080.offer("COMPOUND_TEXT")
[4099623.639] zwlr_data_control_offer_v1@4278190080.offer("TEXT")
[4099623.640] zwlr_data_control_offer_v1@4278190080.offer("text/plain")
[4099623.641] zwlr_data_control_offer_v1@4278190080.offer("STRING")
[4099623.641] zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8")
[4099623.642] zwlr_data_control_offer_v1@4278190080.offer("text/plain")
[4099623.643] zwlr_data_control_offer_v1@4278190080.offer("text/x-moz-url-priv")
[4099623.644] zwlr_data_control_offer_v1@4278190080.offer("SAVE_TARGETS")
[4099623.645] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190080)
[4099623.646] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190081)
[4099623.647] zwlr_data_control_offer_v1@4278190081.offer("text/html")
[4099623.648] zwlr_data_control_offer_v1@4278190081.offer("text/_moz_htmlcontext")
[4099623.649] zwlr_data_control_offer_v1@4278190081.offer("text/_moz_htmlinfo")
[4099623.650] zwlr_data_control_offer_v1@4278190081.offer("text/plain;charset=utf-8")
[4099623.651] zwlr_data_control_offer_v1@4278190081.offer("UTF8_STRING")
[4099623.652] zwlr_data_control_offer_v1@4278190081.offer("COMPOUND_TEXT")
[4099623.653] zwlr_data_control_offer_v1@4278190081.offer("TEXT")
[4099623.653] zwlr_data_control_offer_v1@4278190081.offer("text/plain")
[4099623.654] zwlr_data_control_offer_v1@4278190081.offer("STRING")
[4099623.655] zwlr_data_control_offer_v1@4278190081.offer("text/plain;charset=utf-8")
[4099623.656] zwlr_data_control_offer_v1@4278190081.offer("text/plain")
[4099623.657] zwlr_data_control_offer_v1@4278190081.offer("text/x-moz-url-priv")
[4099623.658] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190081)
[4099623.659] wl_callback@11.done(2036)
[4099623.660]  -> zwlr_data_control_manager_v1@9.create_data_source(new id zwlr_data_control_source_v1@11)
[4099623.661]  -> zwlr_data_control_source_v1@11.offer("text/plain")
[4099623.663]  -> zwlr_data_control_source_v1@11.offer("text/plain;charset=utf-8")
[4099623.664]  -> zwlr_data_control_source_v1@11.offer("TEXT")
[4099623.665]  -> zwlr_data_control_source_v1@11.offer("STRING")
[4099623.665]  -> zwlr_data_control_source_v1@11.offer("UTF8_STRING")
[4099623.666]  -> zwlr_data_control_device_v1@3.set_primary_selection(zwlr_data_control_source_v1@11)
[4099623.668]  -> wl_display@1.sync(new id wl_callback@12)
[4099623.723] wl_display@1.delete_id(12)
[4099623.725] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190082)
[4099623.727] zwlr_data_control_offer_v1@4278190082.offer("text/plain")
[4099623.728] zwlr_data_control_offer_v1@4278190082.offer("text/plain;charset=utf-8")
[4099623.729] zwlr_data_control_offer_v1@4278190082.offer("TEXT")
[4099623.730] zwlr_data_control_offer_v1@4278190082.offer("STRING")
[4099623.732] zwlr_data_control_offer_v1@4278190082.offer("UTF8_STRING")
[4099623.733] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190082)
[4099623.735] wl_callback@12.done(2036)
[4152321.209] zwlr_data_control_source_v1@11.cancelled()
bugaevc commented 1 year ago

[4152321.209] zwlr_data_control_source_v1@11.cancelled()

See, the data source is getting cancelled immediately, without anyone even requesting the data from the source — but not before the compositor accepts the source (and publishes it back as a data offer). So this is not the case of the compositor rejecting the data source (or the set_primary_selection() method call) for some reason.

Does this still happen if you disable your clipboard manager (Klipper)?

Beyley commented 1 year ago

Disabling klipper (i think i was able to? its not clear how to do so, but i set it to disabled) did not seem to help, it still isnt working

Ruakij commented 1 year ago

I encountered the same issue when running a script using a shortcut.

Whilst playing around, trying to get Debug-output, i got it working.. When piping stdout to anything (i tested /dev/null and files), it works..

Here the stderr-outputs of both versions with debug enabled:

WAYLAND_DEBUG=1 wl-copy "foobar" 2>/tmp/error` ```sh [2512924.787] -> wl_display@1.get_registry(new id wl_registry@2) [2512924.799] -> wl_display@1.sync(new id wl_callback@3) [2512927.777] wl_display@1.delete_id(3) [2512927.785] wl_registry@2.global(1, "wl_compositor", 5) [2512927.790] -> wl_registry@2.bind(1, "wl_compositor", 2, new id [unknown]@4) [2512927.794] wl_registry@2.global(3, "zwp_tablet_manager_v2", 1) [2512927.798] wl_registry@2.global(4, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1) [2512927.800] wl_registry@2.global(6, "xdg_wm_base", 4) [2512927.803] -> wl_registry@2.bind(6, "xdg_wm_base", 1, new id [unknown]@5) [2512927.807] wl_registry@2.global(7, "zwlr_layer_shell_v1", 3) [2512927.810] wl_registry@2.global(8, "zxdg_decoration_manager_v1", 1) [2512927.813] wl_registry@2.global(9, "wp_viewporter", 1) [2512927.816] wl_registry@2.global(10, "wp_fractional_scale_manager_v1", 1) [2512927.819] wl_registry@2.global(11, "wl_shm", 1) [2512927.822] -> wl_registry@2.bind(11, "wl_shm", 1, new id [unknown]@6) [2512927.825] wl_registry@2.global(12, "wl_seat", 8) [2512927.828] -> wl_registry@2.bind(12, "wl_seat", 2, new id [unknown]@7) [2512927.832] wl_registry@2.global(13, "zwp_pointer_gestures_v1", 3) [2512927.834] wl_registry@2.global(14, "zwp_pointer_constraints_v1", 1) [2512927.838] wl_registry@2.global(15, "zwp_relative_pointer_manager_v1", 1) [2512927.841] wl_registry@2.global(16, "wl_data_device_manager", 3) [2512927.845] -> wl_registry@2.bind(16, "wl_data_device_manager", 1, new id [unknown]@8) [2512927.848] wl_registry@2.global(17, "zwlr_data_control_manager_v1", 2) [2512927.852] -> wl_registry@2.bind(17, "zwlr_data_control_manager_v1", 2, new id [unknown]@9) [2512927.855] wl_registry@2.global(18, "zwp_primary_selection_device_manager_v1", 1) [2512927.858] -> wl_registry@2.bind(18, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@10) [2512927.861] wl_registry@2.global(19, "org_kde_kwin_idle", 1) [2512927.865] wl_registry@2.global(20, "zwp_idle_inhibit_manager_v1", 1) [2512927.868] wl_registry@2.global(21, "ext_idle_notifier_v1", 1) [2512927.870] wl_registry@2.global(22, "org_kde_plasma_shell", 8) [2512927.874] wl_registry@2.global(23, "org_kde_kwin_appmenu_manager", 1) [2512927.877] wl_registry@2.global(24, "org_kde_kwin_server_decoration_palette_manager", 1) [2512927.880] wl_registry@2.global(26, "org_kde_plasma_virtual_desktop_management", 2) [2512927.883] wl_registry@2.global(28, "org_kde_kwin_shadow_manager", 2) [2512927.886] wl_registry@2.global(29, "org_kde_kwin_dpms_manager", 1) [2512927.888] wl_registry@2.global(30, "org_kde_kwin_server_decoration_manager", 1) [2512927.892] wl_registry@2.global(31, "kde_output_management_v2", 3) [2512927.895] wl_registry@2.global(32, "zxdg_output_manager_v1", 3) [2512927.899] wl_registry@2.global(33, "wl_subcompositor", 1) [2512927.901] wl_registry@2.global(34, "zxdg_exporter_v2", 1) [2512927.904] wl_registry@2.global(35, "zxdg_importer_v2", 1) [2512927.907] wl_registry@2.global(38, "xdg_activation_v1", 1) [2512927.910] wl_registry@2.global(40, "wp_content_type_manager_v1", 1) [2512927.913] wl_registry@2.global(41, "wp_tearing_control_manager_v1", 1) [2512927.915] wl_registry@2.global(43, "wl_drm", 2) [2512927.918] wl_registry@2.global(44, "zwp_linux_dmabuf_v1", 4) [2512927.921] wl_registry@2.global(46, "kde_output_device_v2", 2) [2512927.924] wl_registry@2.global(47, "kde_output_device_v2", 2) [2512927.927] wl_registry@2.global(48, "wl_output", 4) [2512927.929] wl_registry@2.global(49, "wl_output", 4) [2512927.932] wl_registry@2.global(50, "wp_drm_lease_device_v1", 1) [2512927.935] wl_registry@2.global(51, "kde_output_order_v1", 1) [2512927.938] wl_registry@2.global(52, "zwp_text_input_manager_v1", 1) [2512927.940] wl_registry@2.global(53, "zwp_text_input_manager_v2", 1) [2512927.943] wl_registry@2.global(54, "zwp_text_input_manager_v3", 1) [2512927.946] wl_registry@2.global(56, "org_kde_kwin_contrast_manager", 2) [2512927.949] wl_registry@2.global(57, "org_kde_kwin_blur_manager", 1) [2512927.952] wl_registry@2.global(58, "org_kde_kwin_slide_manager", 1) [2512927.955] wl_callback@3.done(64431) [2512927.959] -> wl_display@1.sync(new id wl_callback@3) [2512928.178] wl_display@1.delete_id(3) [2512928.183] wl_seat@7.capabilities(7) [2512928.186] wl_seat@7.name("") [2512928.189] wl_callback@3.done(64431) [2512928.193] -> zwlr_data_control_manager_v1@9.get_data_device(new id zwlr_data_control_device_v1@3, wl_seat@7) [2512928.197] -> zwlr_data_control_manager_v1@9.create_data_source(new id zwlr_data_control_source_v1@11) [2512928.200] -> zwlr_data_control_source_v1@11.offer("text/plain") [2512928.204] -> zwlr_data_control_source_v1@11.offer("text/plain;charset=utf-8") [2512928.207] -> zwlr_data_control_source_v1@11.offer("TEXT") [2512928.210] -> zwlr_data_control_source_v1@11.offer("STRING") [2512928.213] -> zwlr_data_control_source_v1@11.offer("UTF8_STRING") [2512928.216] -> zwlr_data_control_device_v1@3.set_selection(zwlr_data_control_source_v1@11) [2512928.219] -> wl_display@1.sync(new id wl_callback@12) [2512928.311] wl_display@1.delete_id(12) [2512928.325] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190080) [2512928.331] zwlr_data_control_offer_v1@4278190080.offer("TIMESTAMP") [2512928.336] zwlr_data_control_offer_v1@4278190080.offer("TARGETS") [2512928.341] zwlr_data_control_offer_v1@4278190080.offer("SAVE_TARGETS") [2512928.346] zwlr_data_control_offer_v1@4278190080.offer("MULTIPLE") [2512928.350] zwlr_data_control_offer_v1@4278190080.offer("STRING") [2512928.352] zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8") [2512928.355] zwlr_data_control_offer_v1@4278190080.offer("text/plain") [2512928.358] zwlr_data_control_offer_v1@4278190080.offer("chromium/x-web-custom-data") [2512928.366] zwlr_data_control_offer_v1@4278190080.offer("text/html") [2512928.371] zwlr_data_control_offer_v1@4278190080.offer("text/plain") [2512928.376] zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8") [2512928.384] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190080) [2512928.391] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190081) [2512928.396] zwlr_data_control_offer_v1@4278190081.offer("TIMESTAMP") [2512928.401] zwlr_data_control_offer_v1@4278190081.offer("TARGETS") [2512928.406] zwlr_data_control_offer_v1@4278190081.offer("SAVE_TARGETS") [2512928.411] zwlr_data_control_offer_v1@4278190081.offer("MULTIPLE") [2512928.416] zwlr_data_control_offer_v1@4278190081.offer("STRING") [2512928.421] zwlr_data_control_offer_v1@4278190081.offer("text/plain;charset=utf-8") [2512928.429] zwlr_data_control_offer_v1@4278190081.offer("text/plain") [2512928.435] zwlr_data_control_offer_v1@4278190081.offer("text/plain") [2512928.441] zwlr_data_control_offer_v1@4278190081.offer("text/plain;charset=utf-8") [2512928.447] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190081) [2512928.452] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190082) [2512928.457] zwlr_data_control_offer_v1@4278190082.offer("text/plain") [2512928.463] zwlr_data_control_offer_v1@4278190082.offer("text/plain;charset=utf-8") [2512928.469] zwlr_data_control_offer_v1@4278190082.offer("TEXT") [2512928.474] zwlr_data_control_offer_v1@4278190082.offer("STRING") [2512928.480] zwlr_data_control_offer_v1@4278190082.offer("UTF8_STRING") [2512928.485] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190082) [2512928.490] wl_callback@12.done(64431) wl_display_dispatch: Socket operation on non-socket ```
WAYLAND_DEBUG=1 wl-copy "foobar" >/dev/null 2>/tmp/error` ```sh [2146425.439] -> wl_display@1.get_registry(new id wl_registry@2) [2146425.451] -> wl_display@1.sync(new id wl_callback@3) [2146428.369] wl_display@1.delete_id(3) [2146428.375] wl_registry@2.global(1, "wl_compositor", 5) [2146428.378] -> wl_registry@2.bind(1, "wl_compositor", 2, new id [unknown]@4) [2146428.381] wl_registry@2.global(3, "zwp_tablet_manager_v2", 1) [2146428.383] wl_registry@2.global(4, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1) [2146428.385] wl_registry@2.global(6, "xdg_wm_base", 4) [2146428.387] -> wl_registry@2.bind(6, "xdg_wm_base", 1, new id [unknown]@5) [2146428.388] wl_registry@2.global(7, "zwlr_layer_shell_v1", 3) [2146428.390] wl_registry@2.global(8, "zxdg_decoration_manager_v1", 1) [2146428.392] wl_registry@2.global(9, "wp_viewporter", 1) [2146428.394] wl_registry@2.global(10, "wp_fractional_scale_manager_v1", 1) [2146428.395] wl_registry@2.global(11, "wl_shm", 1) [2146428.397] -> wl_registry@2.bind(11, "wl_shm", 1, new id [unknown]@6) [2146428.399] wl_registry@2.global(12, "wl_seat", 8) [2146428.401] -> wl_registry@2.bind(12, "wl_seat", 2, new id [unknown]@7) [2146428.403] wl_registry@2.global(13, "zwp_pointer_gestures_v1", 3) [2146428.404] wl_registry@2.global(14, "zwp_pointer_constraints_v1", 1) [2146428.406] wl_registry@2.global(15, "zwp_relative_pointer_manager_v1", 1) [2146428.407] wl_registry@2.global(16, "wl_data_device_manager", 3) [2146428.409] -> wl_registry@2.bind(16, "wl_data_device_manager", 1, new id [unknown]@8) [2146428.411] wl_registry@2.global(17, "zwlr_data_control_manager_v1", 2) [2146428.413] -> wl_registry@2.bind(17, "zwlr_data_control_manager_v1", 2, new id [unknown]@9) [2146428.415] wl_registry@2.global(18, "zwp_primary_selection_device_manager_v1", 1) [2146428.417] -> wl_registry@2.bind(18, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@10) [2146428.419] wl_registry@2.global(19, "org_kde_kwin_idle", 1) [2146428.421] wl_registry@2.global(20, "zwp_idle_inhibit_manager_v1", 1) [2146428.423] wl_registry@2.global(21, "ext_idle_notifier_v1", 1) [2146428.424] wl_registry@2.global(22, "org_kde_plasma_shell", 8) [2146428.426] wl_registry@2.global(23, "org_kde_kwin_appmenu_manager", 1) [2146428.428] wl_registry@2.global(24, "org_kde_kwin_server_decoration_palette_manager", 1) [2146428.429] wl_registry@2.global(26, "org_kde_plasma_virtual_desktop_management", 2) [2146428.431] wl_registry@2.global(28, "org_kde_kwin_shadow_manager", 2) [2146428.433] wl_registry@2.global(29, "org_kde_kwin_dpms_manager", 1) [2146428.435] wl_registry@2.global(30, "org_kde_kwin_server_decoration_manager", 1) [2146428.436] wl_registry@2.global(31, "kde_output_management_v2", 3) [2146428.438] wl_registry@2.global(32, "zxdg_output_manager_v1", 3) [2146428.440] wl_registry@2.global(33, "wl_subcompositor", 1) [2146428.441] wl_registry@2.global(34, "zxdg_exporter_v2", 1) [2146428.443] wl_registry@2.global(35, "zxdg_importer_v2", 1) [2146428.444] wl_registry@2.global(38, "xdg_activation_v1", 1) [2146428.446] wl_registry@2.global(40, "wp_content_type_manager_v1", 1) [2146428.448] wl_registry@2.global(41, "wp_tearing_control_manager_v1", 1) [2146428.449] wl_registry@2.global(43, "wl_drm", 2) [2146428.451] wl_registry@2.global(44, "zwp_linux_dmabuf_v1", 4) [2146428.453] wl_registry@2.global(46, "kde_output_device_v2", 2) [2146428.454] wl_registry@2.global(47, "kde_output_device_v2", 2) [2146428.456] wl_registry@2.global(48, "wl_output", 4) [2146428.458] wl_registry@2.global(49, "wl_output", 4) [2146428.459] wl_registry@2.global(50, "wp_drm_lease_device_v1", 1) [2146428.461] wl_registry@2.global(51, "kde_output_order_v1", 1) [2146428.463] wl_registry@2.global(52, "zwp_text_input_manager_v1", 1) [2146428.464] wl_registry@2.global(53, "zwp_text_input_manager_v2", 1) [2146428.466] wl_registry@2.global(54, "zwp_text_input_manager_v3", 1) [2146428.467] wl_registry@2.global(56, "org_kde_kwin_contrast_manager", 2) [2146428.469] wl_registry@2.global(57, "org_kde_kwin_blur_manager", 1) [2146428.471] wl_registry@2.global(58, "org_kde_kwin_slide_manager", 1) [2146428.473] wl_callback@3.done(62967) [2146428.475] -> wl_display@1.sync(new id wl_callback@3) [2146428.514] wl_display@1.delete_id(3) [2146428.517] wl_seat@7.capabilities(7) [2146428.519] wl_seat@7.name("") [2146428.521] wl_callback@3.done(62967) [2146428.523] -> zwlr_data_control_manager_v1@9.get_data_device(new id zwlr_data_control_device_v1@3, wl_seat@7) [2146428.526] -> zwlr_data_control_manager_v1@9.create_data_source(new id zwlr_data_control_source_v1@11) [2146428.528] -> zwlr_data_control_source_v1@11.offer("text/plain") [2146428.530] -> zwlr_data_control_source_v1@11.offer("text/plain;charset=utf-8") [2146428.532] -> zwlr_data_control_source_v1@11.offer("TEXT") [2146428.533] -> zwlr_data_control_source_v1@11.offer("STRING") [2146428.535] -> zwlr_data_control_source_v1@11.offer("UTF8_STRING") [2146428.536] -> zwlr_data_control_device_v1@3.set_selection(zwlr_data_control_source_v1@11) [2146428.538] -> wl_display@1.sync(new id wl_callback@12) [2146428.623] wl_display@1.delete_id(12) [2146428.632] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190080) [2146428.637] zwlr_data_control_offer_v1@4278190080.offer("TIMESTAMP") [2146428.640] zwlr_data_control_offer_v1@4278190080.offer("TARGETS") [2146428.644] zwlr_data_control_offer_v1@4278190080.offer("SAVE_TARGETS") [2146428.647] zwlr_data_control_offer_v1@4278190080.offer("MULTIPLE") [2146428.650] zwlr_data_control_offer_v1@4278190080.offer("STRING") [2146428.652] zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8") [2146428.654] zwlr_data_control_offer_v1@4278190080.offer("text/plain") [2146428.657] zwlr_data_control_offer_v1@4278190080.offer("chromium/x-web-custom-data") [2146428.660] zwlr_data_control_offer_v1@4278190080.offer("text/html") [2146428.662] zwlr_data_control_offer_v1@4278190080.offer("text/plain") [2146428.665] zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8") [2146428.667] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190080) [2146428.670] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190081) [2146428.673] zwlr_data_control_offer_v1@4278190081.offer("TIMESTAMP") [2146428.675] zwlr_data_control_offer_v1@4278190081.offer("TARGETS") [2146428.678] zwlr_data_control_offer_v1@4278190081.offer("SAVE_TARGETS") [2146428.680] zwlr_data_control_offer_v1@4278190081.offer("MULTIPLE") [2146428.682] zwlr_data_control_offer_v1@4278190081.offer("STRING") [2146428.686] zwlr_data_control_offer_v1@4278190081.offer("text/plain;charset=utf-8") [2146428.689] zwlr_data_control_offer_v1@4278190081.offer("text/plain") [2146428.692] zwlr_data_control_offer_v1@4278190081.offer("text/plain") [2146428.694] zwlr_data_control_offer_v1@4278190081.offer("text/plain;charset=utf-8") [2146428.696] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190081) [2146428.699] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190082) [2146428.701] zwlr_data_control_offer_v1@4278190082.offer("text/plain") [2146428.704] zwlr_data_control_offer_v1@4278190082.offer("text/plain;charset=utf-8") [2146428.707] zwlr_data_control_offer_v1@4278190082.offer("TEXT") [2146428.709] zwlr_data_control_offer_v1@4278190082.offer("STRING") [2146428.712] zwlr_data_control_offer_v1@4278190082.offer("UTF8_STRING") [2146428.715] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190082) [2146428.717] wl_callback@12.done(62967) [2146428.902] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2146428.925] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2146428.933] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2146428.996] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2146429.016] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2146429.110] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2146429.285] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2146429.352] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2146429.427] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2146482.070] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2146482.211] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2146482.367] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2146640.097] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2146640.196] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2146640.290] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147000.206] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2147000.305] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2147000.404] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147562.949] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2147563.044] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2147564.796] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147565.372] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147565.986] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190083) [2147565.997] zwlr_data_control_offer_v1@4278190083.offer("application/x-copyq-owner") [2147566.001] zwlr_data_control_offer_v1@4278190083.offer("text/plain") [2147566.004] zwlr_data_control_offer_v1@4278190083.offer("text/plain;charset=utf-8") [2147566.006] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190083) [2147566.014] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147566.611] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2147566.670] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2147566.735] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147614.321] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147615.554] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2147615.646] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2147615.745] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147757.544] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2147759.884] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2147759.982] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2147760.078] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2148100.586] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2148100.625] zwlr_data_control_source_v1@11.send("text/plain", fd 5) [2148100.827] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2148100.976] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2172274.369] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190084) [2172274.392] zwlr_data_control_offer_v1@4278190084.offer("TIMESTAMP") [2172274.397] zwlr_data_control_offer_v1@4278190084.offer("TARGETS") [2172274.400] zwlr_data_control_offer_v1@4278190084.offer("MULTIPLE") [2172274.402] zwlr_data_control_offer_v1@4278190084.offer("text/html") [2172274.405] zwlr_data_control_offer_v1@4278190084.offer("text/_moz_htmlcontext") [2172274.407] zwlr_data_control_offer_v1@4278190084.offer("text/_moz_htmlinfo") [2172274.409] zwlr_data_control_offer_v1@4278190084.offer("text/plain;charset=utf-8") [2172274.411] zwlr_data_control_offer_v1@4278190084.offer("COMPOUND_TEXT") [2172274.414] zwlr_data_control_offer_v1@4278190084.offer("text/plain") [2172274.416] zwlr_data_control_offer_v1@4278190084.offer("STRING") [2172274.418] zwlr_data_control_offer_v1@4278190084.offer("text/plain;charset=utf-8") [2172274.420] zwlr_data_control_offer_v1@4278190084.offer("text/plain") [2172274.422] zwlr_data_control_offer_v1@4278190084.offer("text/x-moz-url-priv") [2172274.425] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190084) [2172274.747] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2172275.236] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2172275.297] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2172275.377] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2172328.258] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2172328.547] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2172328.727] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2172486.985] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2172487.144] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2172487.263] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2172850.463] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2172850.635] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2172850.864] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2201361.844] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190085) [2201361.880] zwlr_data_control_offer_v1@4278190085.offer("text/plain") [2201361.886] zwlr_data_control_offer_v1@4278190085.offer("text/plain;charset=utf-8") [2201361.889] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190085) [2201364.403] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2201364.502] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2201364.614] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2201413.605] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2201413.707] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2201413.808] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2201557.586] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2201557.733] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2201557.857] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2201901.206] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2201901.452] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2201901.706] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2206074.737] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190086) [2206074.763] zwlr_data_control_offer_v1@4278190086.offer("text/plain") [2206074.768] zwlr_data_control_offer_v1@4278190086.offer("text/plain;charset=utf-8") [2206074.771] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190086) [2206079.347] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2206079.485] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2206079.579] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2206132.688] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2206132.835] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2206133.004] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2206291.726] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2206292.185] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2206292.333] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2206650.758] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2206650.903] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2206651.018] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2242893.794] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190087) [2242893.822] zwlr_data_control_offer_v1@4278190087.offer("TIMESTAMP") [2242893.827] zwlr_data_control_offer_v1@4278190087.offer("TARGETS") [2242893.831] zwlr_data_control_offer_v1@4278190087.offer("SAVE_TARGETS") [2242893.834] zwlr_data_control_offer_v1@4278190087.offer("MULTIPLE") [2242893.837] zwlr_data_control_offer_v1@4278190087.offer("STRING") [2242893.840] zwlr_data_control_offer_v1@4278190087.offer("text/plain;charset=utf-8") [2242893.842] zwlr_data_control_offer_v1@4278190087.offer("text/plain") [2242893.845] zwlr_data_control_offer_v1@4278190087.offer("text/plain") [2242893.848] zwlr_data_control_offer_v1@4278190087.offer("text/plain;charset=utf-8") [2242893.851] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190087) [2242894.601] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2242894.672] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2242894.749] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2242946.887] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2242947.121] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2242947.361] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2243100.638] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2243100.841] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2243100.997] zwlr_data_control_source_v1@11.send("image/png", fd 4) [2243450.285] zwlr_data_control_source_v1@11.send("text/plain", fd 4) [2243450.411] zwlr_data_control_source_v1@11.send("text/plain;charset=utf-8", fd 4) [2243450.500] zwlr_data_control_source_v1@11.send("image/png", fd 4) ```

For obvious reasons i cannot compare the stdout. Maybe thats where the problem is. Not sure how the shortcut launches the script, but if it didnt have an stdout (if thats even possible) that could lead to problems? This would also explain why it works when running the script normally as it then has an stdout.

Hope it helps.

bugaevc commented 1 year ago

That is helpful, thank you!

What version of wl-clipboard do you have, does it include https://github.com/bugaevc/wl-clipboard/commit/aa4633b894c3c5ae6053026529ec9288566060a6 (which is in 2.1.0 and newer)?

wl_display_dispatch: Socket operation on non-socket

This is certainly concerning.

What could happen here is that wl-copy is launched without an stdout, so the Wayland connection gets fd 1, which wl-copy then closes thinking that it's its stdout. That itself will break everything, but then some other file is opened under the same fd 1, and wl_display_dispatch tries to operate on that and finds out that it's not a socket.

Would it be possible for you to find out whether wl-copy indeed starts up with some of the standard fds (0, 1, 2) closed?

Ruakij commented 1 year ago

What version of wl-clipboard do you have, does it include aa4633b (which is in 2.1.0 and newer)?

--version reports 2.1.0

I'll try to check how its launched and what state the pipes have.

Ruakij commented 1 year ago
# Check if stdin exists
if [ -t 0 ]; then
  echo "stdin exists" >> /tmp/output
else
  echo "stdin does not exist" >> /tmp/output
fi

# Check if stdout exists
if [ -t 1 ]; then
  echo "stdout exists" >> /tmp/output
else
  echo "stdout does not exist" >> /tmp/output
fi

# Check if stderr exists
if [ -t 2 ]; then
  echo "stderr exists" >> /tmp/output
else
  echo "stderr does not exist" >> /tmp/output
fi

Ran once with a shortcut and once directly:

stdin does not exist
stdout does not exist
stderr does not exist
stdin exists
stdout exists
stderr exists
bugaevc commented 1 year ago

Thank you!

In this case it clearly is an issue with how KDE spawns processes from shortcuts. It absolutely should provide the standard descriptors. It would be best to connect stdout and stderr to the system journal in this case, like it's done for services, but if that's not available, it should at least open /dev/null. All the Unix software is written under the assumption that it can use stdout/stderr and that won't interfere with whatever other files it opens. This is not something that the launched software can be reasonably expected to check, it's on KDE (or whoever spawns wl-clipboard) to provide it with a sane environment.

So please report this to KDE, it's their bug.

However, seeing how multiple people have reported it against wl-clipboard, I'll add a check that the Wayland fd is > 2. If it isn't, wl-clipboard will try to log a message (which is tricky when you might not have stderr...) explaining what's going on and abort.

Thank you again for figuring this out!

Ruakij commented 1 year ago

Bug is filed: https://bugs.kde.org/show_bug.cgi?id=469328

bugaevc commented 1 year ago

Everyone (@Beyley, @Ruakij, @QazCetelic, @OhaDerErste), please try the abort-on-closed-stdio branch. If this is indeed what's happening, wl-clipboard will now complain loudly -- to the journal if there's no other option.

So please all state whether or not this is happening in your case.

Ruakij commented 1 year ago

I have compiled and tested the branch. I get the error-message in stderr you set and wl-copy exits with code 134.

When stderr is not attached, this prints in the journal:

Log ```log Mai 04 09:46:30 system systemd[1634]: Started /home/ruakij/Spectacle-OCR/script.sh. kwin_wayland_wrapper[42608]: wl-clipboard has been launched with a closed standard file descriptor. This is a bug in the software that has launched wl-clipboard. Aborting. Mai 04 09:46:33 system systemd[1]: Started Process Core Dump (PID 42609/UID 0). Mai 04 09:46:33 system systemd-coredump[42610]: [🡕] Process 42608 (wl-copy) of user 1000 dumped core. Stack trace of thread 42608: #0 0x00007f1be56fc8ec n/a (libc.so.6 + 0x878ec) #1 0x00007f1be56adea8 raise (libc.so.6 + 0x38ea8) #2 0x00007f1be569753d abort (libc.so.6 + 0x2253d) #3 0x000055f7592d0fc5 n/a (/home/ruakij/git/github.com/bugaevc/wl-clipboard/build/src/wl-copy + 0x5fc5) #4 0x000055f7592d08c6 n/a (/home/ruakij/git/github.com/bugaevc/wl-clipboard/build/src/wl-copy + 0x58c6) #5 0x00007f1be5698790 n/a (libc.so.6 + 0x23790) #6 0x00007f1be569884a __libc_start_main (libc.so.6 + 0x2384a) #7 0x000055f7592d0475 n/a (/home/ruakij/git/github.com/bugaevc/wl-clipboard/build/src/wl-copy + 0x5475) ELF object binary architecture: AMD x86-64 Mai 04 09:46:33 system kwin_wayland_wrapper[42557]: /home/ruakij/Spectacle-OCR/script.sh: line 40: 42608 Aborted (core dumped) /home/ruakij/git/github.com/bugaevc/wl-clipboard/build/src/wl-copy "$OUTPUT" ```
bugaevc commented 1 year ago

Awesome -- so if you didn't already know what's going on, would that be enough to point you in the right direction?

Ruakij commented 1 year ago

I think the visibility might be a problem, but you dont really have other choices :) But yeah i think the log message should be sufficient to know or at least search what the issue might be (and probably finding this issue :+1:)