SUPERCILEX / gnome-clipboard-history

Gnome Clipboard History is a clipboard manager Gnome extension that saves what you've copied into an easily accessible, searchable history panel.
https://extensions.gnome.org/extension/4839/clipboard-history/
MIT License
455 stars 45 forks source link

How to view database.log #174

Closed hedgieinsocks closed 3 months ago

hedgieinsocks commented 3 months ago

Is there any sane way to view the contents of database.log file? I'd like to interact with the clipboard history via fzf :)

SUPERCILEX commented 3 months ago

There's tooling to extract metadata, but nothing in this repo to manipulate data via the CLI. But! I'm working on a replacement from the ground up and while the UI is currently non-functional (paste isn't implemented yet), there's pretty nice tooling for CLI stuff. If you're willing to be my guinea pig, you can take a look at Ringboard: https://github.com/SUPERCILEX/clipboard-history. Install it (ideally using the curl command so I know if the script works on other people's machines) and then run a migration: https://github.com/SUPERCILEX/clipboard-history#migrating-from-existing-clipboard-managers. Some caveats: this is a totally separate clipboard, so if you modify anything manually in this extension that won't be reflected in Ringboard. Also Ringboard supports more than just plain text data so it might copy slightly different stuff.

Anyway, for your purposes you can ringboard dev dump which spits out JSON as described here: https://github.com/SUPERCILEX/clipboard-history/blob/fcdb188191aa40d4b0ebf750a7ef7f9f4c23b4c6/cli/command-reference.golden#L269-L273. You'll then probably want to filter for kind = Human so you don't have to deal with base64 and use jq to extract out all the data fields for fzf.

hedgieinsocks commented 3 months ago

Thank you for your prompt response!

I'm using Fedora 40 on wayland. I already had cargo installed from dnf rustup.

I did the curl installation as asked, and it went without errors. But I guess you need to add --now flag to systemctl enable command, cause I had to start the service manually.

Not sure how, but x11 version service seems to work. Here is how I ended up using fzf with that ringboard:

cb() {
  ringboard dev dump \
    | jq --compact-output --raw-output0 '.[] | select(.kind == "Human") | .data' \
    | fzf --read0 --tac --highlight-line --cycle --layout=reverse --height=40% --query "${*:-}" \
    | wl-copy -n
  [[ -n "${ZLE_STATE}" ]] && zle reset-prompt
}
zle -N cb
bindkey "^s" cb

So it seems like I ended up with what I wanted. Hopefully, two separate watchers won't impact the battery/cpu :P

SUPERCILEX commented 3 months ago

But I guess you need to add --now flag to systemctl enable command, cause I had to start the service manually.

Thank you for that catch, fixed!

Not sure how, but x11 version service seems to work.

I also didn't know this until working on the project, but Xwayland provides a compatibility layer so that anything X11 should mostly work when running under Wayland. Of course you don't get to take advantage of Wayland's improved efficiency, but for now it's fine. I'm going to add a Wayland clipboard watcher eventually.

So it seems like I ended up with what I wanted. Hopefully, two separate watchers won't impact the battery/cpu :P

Sweet, glad it's working! And no, there shouldn't be any performance issues: Ringboard is way over engineered so it should be extremely efficient.

hedgieinsocks commented 3 months ago

Just for fun, while gui is not yet functional, and looks like an abomination, here's how I've adopted your baby :D https://github.com/hedgieinsocks/ulauncher-ringboard

It will likely not scale with a lot of entries or when there will be huge entries, but for my simple purposes good enough. By the way, I had to use python fuzzy search cause ringboard search does not work and exits with error right away

SUPERCILEX commented 3 months ago

Just for fun, while gui is not yet functional, and looks like an abomination, here's how I've adopted your baby :D

Lol, very nice. BTW, $ ringboard-egui does have search, you just can't paste entries yet. Also fuzzy search isn't supported though I'll look into adding it because that seems pretty reasonable.

ringboard search does not work and exits with error right away

Can you share what the error is? It should work.

hedgieinsocks commented 3 months ago
❯ strace ringboard search foo
execve("/home/hedgieinsocks/.cargo/bin/ringboard", ["ringboard", "search", "foo"], 0x7ffe545886b0 /* 95 vars */) = 0
brk(NULL)                               = 0x557adb3e4000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=70943, ...}) = 0
mmap(NULL, 70943, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5fab00b000
close(3)                                = 0
openat(AT_FDCWD, "/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=190552, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5fab009000
mmap(NULL, 184776, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5faafdb000
mmap(0x7f5faafdf000, 147456, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f5faafdf000
mmap(0x7f5fab003000, 16384, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x7f5fab003000
mmap(0x7f5fab007000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2c000) = 0x7f5fab007000
mmap(0x7f5fab008000, 456, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5fab008000
close(3)                                = 0
openat(AT_FDCWD, "/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=944216, ...}) = 0
mmap(NULL, 925712, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5faaef8000
mmap(0x7f5faaf08000, 487424, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0x7f5faaf08000
mmap(0x7f5faaf7f000, 368640, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x87000) = 0x7f5faaf7f000
mmap(0x7f5faafd9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe0000) = 0x7f5faafd9000
close(3)                                = 0
openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\242\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
fstat(3, {st_mode=S_IFREG|0755, st_size=2423856, ...}) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 2018160, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5faad0b000
mmap(0x7f5faad33000, 1478656, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x7f5faad33000
mmap(0x7f5faae9c000, 319488, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x191000) = 0x7f5faae9c000
mmap(0x7f5faaeea000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1de000) = 0x7f5faaeea000
mmap(0x7f5faaef0000, 31600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5faaef0000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5faad09000
arch_prctl(ARCH_SET_FS, 0x7f5faad09c40) = 0
set_tid_address(0x7f5faad09f10)         = 355093
set_robust_list(0x7f5faad09f20, 24)     = 0
rseq(0x7f5faad0a560, 0x20, 0, 0x53053053) = 0
mprotect(0x7f5faaeea000, 16384, PROT_READ) = 0
mprotect(0x7f5faafd9000, 4096, PROT_READ) = 0
mprotect(0x7f5fab007000, 4096, PROT_READ) = 0
mprotect(0x557ad5fdb000, 278528, PROT_READ) = 0
mprotect(0x7f5fab055000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7f5fab00b000, 70943)           = 0
poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 0 (Timeout)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f5faad4b710}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
getrandom("\x55\xe2\x1b\xbb\x97\x05\x9c\x00", 8, GRND_NONBLOCK) = 8
brk(NULL)                               = 0x557adb3e4000
brk(0x557adb405000)                     = 0x557adb405000
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = 3
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "557ad5cbb000-557ad5dc7000 r--p 0"..., 1024) = 1024
read(3, "f5faaef0000 rw-p 001e2000 00:21 "..., 1024) = 1024
read(3, "-20240620.so.1\n7f5fab008000-7f5f"..., 1024) = 914
close(3)                                = 0
sched_getaffinity(355093, 32, [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]) = 8
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0x557ad5fb2880, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7f5faad4b710}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x557ad5fb2880, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7f5faad4b710}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f5fab01a000
mprotect(0x7f5fab01a000, 4096, PROT_NONE) = 0
sigaltstack({ss_sp=0x7f5fab01b000, ss_flags=0, ss_size=8192}, NULL) = 0
statx(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFDIR|0755, stx_size=114, ...}) = 0
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/main.ring", O_RDONLY|O_LARGEFILE) = 3
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=64, ...}) = 0
mmap(NULL, 1048576, PROT_READ, MAP_SHARED_VALIDATE, 3, 0) = 0x7f5faac09000
close(3)                                = 0
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/favorites.ring", O_RDONLY|O_LARGEFILE) = 3
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=8, ...}) = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 3, 0) = 0x7f5fab019000
close(3)                                = 0
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(0, 4]", O_RDONLY|O_LARGEFILE) = 3
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(4, 8]", O_RDONLY|O_LARGEFILE) = 4
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(8, 16]", O_RDONLY|O_LARGEFILE) = 5
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(16, 32]", O_RDONLY|O_LARGEFILE) = 6
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(32, 64]", O_RDONLY|O_LARGEFILE) = 7
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(64, 128]", O_RDONLY|O_LARGEFILE) = 8
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(128, 256]", O_RDONLY|O_LARGEFILE) = 9
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(256, 512]", O_RDONLY|O_LARGEFILE) = 10
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(512, 1024]", O_RDONLY|O_LARGEFILE) = 11
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(1024, 2048]", O_RDONLY|O_LARGEFILE) = 12
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/buckets/(2048, 4096)", O_RDONLY|O_LARGEFILE) = 13
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
statx(4, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=24, ...}) = 0
statx(5, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=112, ...}) = 0
statx(6, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
statx(7, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=192, ...}) = 0
statx(8, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
statx(9, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
statx(10, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
statx(11, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
statx(12, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_SIZE, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0600, stx_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 3, 0) = 0x7f5fab018000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 4, 0) = 0x7f5fab017000
close(4)                                = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 5, 0) = 0x7f5fab016000
close(5)                                = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 6, 0) = 0x7f5fab015000
close(6)                                = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 7, 0) = 0x7f5fab014000
close(7)                                = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 8, 0) = 0x7f5fab013000
close(8)                                = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 9, 0) = 0x7f5fab012000
close(9)                                = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 10, 0) = 0x7f5fab011000
close(10)                               = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 11, 0) = 0x7f5fab010000
close(11)                               = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 12, 0) = 0x7f5fab00f000
close(12)                               = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED_VALIDATE, 13, 0) = 0x7f5fab00e000
close(13)                               = 0
openat(AT_FDCWD, "/home/hedgieinsocks/.local/share/clipboard-history/direct", O_RDONLY|O_LARGEFILE|O_PATH|O_DIRECTORY) = 3
rt_sigaction(SIGRT_1, {sa_handler=0x7f5faad9e190, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f5faad4b710}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
mmap(NULL, 2101248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f5faaa00000
mprotect(0x7f5faaa01000, 2097152, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[], [], 8)   = 0
clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, child_tid=0x7f5faac00990, parent_tid=0x7f5faac00990, exit_signal=0, stack=0x7f5faaa00000, stack_size=0x1ffec0, tls=0x7f5faac006c0} => {parent_tid=[355094]}, 88) = 355094
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 2101248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f5faa600000
+++ killed by SIGBUS (core dumped) +++
[1]    355090 bus error (core dumped)  strace ringboard search foo
SUPERCILEX commented 3 months ago

Ah, silly mistake. Just published a new version with the fix.