Last active
July 4, 2026 11:51
-
-
Save Vonr/1814a7840a65a21013bad6607c2bc06c to your computer and use it in GitHub Desktop.
Rofi dmenu dialog for Ringboard (SUPERCILEX/clipboard-history)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| tmp="$(mktemp --suffix '.ringboard')" | |
| if [ "$?" -ne 0 ]; then | |
| exit 1 | |
| fi | |
| trap "rm -rf \"$tmp\"" EXIT | |
| menu() { | |
| selection="$(rofi -dmenu -sep '\0' -p 'Ringboard' -format 'i')" | |
| if [ "$?" -eq "1" ]; then | |
| exit 1 | |
| fi | |
| tmp2="$(mktemp --suffix '.ringboard')" | |
| if [ "$?" -ne 0 ]; then | |
| exit 1 | |
| fi | |
| trap "rm -rf \"$tmp2\"" EXIT | |
| ringboard last "$selection" > "$tmp2" | |
| target="$(file --mime-type "$tmp2" | awk '{ print $NF }')" | |
| if [ "$target" = "text/plain" ]; then | |
| # Using substitution to remove trailing newline | |
| printf '%s' "$(< "$tmp2")" | xsel -i -b | |
| else | |
| xclip -t "$target" -se c -i "$tmp2" > /dev/null | |
| fi | |
| } | |
| idx=0 | |
| size="$(sed -nE 's/^main = ([0-9]+)/\1/gp' "$HOME/.local/share/clipboard-history/config.toml" 2>/dev/null)" | |
| if [ "$?" -ne "0" ]; then | |
| size=131070 | |
| fi | |
| while [ "$idx" -lt "$size" ]; do | |
| if ! ringboard last "$idx" > "$tmp" 2>/dev/null | |
| then | |
| break | |
| fi | |
| idx="$((idx+1))" | |
| target="$(file --mime-type "$tmp" | awk '{ print $NF }')" | |
| if [ "$target" = "text/plain" ] | |
| then | |
| printf '%s\0' "$(< "$tmp")" | |
| else | |
| printf '<%s> (%s bytes)\0' "$target" "$(wc -c "$tmp" | awk '{ print $1 }')" | |
| fi | |
| done | menu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment