Copying from clipboard into script

Hi :slight_smile:

I assume (for this case) there is only text in the clipboard. How can I get access to what is saved in clipboard to use in script?

When I select some text and press the combination Ctrl-C → text is in clipboard. But where is this text stored in my OS and how I could use it, but not with keyboard (Ctrl-V). I want that what is in clipboard was copied into bash script (or Python maybe).

I’ve searched for clues and found something like xclip (stackoverflow pipe-to-from-the-clipboard-in-bash-script) but find / -name xclip throws nothing. So I don’t have xclip and Ctrl-C Ctrl-V combinations works fine what means that my OS have some way to work with copy/paste. Other searches point to urxvt (which am using) but there is no need to run terminal. I just want get what is inside clipboard register put into script to work with it and run it with some bindsym combination.

I hope you understand what I mean :slight_smile:

The i3 edition uses clipit as a clipboard manager. The cliboard history can be found in the file ~/.local/share/clipit/history.

Maybe some of the suggestions here would help:

echo "toto" | xclip
ls -l | xclip
...
# display content
xclip -out
1 Like

Are you sure you don’t have xclip installed? Try running xclip -version to see. If you have it then xclip -o should work in a script. Alternatively you could use clipit -c, assuming you have that installed, but how it works will depend on how you have clipit configured.

1 Like
[groot@dell:~]$ xclip -version
bash: xclip: command not found

I will try suggestion mentioned by @bill_t tomorrow.

Huh, weird. It’s in the repositories, so you can just install it with pacman (or pamac or whatever), or you can go with clipit.

The i3 edition uses clipit as a clipboard manager.

clipit is the answer i was looking for. Thank you @bill_t

I found one more problem with clipit. If it was launched via terminal it throws error
Gtk-WARNING **: Unable to locate theme engine in module_path: "adwaita"
but a little searching brings solution. There was need of

sudo pacman -S gnome-themes-standard

and problem disappears :slight_smile:

Now

clipit -c

gives me what i need :wink:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.