summaryrefslogtreecommitdiff
path: root/.local/bin/desktop/edit-graphical-buffer
blob: 10eac8fbf958ae4dca7df5d716d4334ce0396ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

sleep 0.5
xdotool key --clearmodifiers ctrl+a ctrl+c
content="$(xclip -o -sel clipboard)"

tempfile=/tmp/scratch-buffer/$$.txt
mkdir -pv /tmp/scratch-buffer
echo "$content" | tee "$tempfile" > "$tempfile.bak"
${TERMINAL:-xdg-terminal-exec} -c dropdown_buffer -e nvim "$tempfile"

diff "$tempfile" "$tempfile.bak" >/dev/null || {
	xclip -sel clipboard < "$tempfile"
	xdotool key --clearmodifiers ctrl+a ctrl+v
}

rm -f "$tempfile" "$tempfile.bak"