WIP clipboard stupidity and screenshot url update
This commit is contained in:
parent
0e87a22283
commit
de4d852795
8 changed files with 62 additions and 32 deletions
1
Makefile
1
Makefile
|
@ -1,5 +1,6 @@
|
||||||
MAKEFILE_PATH ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
MAKEFILE_PATH ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
all: install
|
||||||
default: install
|
default: install
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
20
bin/clipshot
20
bin/clipshot
|
@ -1,16 +1,30 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
umask 077
|
||||||
|
d="$(date +"%Y-%m-%d_%H-%M-%S")"
|
||||||
|
fn="$SCROTS_PATH/clipshot_$d.png"
|
||||||
|
|
||||||
if is_wayland; then
|
if is_wayland; then
|
||||||
grim -g "$(slurp -d)" - | wl-copy
|
dim="$(slurp -d)"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
grim -g "$dim" - | wl-copy
|
||||||
|
wl-paste -n > "$fn"
|
||||||
|
echo "$fn"
|
||||||
|
# grim -g "$dim" - | tee "$fn" | wl-copy -f
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
pkill unclutter
|
pkill unclutter
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
fn="$SCROTS_PATH/clipshot_$(date +"%Y-%m-%d_%H-%M-%S").png"
|
|
||||||
import "$fn"
|
import "$fn"
|
||||||
chmod 700 "$fn"
|
|
||||||
< "$fn" xclip -t image/png -i -selection clipboard
|
< "$fn" xclip -t image/png -i -selection clipboard
|
||||||
< "$fn" xclip -t image/png -i -selection primary
|
< "$fn" xclip -t image/png -i -selection primary
|
||||||
< "$fn" xclip -t image/png -i -selection secondary
|
< "$fn" xclip -t image/png -i -selection secondary
|
||||||
< "$fn" xclip -t image/png -i -selection buffer-cut
|
< "$fn" xclip -t image/png -i -selection buffer-cut
|
||||||
unclutter &
|
unclutter &
|
||||||
|
echo "$fn"
|
||||||
fi
|
fi
|
||||||
|
set -x
|
||||||
|
|
15
bin/fzf-history-weight
Executable file
15
bin/fzf-history-weight
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
rf="$1" # history count record file
|
||||||
|
cf="$1" # all choices file
|
||||||
|
|
||||||
|
touch "$record"
|
||||||
|
app="$(
|
||||||
|
< "$rf" awk 'NF{NF--};1' | cat - "$cf" | \
|
||||||
|
sort | uniq -c | sort -nr | \
|
||||||
|
sd '^\s+' '' | \
|
||||||
|
cut -d' ' -f2- | \
|
||||||
|
fzf
|
||||||
|
)"
|
||||||
|
echo "$app $(date +%s)" >> "$LAUNCHER_HISTORY_FILE"
|
||||||
|
echo "$app"
|
8
bin/fzfp
8
bin/fzfp
|
@ -6,7 +6,11 @@ FZFP_PASS_DIR="$HOME/.password-store"
|
||||||
FZFP_HEIGHT="${FZFP_HEIGHT:-40%}"
|
FZFP_HEIGHT="${FZFP_HEIGHT:-40%}"
|
||||||
FZFP_PROMPT="${FZFP_PROMPT:-"$FZFP_PASS_CMD@$FZFP_PASS_DIR> "}"
|
FZFP_PROMPT="${FZFP_PROMPT:-"$FZFP_PASS_CMD@$FZFP_PASS_DIR> "}"
|
||||||
FZFP_PASS_OPTS="${FZFP_PASS_OPTS:-}"
|
FZFP_PASS_OPTS="${FZFP_PASS_OPTS:-}"
|
||||||
|
|
||||||
cd "$FZFP_PASS_DIR" || { echo "Could not cd to $FZFP_PASS_DIR" >&2; exit 1; }
|
cd "$FZFP_PASS_DIR" || { echo "Could not cd to $FZFP_PASS_DIR" >&2; exit 1; }
|
||||||
pp="$(fd gpg | sd ".gpg" "" | fzf --height "$FZFP_HEIGHT" --prompt "$FZFP_PROMPT")"
|
|
||||||
"${FZFP_PASS_CMD}" $FZFP_PASS_OPTS "$@" "$pp"
|
# TODO: weighted history (see ./launch)
|
||||||
|
"${FZFP_PASS_CMD}" $FZFP_PASS_OPTS "$@" \
|
||||||
|
"$(fd gpg | sd ".gpg" "" | fzf --height "$FZFP_HEIGHT" --prompt "$FZFP_PROMPT")"
|
||||||
|
|
||||||
cd - >/dev/null || return 1
|
cd - >/dev/null || return 1
|
||||||
|
|
|
@ -1,15 +1,3 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# TODO: can we use fzfp here?
|
env WAYLAND_DEBUG=1 FZFP_HEIGHT="100%" floating-term bash -c "fzfp | head -n 1 | wl-copy &"
|
||||||
floating-term \
|
|
||||||
bash -c "
|
|
||||||
cd $HOME/.password-store
|
|
||||||
fd gpg |
|
|
||||||
sd '.gpg\$' '' |
|
|
||||||
fzf --height 100% --prompt 'fzf-pass> ' > /tmp/fzfp-key
|
|
||||||
pass \"\$(cat /tmp/fzfp-key)\" |
|
|
||||||
head -n 1 |
|
|
||||||
sd '\s+\$' '' |
|
|
||||||
nohup clip &>/dev/null &
|
|
||||||
notify-send -a 'pass' 'Password in Clipboard'
|
|
||||||
"
|
|
||||||
|
|
22
bin/scrup
22
bin/scrup
|
@ -1,9 +1,19 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
f="${HOME}/.scrup.png"
|
set -x
|
||||||
|
|
||||||
pkill unclutter
|
remote_dir="scrots"
|
||||||
sleep 0.1
|
url_prefix="https://files.lyte.dev/$remote_dir"
|
||||||
import "${f}"
|
|
||||||
upload "${f}" "scrup-$(date +%Y-%m-%d_%H-%M-%S).png" "scrots"
|
u="$(uuid -v4)"
|
||||||
unclutter &
|
d="$(date +%Y-%m-%d_%H-%M-%S)"
|
||||||
|
|
||||||
|
fn="$(clipshot)"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Scrot captured. Uploading..."
|
||||||
|
upload "${fn}" "scrup-$u-$d.png" "$remote_dir"
|
||||||
|
echo "$url_prefix/scrup-$u-$d.png" | clip
|
||||||
|
notify-send "Scrot uploaded. URL in clipboard."
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
12
bin/upload
12
bin/upload
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
# TODO: progress bar!
|
# TODO: progress bar!
|
||||||
|
|
||||||
HOST="ld"
|
HOST="faceless"
|
||||||
|
|
||||||
f="${1}"
|
f="${1}"
|
||||||
fname="${2:-$(basename "${f}")}"
|
fname="${2:-$(basename "${f}")}"
|
||||||
subdir="${3:-uploads}"
|
subdir="${3:-uploads}"
|
||||||
internal_dir="/home/daniel/services/data/files/${subdir}"
|
internal_dir="/home/daniel/files/${subdir}"
|
||||||
url="https://lyte.dev/${subdir}/${fname}"
|
url="https://files.lyte.dev/${subdir}/${fname}"
|
||||||
|
|
||||||
[ "${f}" = "" ] && echo "No file provided. Exiting." >&2 && exit 2
|
[ "${f}" = "" ] && echo "No file provided. Exiting." >&2 && exit 2
|
||||||
[ ! -f "${f}" ] && echo "File '$f' does not exist. Exiting." >&2 && exit 1
|
[ ! -f "${f}" ] && echo "File '$f' does not exist. Exiting." >&2 && exit 1
|
||||||
|
@ -18,11 +18,9 @@ if [ "$(curl -s -o /dev/null -w "%{http_code}" "${url}")" -eq 200 ]; then
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh ld mkdir -p "${internal_dir}"
|
ssh "$HOST" mkdir -p "${internal_dir}"
|
||||||
rsync --progress --no-owner --no-group --no-perms --stats --ignore-existing "${f}" "${HOST}:${internal_dir}/${fname}" | tee "${HOME}/.upload.log"
|
rsync --progress --no-owner --no-group --chmod=644 --ignore-existing "${f}" "${HOST}:${internal_dir}/${fname}" | tee "${HOME}/.upload.log"
|
||||||
code="$?"
|
code="$?"
|
||||||
# shellcheck disable=SC2029
|
|
||||||
ssh ld chmod a+r "${internal_dir}/${fname}"
|
|
||||||
echo "Uploaded to: ${url}"
|
echo "Uploaded to: ${url}"
|
||||||
|
|
||||||
if [ "$code" -ne 0 ]; then
|
if [ "$code" -ne 0 ]; then
|
||||||
|
|
|
@ -61,5 +61,5 @@ cd '~/.config/dotfiles' && ./setup.bash # follow the instructions!
|
||||||
|
|
||||||
[upstream]: https://git.faceless.lytedev.io/lytedev/dotfiles
|
[upstream]: https://git.faceless.lytedev.io/lytedev/dotfiles
|
||||||
[github]: https://github.com/lytedev/dotfiles
|
[github]: https://github.com/lytedev/dotfiles
|
||||||
[desktop-screenshot]: https://lyte.dev/unix/desktop-screenshot.png
|
[desktop-screenshot]: https://files.lyte.dev/unix/desktop-screenshot.png
|
||||||
[1]: https://smallstep.com/blog/ssh-tricks-and-tips/
|
[1]: https://smallstep.com/blog/ssh-tricks-and-tips/
|
||||||
|
|
Reference in a new issue