commit 8022250599b60283c783f43d94cfd8cdea3e63e9 Author: ksyasuda Date: Fri Apr 5 00:18:27 2024 -0700 initial commit diff --git a/dexscreener-opener.sh b/dexscreener-opener.sh new file mode 100755 index 0000000..96a71e2 --- /dev/null +++ b/dexscreener-opener.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -Eeuo pipefail + +BROWSER=firefox +PASTE_CMD=wl-paste + +lg() { + printf "\033[1;32m%s\033[0m\n" "$*" +} + +debug() { + printf "\033[1;34m%s\033[0m\n" "$*" >&2 +} + +notify() { + dunstify -u normal -t 3000 "$*" +} + +get_token_name() { + jq -r '.pairs[0].baseToken.name' <<< "$(curl --no-progress-meter "https://api.dexscreener.com/latest/dex/tokens/$1")" +} + +get_ticker() { + jq -r '.pairs[0].baseToken.symbol' <<< "$(curl --no-progress-meter "https://api.dexscreener.com/latest/dex/tokens/$1")" +} + +CONTRACT_ADDRESS="$($PASTE_CMD)" + +if [ -z "$CONTRACT_ADDRESS" ]; then + notify "No contract address in clipboard" + exit 1 +fi + +TOKEN_NAME="$(get_token_name "$CONTRACT_ADDRESS")" +TICKER="$(get_ticker "$CONTRACT_ADDRESS")" + +lg "Opening dexscreener page for $TOKEN_NAME (\$$TICKER)" + +notify "Opening dexscreener page for $TOKEN_NAME (\$$TICKER)" +if ! $BROWSER "https://dexscreener.com/solana/$CONTRACT_ADDRESS"; then + notify "Failed to open browser tab/window" + exit 1 +fi