#!/usr/bin/env bash cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/linkhandler" store_file="$cache_dir/store" [ -d "$cache_dir" ] || mkdir -p "$cache_dir" if [ -f "$store_file" ]; then mapfile -d '' store_urls < "$store_file" urls=( "${store_urls[@]}" "$@" ) else urls=( "$@" ) fi command="$(dmenu -p "${#urls[@]} $(printf "%.50s" "${1#*://}")..." <> "$HOME/Syncthing/Markor/laptop_share.md" ;; store) for link in "${urls[@]}" do printf "%s\0" "$link" done > "$store_file" exit ;; store_clear) ;; *) exit esac [ -f "$store_file" ] && rm "$store_file"