You are not logged in.

#1 2012-07-09 21:08:27

Cloudef
Member
Registered: 2010-10-12
Posts: 636

xcmenu - lightweight clipboard manager for X (formerly loliclip)

Due to issues with the project name.
The name has been changed from loliclip -> xcmenu.
You should update to use the new xcmenu package instead.
To move your old clipboard history over, do: mv ~/.local/share/loliclip ~/.local/share/xcmenu

I wrote small clipboard manager in XCB.

The motivation for this project was that I was fed up with the current clipboard solutions.
What I mainly wanted was just simple synchorization from XA_CLIPBOARD to XA_PRIMARY automatically.
And optionally vice versa when certain key combo is pressed.

I used to do this with xclip && xsel before and simple script. But xsel && xclip got sometimes stuck,
and the history files felt bit too hacky for my taste.

TODO: write better readme

Lightweight clipboard manager for X

By default it keeps history of your XA_CLIPBOARD,
and keeps XA_PRIMARY on sync with it.

History is saved in XDG_USER_DATA/xcmenu or $HOME/.local/xcmenu
By default it uses zlib compression.

Change settings in config.h
Also comes with bash script for dmenu access.

xcmenuctrl can read dmenu settings from $HOME/.dmenurc
with the variable XCMENUCTRL_DMENU, for example:
XCMENUCTRL_DMENU='dmenu -i -l 15'

By default, xcmenu uses CLEAR_SELECTIONS bitflag for,
XA_CLIPBOARD to increase compatibility with applications.

Without this flag however, you can have some extra flexibility
related to selection targets.

MISC:
   You can set clipboard data similar to xsel/xclip
   echo "asd" | xcmenu -pi # copy to primary
   echo "asd" | xcmenu -ci # copy to clipboard
   xcmenu -p               # output selection from primary
   xcmenu -c               # output selection from clipboard

   Special selections are supported as well
   xcmenu -b image/png > image.png  # get image from gimp
   xcmenu -bi image/png < image.png # upload image to image/png

Those commands will leave xcmenu process open until someone else takes ownership of the particular selection (ex. XA_CLIPBOARD).

TODO:
   Remove clip by index from history from CLI
   Dynamic specialclip buffers

github
AUR

Some discussion from later pages of how to use xcmenu properly:

webspider wrote:

So I have seen this excellent little tool and decided to integrate it in my dwm-workflow. Although I've been reading a lot about how X implements the clipboard and selection buffers, I don't really understand how to use it as efficiently as possible. Maybe I'm just too tired and will gain sudden insight the next morning.
If I've understood everything correctly, there are two trivial and two not so trivial cases:

- Copy/Paste between terminals/ttys or in a terminal/tty: Select  and press Shift+Insert to paste the selection.
- Copy/Paste between GUI applications or in a GUI application: Use the controls given (usually these would be Ctrl+C and Ctrl+V).
- Copy/Paste from a terminal to a GUI application: use ``echo "ABC" | xcmenu -ci`` in the terminal, then use Ctrl+V in the GUI application.
- Copy/Paste from a GUI application to a terminal: use Ctrl+C in the GUI application, then use ``xcmenu --get`` in the terminal.

Is this correct? It feels very clunky to me and I currently don't see how to make things go smoother by binding certain xcmenu or xcmenuctrl commands to keys or writing scripts that use xcmenu or xcmenuctrl to autosync stuff. Maybe I'm just too used to the Microsoft way and am over-thinking everything. It would be cool if somebody can give me a hint or even write a small round-up on Clipboards and tools to manage them. Thank you, guys.

Copy/Paste from GUI to terminal: Ctrl+C in GUI, shift+insert in terminal (this is what default config.h in xcmenu does)
Copy/Paste from terminal to GUI: bind 'xcmenuctrl -spc' in your wm or whatever you use to bind keys.
And use that to synchorize primary to clipboard manually when you need it.

From vim without X clipboard support compiled in:
xnoremap <silent> <C-c> "zy:call system('xcmenu -ci', @z)<cr>

It's possible to set primary to sync to clipboard automatically as well in config.h
But it's quite counter innutive since your clipboard gets replaced each text selection.

That's at least my workflow.. and 'xcmenuctrl' for history, 'xcmenuctrl -u' for url history.
(I have these binded to 'meta-c' and 'meta-shift-c' the primary sync is binded to 'alt-shift-c')

Example of how to copy image to clipboard from sxiv:

# Add to config.h of sxiv
{ true, XK_c, it_shell_cmd, (arg_t)"xcmenu -bwi image/png < \"$SXIV_IMG\"; xcmenu -bi text/uri-list \"$SXIV_IMG\"" },

Even though, it stores it in image/png. At least sxiv itself and gimp will open the file fine in any file format you copy to the buffer for some reason (even animated gifs work).

Add files to text/uri-list copy buffer:

echo "file:///home/user/README\nfile:///home/user/video.mkv" | xcmenu -bi text/uri-list

This works at least with qtfm which is the only graphical fm I have installed for testing atm.
It should be possible to integrate this with ranger for example I think.

You can also have your own custom buffer, by adding new special selection to xcmenu's config.h,
you can access it through -b switch like usual.

Last edited by Cloudef (2013-12-09 17:13:16)

Offline

#2 2012-07-10 11:55:13

DoctorSamulus
Member
Registered: 2010-11-04
Posts: 53

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Wow this is awesome! Does exactly what its supposed to. And holy crap I just ran lolictrl, this is great. Looking forward to that config.h so I can theme it for my wm, thanks!

Offline

#3 2012-07-10 23:13:23

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

DoctorSamulus wrote:

Wow this is awesome! Does exactly what its supposed to. And holy crap I just ran lolictrl, this is great. Looking forward to that config.h so I can theme it for my wm, thanks!

If you just want to theme, I suggest writing wrapper script for dmenu and puttin it to your path instead.
Something like my dmenu wrapper for example. Other plus side is that it works for each application that launches dmenu without any options you have specified in the wrapper.

The config.h will have only loliclip's build time configuration. I'm glad you like it though, and suggestions are welcome. I encountered some issue where it stopped syncing for some reason yesterday as well, but it's probably related to the clipboard owning issues mentioned above.

Also some minor usability improvements like when picking urls with lolictrl -u, would be great if they skipped history for example.

These will all be fixed of course, since I use it smile

Last edited by Cloudef (2012-07-10 23:14:49)

Offline

#4 2012-07-11 01:38:23

x_fausto
Member
Registered: 2011-11-12
Posts: 18
Website

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

The first thing I note was the name, but now that I use it, it's awesome. Great tool.


Fork me on Github  |  Eri  @  Arch Linux i686

Offline

#5 2012-07-11 22:50:52

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Ok, fixed some issues mentioned before. Still no config.h though.
Selecting from lolictrl and pasting instantly should work without any delays.
Noticed some history duplicating which I fixed as well.
Also some other minor stuff.

You might notice processes such as 'loliclip --clipboard', if you use lolictrl.
These are merely small X clients that are blocking until some else X client takes over the
particular selection (similar to xsel/xclip).  I tried to do this another way instead of leaving
the process open, but it seems there is no sane way without good response.

If you ever see more than one of these small clients for particular selection, then there is a bug.

Last edited by Cloudef (2012-07-11 23:04:41)

Offline

#6 2012-07-14 09:57:43

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Fixed bug where exact match from clipboard (and after postprocessing) would be rejected and not get synchorized or saved in the history.

Offline

#7 2012-07-15 12:26:48

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Thanks for sharing. Small suggestion:

sed -i 's/_crappy_/_/g' *

gh · da · ds · cr · ab · fkr

Offline

#8 2012-07-15 12:45:50

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

bloom wrote:

Thanks for sharing. Small suggestion:

sed -i 's/_crappy_/_/g' *

Done.

Offline

#9 2012-07-16 12:58:26

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Great app! Does what it's supposed to do. I was using anamnesis before, but this is my new clipboard manager. smile

Offline

#10 2012-07-17 23:06:45

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Some changes,

- Basic config.h file is provided.
- XA_CLIPBOARD is owned immediatly when new data by default now
- Command sequences ex. '#LC:skip_history:Hello, I'm skipping your history'
- loliclip [-psc] arguments are daemonized now by default, so they won't block
- lolictrl url mode now skips history
- better url matching

Last edited by Cloudef (2012-07-17 23:59:48)

Offline

#11 2012-07-19 17:50:24

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Pushed fix where loliclip responded wrong to TARGETS request.

Offline

#12 2012-07-22 14:46:41

ne
Member
Registered: 2012-03-25
Posts: 15

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Could you put it on the AUR? Just replaced ClipIt with this.

Offline

#13 2012-07-22 15:00:08

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

ne wrote:

Could you put it on the AUR? Just replaced ClipIt with this.

done.

Offline

#14 2012-07-22 18:48:37

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 841

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Thanks, nice little app.

Few issues I came across:

1. Piping into loliclip doesn't work for even number of letters, for example:

echo "a" | loliclip -c #works
echo "aa" | loliclip -c #doesn't work
echo "aaa" | loliclip -c #works
echo "aaaa" | loliclip -c #doesn't work

when it fails, nothing gets into clipboard.

2. When the above does work, it pastes a new line when it shouldn't. For example, when doing

echo "aaa" | loliclip -c

and pasting into GTK text editor, it pastes "aaa" and hops into a new line.

3. Any plans to support binary data (for example part of a GIMP painting and such)? Currently it does not seem to work.

Last edited by karabaja4 (2012-07-22 19:03:05)


pie!

Online

#15 2012-07-22 19:24:02

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

@karabaja4
1 && 2) Thanks for reporting, I'll take a look what's at cause.
3) Gimp seems to work here fined, can you give more details?

Edit, I can't seem to reproduce 1 and 2 either. Could you give me exact steps?

Last edited by Cloudef (2012-07-22 19:26:13)

Offline

#16 2012-07-22 20:46:56

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 841

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Here are the steps. I think I found another bug or another way to reproduce the above bug, this is it:

0) Make sure loliclip isn't running and remove the ~/.local/share/loliclip/ folder.
1) Start loliclip in a terminal with a command "loliclip" and leave the terminal open.
2) Open Geany or some other GTK editor. Write "aaaa" in it and copy the whole word.
3) Close Geany.
4) Open Geany again. Paste. Nothing gets pasted (if it pasted successfully close Geany and goto 2 with different word size).

GIMP:
0) Run loliclip like the above.
1) Open GIMP, make new image and paint something in it.
2) Select a part of an image and cut/copy it.
3) Close GIMP, don't save.
4) Open GIMP again.
5) Make new blank image. Paste. Nothing gets pasted.

For new line and piping problem I have to figure out how to reproduce it with consistent results. It seems to work sometimes, other times it doesn't.

Last edited by karabaja4 (2012-07-22 21:21:10)


pie!

Online

#17 2012-07-22 21:24:37

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Thank you, I'll try reproducing these issues later today.
I'm pretty sure the newline bug you are expiring is related to the 'aaaa' issue as well.

I see, that you want persistant clipboard store for GIMP.
I'm not sure if this is possible, but I can take a look at it (does some other clipboard manager do it?)

Anyways, off to sleep for now.

Last edited by Cloudef (2012-07-22 21:24:55)

Offline

#18 2012-07-22 21:36:06

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 841

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Cloudef wrote:

I see, that you want persistant clipboard store for GIMP.
I'm not sure if this is possible, but I can take a look at it (does some other clipboard manager do it?)

It's not just GIMP, clipboard can store images, parts of images, parts of audio, etc. that is, any kind of binary data.

qlipper2-git does it, but because it handles xclip/xsel poorly I don't use it.

Your idea with automatic clipboard->primary synchronizing is extremely useful, it would be awesome it you could solve these few bugs.


pie!

Online

#19 2012-07-23 05:02:08

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

It's not just GIMP, clipboard can store images, parts of images, parts of audio, etc. that is, any kind of binary data.

Then It's propably the inc/multiple atoms I din't implement as they looked like a pain. I'll see what I can do when my work is over.

Last edited by Cloudef (2012-07-23 05:02:21)

Offline

#20 2012-07-23 15:08:52

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

0) Make sure loliclip isn't running and remove the ~/.local/share/loliclip/ folder.
1) Start loliclip in a terminal with a command "loliclip" and leave the terminal open.
2) Open Geany or some other GTK editor. Write "aaaa" in it and copy the whole word.
3) Close Geany.
4) Open Geany again. Paste. Nothing gets pasted (if it pasted successfully close Geany and goto 2 with different word size).

I can't seem to be able to reproduce this, no matter how many times I try.
Can you make sure you have latest version from here

Maybe flip the DEBUG=0 to 1 in the PKGBUILD and paste the output of loliclip daemon to gist.github or something when the bug triggers.

I'm working on giving gimp a support atm.

Offline

#21 2012-07-23 16:15:27

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 841

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Cloudef wrote:

I can't seem to be able to reproduce this, no matter how many times I try.
Can you make sure you have latest version from here

Maybe flip the DEBUG=0 to 1 in the PKGBUILD and paste the output of loliclip daemon to gist.github or something when the bug triggers.

I'm working on giving gimp a support atm.

I owe you an apology, the whole time I was using gcw editor, not Geany. I said to use Geany because I figured you probably already have it installed.

Anyway, with Geany, it works fine. So it's probably not your bug but there's something wrong with my editor.

Here's the output of loliclip when using gcw just in case:

~ >>> loliclip
-!- Taking ownership of PRIMARY
-!- PRIMARY = 0x1
-!- Taking ownership of SECONDARY
-!- SECONDARY = 0x2
-!- Taking ownership of CLIPBOARD
-!- CLIPBOARD = 0x194
-!- XSEL_DATA = 0x1fc
-!- support: UTF8_STRING
-!- UTF8_STRING = 0x110
-!- STRING = 0x1f
-!- support: TIMESTAMP
-!- TIMESTAMP = 0x19e
-!- support: TARGETS
-!- TARGETS = 0x19c
-!- support: DELETE
-!- DELETE = 0x1fd
-!- support: NULL
-!- NULL = 0x1fe
-!- support: TEXT
-!- TEXT = 0x1b4
-!- INTEGER = 0x13
-!- ATOM = 0x4
-!- 1480 [/home/igor/Downloads/loliclip/src/loliclip.c :: main]: Starting loliclip
-!- xcb: selection request
-!- SENT: (null) [0]
-!- xcb: selection request
-!- SENT: (null) [0]
-!- xcb: clear request
-!- PRIMARY owner is: 0x2800102
-!- Requesting selection from X
-!- Failed to get selection from X
-!- Taking ownership of PRIMARY
-!- xcb: unhandled event
-!- xcb: unhandled event
-!- xcb: clear request
-!- PRIMARY owner is: 0x2800102
-!- Requesting selection from X
-!- Start of PRIMARY copy
-!- Requesting selection from X
-!- End of PRIMARY copy
-!- Requesting selection from X
-!- Requesting selection from X
-!- Failed to get selection from X ///////////////////////////////////////////////////////////////////////////// around this command I press Ctrl-C
-!- Taking ownership of PRIMARY
Terminated

Last edited by karabaja4 (2012-07-23 16:16:39)


pie!

Online

#22 2012-07-23 16:23:41

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Anyway, with Geany, it works fine. So it's probably not your bug but there's something wrong with my editor.

Nope, I actually just installed it. The only editor I have is vim smile I'll check out qcw.

Btw, in debug build the ctrl-c is trapped, and it won't actually terminate until you break the select that loliclip is doing.
You can break it by copying something to any clipboard you have registered in config.h.
This is so I can debug any memory leaks by exiting the application cleanly.

As for gimp support, this will take a while.

E: Can't seem to reproduce with gcw either, this bug is starting to sound quite troublesome.
E2: Ok got it! Should be fixed soon. (Cloudef time)

Last edited by Cloudef (2012-07-23 19:25:09)

Offline

#23 2012-07-24 18:39:36

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

@karabaja4

Could you try with the latest version from Git? I did some fixes..
I could not reproduce your bug anymore with ctrl-c copy, I noticed some issues with PRIMARY selection however which I fixed as well.

There is also some beginnings for INCR support, but none that works yet.. Need to get head around still how it really works.
The INCR support will also fix copying of huge texts.

Offline

#24 2012-07-24 21:12:09

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 841

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

Whatever you did seems to have fixed the problem with gcw. I cannot reproduce the bug anymore. Thanks!

Looking forward to the INCR support.

EDIT: One small bug I noticed though. Sometimes when I click Ctrl-C in gcw I lose the selection of the text (text does get into clipboard). This doesn't happen without loliclip.

Last edited by karabaja4 (2012-07-24 21:19:20)


pie!

Online

#25 2012-07-24 22:19:36

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: xcmenu - lightweight clipboard manager for X (formerly loliclip)

karabaja4 wrote:

EDIT: One small bug I noticed though. Sometimes when I click Ctrl-C in gcw I lose the selection of the text (text does get into clipboard). This doesn't happen without loliclip.

This "bug" is explained in the config.h.
Basically, when you press ctrl-c. Loliclip notices the change in clipboard, after this loliclip syncs the clipboard to PRIMARY which requires taking ownership of primary and this causes the selection to be lost visually on application. I don't know if there is any solution for this.

Last edited by Cloudef (2012-07-24 22:20:46)

Offline

Board footer

Powered by FluxBB