This script requires that clipman, rofi, and dmenu is installed. All you need to do is change the location of the clipman history file and the name/location of the rofi theme file.
As part of your niri configuration, add the following line to use clipman:
spawn-sh-at-startup “wl-paste -t text –watch clipman store –no-persist”
#!/bin/bash
FILE="/home/karmst/.local/share/clipman.json"
ROFI_THEME="fzf_finder.rasi"
ARGS="-config ~/.config/rofi/themes/$ROFI_THEME -dmenu -l 25"
function list () {
case "$choice" in
Now)
cmd=$(clipman restore && wtype -M ctrl -M shift v)
;;
Copy)
cmd=$(clipman pick -t rofi --tool-args="$ARGS" --err-on-no-selection && wtype -M ctrl -M shift c)
;;
Paste)
cmd=$(clipman pick -t rofi --tool-args="$ARGS" --err-on-no-selection && wtype -M ctrl -M shift v)
;;
List)
cmd=$(clipman pick -t rofi --tool-args="$ARGS")
;;
Delete)
old=1
new=0
while [ $new -lt $old ]
do
old=$(cat $FILE | jq ".[] | length" | wc -l)
cmd=$(clipman clear -t rofi --tool-args="$ARGS")
new=$(cat $FILE | jq ".[] | length" | wc -l)
done
;;
Wipe)
cmd=$(clipman clear -a)
;;
esac
}
function display_first () {
if [[ -f "$FILE" ]]; then
choice=$(echo -e "Now\nPaste\nCopy\nList\nDelete\nWipe" | rofi -dmenu -p "Clipboard action" $ARGS)
list
else
dunstify -t 2500 "There is nothing currently in the clipboard"
fi
}
display_first
RET=$?
while [ $RET -eq 1 ]
do
display_first
RET=$?
done
exit 0