summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2021-09-14 02:01:26 -0400
committerAndrew Cady <d@jerkface.net>2021-09-14 02:01:26 -0400
commit2fcc9ad27c5f2d8ca58df22eb7f9920c634b279c (patch)
tree1b5d1ae5d6a9657c264dc9d6fa8e61ab1292e13f
parentf2068c96072753bfd60c0f089a4ed3c7a5d96e21 (diff)
cutbuffer stack feature partially implemented
-rwxr-xr-xdot/local/bin/cutbuffer_pop81
-rwxr-xr-xdot/local/bin/cutbuffer_push68
-rw-r--r--dot/xbindkeysrc6
3 files changed, 155 insertions, 0 deletions
diff --git a/dot/local/bin/cutbuffer_pop b/dot/local/bin/cutbuffer_pop
new file mode 100755
index 0000000..6b314e5
--- /dev/null
+++ b/dot/local/bin/cutbuffer_pop
@@ -0,0 +1,81 @@
1#!/bin/sh
2
3# A screen-grab will be saved in $SCREEN_GRAB_DEST_DIR if set, otherwise
4# in $HOME/screen_grab/ if it exsts; otherwise $HOME.
5
6default_basename=cutbuffer_grab
7default_extension=txt
8date_format=+%F_%H%M%S
9SCREEN_GRAB_DEST_DIR=$HOME/$default_basename
10
11chdir_to_destination()
12{
13 [ -d "$SCREEN_GRAB_DEST_DIR" ] || mkdir -p "$SCREEN_GRAB_DEST_DIR"
14 cd "$SCREEN_GRAB_DEST_DIR"
15}
16
17choose_destination()
18{
19 local stamp basename extension now
20 case $# in
21 1) ;;
22 0) now=$(date "$date_format")
23 DESTINATION=$default_basename.$now.$default_extension
24 return
25 ;;
26 *) return 1 ;;
27 esac
28
29 case "$1" in
30 *.*)
31 basename=${1%.*}
32 extension=${1##*.}
33 ;;
34 *)
35 basename=$1
36 extension=$default_extension
37 ;;
38 esac
39 DESTINATION=$basename.$extension
40}
41
42get_out_the_way()
43{
44 local stamp basename extension destination
45 [ -e "$1" ] || return 0
46
47 stamp=$(date -r "$1" "$date_format") || return
48 case "$1" in
49 *.*)
50 basename=${1%.*}
51 extension=${1##*.}
52 destination=$basename.$stamp.$extension
53 ;;
54 *)
55 destination=$1.$stamp
56 ;;
57 esac
58 [ ! -e "$destination" ] || return
59 mv "$1" "$destination"
60}
61
62extract()
63{
64 sort -z -k1,1 -r | head -z -n 1 | xargs -0 printf '%s\n' | cut -d' ' -f2
65}
66
67
68set -e
69
70chdir_to_destination
71
72f=$(find . -maxdepth 1 -type f -printf "%C@ %h/%f\0" | extract)
73
74set -x
75exec 2> /tmp/cbp.log
76
77xcb -s 0 < "$f"
78xcb -p 0 | xsel
79mkdir -p .popped
80mv "$f" -t .popped
81
diff --git a/dot/local/bin/cutbuffer_push b/dot/local/bin/cutbuffer_push
new file mode 100755
index 0000000..f7e1e69
--- /dev/null
+++ b/dot/local/bin/cutbuffer_push
@@ -0,0 +1,68 @@
1#!/bin/sh
2
3# A screen-grab will be saved in $SCREEN_GRAB_DEST_DIR if set, otherwise
4# in $HOME/screen_grab/ if it exsts; otherwise $HOME.
5
6default_basename=cutbuffer_grab
7default_extension=txt
8date_format=+%F_%H%M%S
9SCREEN_GRAB_DEST_DIR=$HOME/$default_basename
10
11chdir_to_destination()
12{
13 [ -d "$SCREEN_GRAB_DEST_DIR" ] || mkdir -p "$SCREEN_GRAB_DEST_DIR"
14 cd "$SCREEN_GRAB_DEST_DIR"
15}
16
17choose_destination()
18{
19 local stamp basename extension now
20 case $# in
21 1) ;;
22 0) now=$(date "$date_format")
23 DESTINATION=$default_basename.$now.$default_extension
24 return
25 ;;
26 *) return 1 ;;
27 esac
28
29 case "$1" in
30 *.*)
31 basename=${1%.*}
32 extension=${1##*.}
33 ;;
34 *)
35 basename=$1
36 extension=$default_extension
37 ;;
38 esac
39 DESTINATION=$basename.$extension
40}
41
42get_out_the_way()
43{
44 local stamp basename extension destination
45 [ -e "$1" ] || return 0
46
47 stamp=$(date -r "$1" "$date_format") || return
48 case "$1" in
49 *.*)
50 basename=${1%.*}
51 extension=${1##*.}
52 destination=$basename.$stamp.$extension
53 ;;
54 *)
55 destination=$1.$stamp
56 ;;
57 esac
58 [ ! -e "$destination" ] || return
59 mv "$1" "$destination"
60}
61
62set -e
63
64chdir_to_destination
65choose_destination "$@"
66get_out_the_way "$DESTINATION"
67xcb -p 0 > "$DESTINATION"
68
diff --git a/dot/xbindkeysrc b/dot/xbindkeysrc
index 2ddcd5b..ec4eb9d 100644
--- a/dot/xbindkeysrc
+++ b/dot/xbindkeysrc
@@ -78,6 +78,12 @@ control + XF86AudioLowerVolume
78"im" 78"im"
79 Print 79 Print
80 80
81"cutbuffer_push"
82 control + Print
83
84"cutbuffer_pop"
85 alt + Print
86
81"scrolltoggle" 87"scrolltoggle"
82 Scroll_Lock 88 Scroll_Lock
83 89