From 88417264e401a75ab5566d6ae317ac424bf4a5cf Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 14 Sep 2021 12:46:17 -0400 Subject: cutbuffer: add menu; key bound to shift-PrtSc --- dot/local/bin/cutbuffer | 30 ++++++++++++++++++++++++++---- dot/xbindkeysrc | 3 +++ 2 files changed, 29 insertions(+), 4 deletions(-) mode change 100644 => 100755 dot/local/bin/cutbuffer (limited to 'dot') diff --git a/dot/local/bin/cutbuffer b/dot/local/bin/cutbuffer old mode 100644 new mode 100755 index 423d974..6921b02 --- a/dot/local/bin/cutbuffer +++ b/dot/local/bin/cutbuffer @@ -1,9 +1,11 @@ -#!/bin/sh +#!/bin/bash dest_basename=cutbuffer_grab dest_extension=txt date_format=+%F_%H%M%S destdir=$HOME/$dest_basename +nameglob=$dest_basename.*.$dest_extension +cutbuffer_count=8 cutbuffer_push() { @@ -14,7 +16,6 @@ cutbuffer_push() cutbuffer_pop() { - nameglob=$dest_basename.*.$dest_extension f=$(find . -maxdepth 1 -type f -name "$nameglob" -print0 | sort -z -V -r | head -z -n 1 | xargs -0) xcb -s 0 < "$f" @@ -24,11 +25,32 @@ cutbuffer_pop() mv "$f" -t .popped } +cutbuffer_menu() +{ + find_any | xargs -0 -x bash -c 'populate "$@"' + xcb -l v +} + +find_any() +{ + find . .popped -maxdepth 1 -type f -name "$nameglob" -printf "%f\t%h/%f\0" | sort -k1 -z -V -r | head -z -n "$cutbuffer_count" | perl -0pe 's/.*?\t//' +} + +populate() +{ + i=0 + for f + do + xcb -s $i < "$f" + let ++i + done +} +export -f populate + set -e mkdir -p "$destdir" cd "$destdir" case "$*" in - pop) cutbuffer_pop ;; - push) cutbuffer_push ;; + push|pop|menu) cutbuffer_$1 ;; esac diff --git a/dot/xbindkeysrc b/dot/xbindkeysrc index 62bc5d7..e9ce1c2 100644 --- a/dot/xbindkeysrc +++ b/dot/xbindkeysrc @@ -84,6 +84,9 @@ control + XF86AudioLowerVolume "cutbuffer pop" alt + Print +"cutbuffer menu" + shift + Print + "scrolltoggle" Scroll_Lock -- cgit v1.2.3