local-bin/common/twitnit.sh

21 lines
525 B
Bash
Executable File

#!/bin/sh
# Requires xsel
if ! xsel --version &>/dev/null || ! notify-send --version &>/dev/null; then
echo "Make sure this machien has xsel and notify-send"
exit
fi
# Make sure naked domain is at end
m=("mobile.twitter.com" "m.twitter.com" "twitter.com")
r="nitter.eu"
clip=$(xsel -p -l /tmp/xsel.log)
for f in ${m[@]}; do
echo "looking for $f"
if echo "$clip" | grep "$f"; then
echo "Found!"
clip=$(echo $clip | sed -e "s/${f}/${r}/g" | tr -d '\n' | xsel -ib)
notify-send -a TwitNit "Changed $f to $r"
fi
done