From d923956d4866beb5093c89e0c1a4f54a9c37070f Mon Sep 17 00:00:00 2001 From: Vasil Zlatanov Date: Tue, 18 Aug 2015 01:39:43 +0200 Subject: major fixes and rearrangement --- config/ratpoison/clipboard | 106 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100755 config/ratpoison/clipboard (limited to 'config/ratpoison/clipboard') diff --git a/config/ratpoison/clipboard b/config/ratpoison/clipboard new file mode 100755 index 0000000..093a6d1 --- /dev/null +++ b/config/ratpoison/clipboard @@ -0,0 +1,106 @@ +#!/bin/bash +# +# Clipboard menu +# +# usage: +# clipboard init - clear all buffers +# clipboard menu_paste - pop up a menu to select which buffer to paste +# clipboard menu_set - pop up a menu to select which buffer to save +# the current X selection to +# clipboard paste N - N is buffer 1-9 +# clipboard set N - N is buffer 1-9 +# clipboard push - stack/queue push (push to buffer 1) +# clipboard pop - stack pop (last in first out - pop from buffer 1) +# clipboard pop_queue - queue pop (first in first out - pop from top of stack) +# +# Current stack depth is held in slot 10, and slot 0 is used as temp space for +# stack rotation. +# +command=$1 +option=$2 +source ~/.colors + +function entries() { + # title entry + if [ $command = menu_paste ]; then + echo -n "\"Paste from slot:\" /bin/true " + else + echo -n "\"Yank to slot:\" /bin/true " + fi + + for i in $(seq 1 9); do + repr=$(xcb -p $i | tr '\n$*?"'\''' ' ' | cut --bytes 1-59) + if [ $command = menu_paste ]; then + cmd_item="$0 paste $i" + else + cmd_item="$0 set $i" + fi + #printf '%q %q ' $i "$repr" "$cmd_item" +# echo -n "\"$i: $repr\" \"$cmd_item\" " + echo -n "\"$i:$repr \" \"$cmd_item\" " + done +} + +function menu() { + echo ~/.config/ratpoison/ratmenu -label "\"clipboard $command\"" \ + -style dreary -fg \"$COLOR11\" -bg \"$COLOR0\" -io 2 $(entries) | sh +} + +function get_stack_depth() { + stack_depth=$(xcb -p 10) + echo "stack_depth=$stack_depth" >/dev/stderr +} + +function set_stack_depth() { + echo "setting stack_depth=$1" >/dev/stderr + echo $1 | xcb -n 11 -s 10 +} + +function increment_stack_depth() { + get_stack_depth + set_stack_depth $[ $stack_depth + 1 ] +} + +function decrement_stack_depth() { + get_stack_depth + set_stack_depth $[ $stack_depth - 1 ] +} + +if [ $command = init ]; then + # Clear all buffers + xcb -n 10 -s 0-9