How to access the Linux clipboard without unit Clipbrd? lazarus / 32-Linux ---------------------------------------------------------------------- Hartmut · 2019-08-06 15:27 I want to access the Linux clipboard (only for plain text) from a small console program. I cannot use unit Clipbrd, because it does not work in a console program, because of using the LCL (on Windows this works perfectly). More see https://forum.lazarus.freepascal.org/index.php/topic,46259.0.html So my idea is (inspired by reply #4 of the above link) the following program: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode objfpc}{$H+} uses gtk2,gdk2; var c: PGtkClipboard;    s: string; beginwriteln('AAA');   c:=gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);writeln('BBB');   s:='Hello world';   gtk_clipboard_set_text(c, PChar(s), Length(s));writeln('CCC');   gtk_clipboard_store(c);writeln('DDD');end. It compiles but gives the following runtime errors: Code: [Select]AAA (process:2761): Gtk-CRITICAL **: 17:09:15.766: IA__gtk_clipboard_get_for_display: assertion 'display != NULL' failed BBB (process:2761): Gtk-CRITICAL **: 17:09:15.767: IA__gtk_clipboard_set_text: assertion 'clipboard != NULL' failed CCC (process:2761): Gtk-CRITICAL **: 17:09:15.767: IA__gtk_clipboard_store: assertion 'GTK_IS_CLIPBOARD (clipboard)' failed DDD Probably some initialization is missing. I tried to look into the code but failed to understand it. Does anyone know, how to modify this code that it works? I use Lazarus 1.8.4 with FPC 3.0.4 on Ubuntu 18.04 (64 bit). Thanks in advance. ---------------------------------------------------------------------- bytebites · 2019-08-06 16:56 Error disappeared when I added Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i gtk_init(@argc, @argv); ---------------------------------------------------------------------- Hartmut · 2019-08-06 17:26 Hello bytebites, yes, the errors disappeared now. Thanks a lot. But I expected, after running my program, that the clipboard contains "Hello world". But it still contains that, what was in the clipboard, before I started my program. Is there some kind of "finalization" missing? Do you or somebody else know, how my code must be modified to work? I want to write something into the clipboard. ---------------------------------------------------------------------- bytebites · 2019-08-06 17:42 Add readln at the end of the code and see what happens. When the program terminates, pasted text disappears. ---------------------------------------------------------------------- Hartmut · 2019-08-06 18:04 I placed a readln() at the end of my program. While the program is waiting for the readln(), the clipboard is empty, does not contain "Hello world". After I press ENTER, the clipboard again contains that text, what was in the clipboard, before I started my program.