summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2021-09-14 12:46:17 -0400
committerAndrew Cady <d@jerkface.net>2021-09-14 12:46:17 -0400
commit88417264e401a75ab5566d6ae317ac424bf4a5cf (patch)
tree6afe90e66f5204841a8d15d442118115bcb0eadf
parent6d505fc790ee719cbf7bac03121b006eb74dcb05 (diff)
cutbuffer: add menu; key bound to shift-PrtSc
-rwxr-xr-x[-rw-r--r--]dot/local/bin/cutbuffer30
-rw-r--r--dot/xbindkeysrc3
2 files changed, 29 insertions, 4 deletions
diff --git a/dot/local/bin/cutbuffer b/dot/local/bin/cutbuffer
index 423d974..6921b02 100644..100755
--- a/dot/local/bin/cutbuffer
+++ b/dot/local/bin/cutbuffer
@@ -1,9 +1,11 @@
1#!/bin/sh 1#!/bin/bash
2dest_basename=cutbuffer_grab 2dest_basename=cutbuffer_grab
3dest_extension=txt 3dest_extension=txt
4date_format=+%F_%H%M%S 4date_format=+%F_%H%M%S
5 5
6destdir=$HOME/$dest_basename 6destdir=$HOME/$dest_basename
7nameglob=$dest_basename.*.$dest_extension
8cutbuffer_count=8
7 9
8cutbuffer_push() 10cutbuffer_push()
9{ 11{
@@ -14,7 +16,6 @@ cutbuffer_push()
14 16
15cutbuffer_pop() 17cutbuffer_pop()
16{ 18{
17 nameglob=$dest_basename.*.$dest_extension
18 f=$(find . -maxdepth 1 -type f -name "$nameglob" -print0 | sort -z -V -r | head -z -n 1 | xargs -0) 19 f=$(find . -maxdepth 1 -type f -name "$nameglob" -print0 | sort -z -V -r | head -z -n 1 | xargs -0)
19 20
20 xcb -s 0 < "$f" 21 xcb -s 0 < "$f"
@@ -24,11 +25,32 @@ cutbuffer_pop()
24 mv "$f" -t .popped 25 mv "$f" -t .popped
25} 26}
26 27
28cutbuffer_menu()
29{
30 find_any | xargs -0 -x bash -c 'populate "$@"'
31 xcb -l v
32}
33
34find_any()
35{
36 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//'
37}
38
39populate()
40{
41 i=0
42 for f
43 do
44 xcb -s $i < "$f"
45 let ++i
46 done
47}
48export -f populate
49
27set -e 50set -e
28mkdir -p "$destdir" 51mkdir -p "$destdir"
29cd "$destdir" 52cd "$destdir"
30case "$*" in 53case "$*" in
31 pop) cutbuffer_pop ;; 54 push|pop|menu) cutbuffer_$1 ;;
32 push) cutbuffer_push ;;
33esac 55esac
34 56
diff --git a/dot/xbindkeysrc b/dot/xbindkeysrc
index 62bc5d7..e9ce1c2 100644
--- a/dot/xbindkeysrc
+++ b/dot/xbindkeysrc
@@ -84,6 +84,9 @@ control + XF86AudioLowerVolume
84"cutbuffer pop" 84"cutbuffer pop"
85 alt + Print 85 alt + Print
86 86
87"cutbuffer menu"
88 shift + Print
89
87"scrolltoggle" 90"scrolltoggle"
88 Scroll_Lock 91 Scroll_Lock
89 92