#!/bin/sh

# $1 = "explicit" or "match"
# $2 = URL

# Save all links to a file for debugging (and, yeah, to have a history).
linkhist=/tmp/xiate-link-history-$USER/history
install -dm0700 "$(dirname "$linkhist")"
printf "%s [%s] [%s]\n" "$(date)" "$1" "$2" >>"$linkhist"

printf "%s" "$2" | xclip -selection clipboard

notify-send -u low  -t 5000 -a xiate-link-handler "copied link to clipboard" "$(printf "%s" "$2")"
