diff --git a/Makefile b/Makefile index f2feca5..ffed8b5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ MAKEFILE_PATH ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +all: install default: install install: diff --git a/bin/clipshot b/bin/clipshot index 1e663ab..033999e 100755 --- a/bin/clipshot +++ b/bin/clipshot @@ -1,16 +1,30 @@ #!/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 - 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 pkill unclutter sleep 0.1 - fn="$SCROTS_PATH/clipshot_$(date +"%Y-%m-%d_%H-%M-%S").png" import "$fn" - chmod 700 "$fn" < "$fn" xclip -t image/png -i -selection clipboard < "$fn" xclip -t image/png -i -selection primary < "$fn" xclip -t image/png -i -selection secondary < "$fn" xclip -t image/png -i -selection buffer-cut unclutter & + echo "$fn" fi +set -x diff --git a/bin/fzf-history-weight b/bin/fzf-history-weight new file mode 100755 index 0000000..f5e3ff7 --- /dev/null +++ b/bin/fzf-history-weight @@ -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" diff --git a/bin/fzfp b/bin/fzfp index 83d0943..9204aad 100755 --- a/bin/fzfp +++ b/bin/fzfp @@ -6,7 +6,11 @@ FZFP_PASS_DIR="$HOME/.password-store" FZFP_HEIGHT="${FZFP_HEIGHT:-40%}" FZFP_PROMPT="${FZFP_PROMPT:-"$FZFP_PASS_CMD@$FZFP_PASS_DIR> "}" FZFP_PASS_OPTS="${FZFP_PASS_OPTS:-}" + 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 diff --git a/bin/pass-chooser b/bin/pass-chooser index f36e334..f870783 100755 --- a/bin/pass-chooser +++ b/bin/pass-chooser @@ -1,15 +1,3 @@ #!/usr/bin/env sh -# TODO: can we use fzfp here? -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' - " +env WAYLAND_DEBUG=1 FZFP_HEIGHT="100%" floating-term bash -c "fzfp | head -n 1 | wl-copy &" diff --git a/bin/scrup b/bin/scrup index fb18a17..6aabed8 100755 --- a/bin/scrup +++ b/bin/scrup @@ -1,9 +1,19 @@ #!/usr/bin/env bash -f="${HOME}/.scrup.png" +set -x -pkill unclutter -sleep 0.1 -import "${f}" -upload "${f}" "scrup-$(date +%Y-%m-%d_%H-%M-%S).png" "scrots" -unclutter & +remote_dir="scrots" +url_prefix="https://files.lyte.dev/$remote_dir" + +u="$(uuid -v4)" +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 diff --git a/bin/upload b/bin/upload index 1cc7063..00970aa 100755 --- a/bin/upload +++ b/bin/upload @@ -2,13 +2,13 @@ # TODO: progress bar! -HOST="ld" +HOST="faceless" f="${1}" fname="${2:-$(basename "${f}")}" subdir="${3:-uploads}" -internal_dir="/home/daniel/services/data/files/${subdir}" -url="https://lyte.dev/${subdir}/${fname}" +internal_dir="/home/daniel/files/${subdir}" +url="https://files.lyte.dev/${subdir}/${fname}" [ "${f}" = "" ] && echo "No file provided. Exiting." >&2 && exit 2 [ ! -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 fi -ssh ld mkdir -p "${internal_dir}" -rsync --progress --no-owner --no-group --no-perms --stats --ignore-existing "${f}" "${HOST}:${internal_dir}/${fname}" | tee "${HOME}/.upload.log" +ssh "$HOST" mkdir -p "${internal_dir}" +rsync --progress --no-owner --no-group --chmod=644 --ignore-existing "${f}" "${HOST}:${internal_dir}/${fname}" | tee "${HOME}/.upload.log" code="$?" -# shellcheck disable=SC2029 -ssh ld chmod a+r "${internal_dir}/${fname}" echo "Uploaded to: ${url}" if [ "$code" -ne 0 ]; then diff --git a/readme.md b/readme.md index 6e58e88..6c82ca9 100644 --- a/readme.md +++ b/readme.md @@ -61,5 +61,5 @@ cd '~/.config/dotfiles' && ./setup.bash # follow the instructions! [upstream]: https://git.faceless.lytedev.io/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/