From 720e104f55b7d0b60059a3b1daeb948206b6ae31 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Sat, 18 Jan 2025 12:39:25 -0500 Subject: [PATCH] Dexscreener MC --- aliases/key_dirs.tmpl | 2 +- .../i3blocks/i3blocks-secondary.conf.tmpl | 11 +++--- dot_config/i3blocks/i3blocks.conf.tmpl | 15 +++++--- .../scripts/executable_dexscreener-mc | 6 ++++ .../i3blocks/scripts/executable_spotify | 6 ++-- scripts/executable_dexscreener-mc | 24 +++++++++++++ scripts/executable_spotify-now | 34 +++++++++++++++++++ 7 files changed, 85 insertions(+), 13 deletions(-) create mode 100755 dot_config/i3blocks/scripts/executable_dexscreener-mc create mode 100755 scripts/executable_dexscreener-mc create mode 100755 scripts/executable_spotify-now diff --git a/aliases/key_dirs.tmpl b/aliases/key_dirs.tmpl index cdf1522..eebf3d0 100644 --- a/aliases/key_dirs.tmpl +++ b/aliases/key_dirs.tmpl @@ -51,7 +51,7 @@ cn ~/coding drk ~/coding/dark-sky ffx ~/linux-config/dot_config/fish/functions hbd ~/.habitctl -ib ~/linux-config/dot_config/i3blocks/scripts +ib ~/linux-config/dot_config/i3blocks mbd ~/coding/minikube pig ~/coding/pigallery mbk ~/coding/minikube-kompose diff --git a/dot_config/i3blocks/i3blocks-secondary.conf.tmpl b/dot_config/i3blocks/i3blocks-secondary.conf.tmpl index e0e49fd..ffef76d 100755 --- a/dot_config/i3blocks/i3blocks-secondary.conf.tmpl +++ b/dot_config/i3blocks/i3blocks-secondary.conf.tmpl @@ -36,16 +36,17 @@ interval=2 # volume/spotify [[[ # -# [spotify] -# # command=python ~/linux-config/configs/i3blocks-scripts/spotify.py -# # label= -# label= +[spotify] +#command=python ~/linux-config/configs/i3blocks-scripts/spotify.py +command=/home/kevin/.config/i3blocks/scripts/spotify +# label= +label= # # label=🎧 # # green # # color=#198c19 # # aqua # # color=#2d7272 -# interval=5 +interval=5 # [spotify] # label= diff --git a/dot_config/i3blocks/i3blocks.conf.tmpl b/dot_config/i3blocks/i3blocks.conf.tmpl index 12cc2a1..5b6d012 100755 --- a/dot_config/i3blocks/i3blocks.conf.tmpl +++ b/dot_config/i3blocks/i3blocks.conf.tmpl @@ -65,6 +65,11 @@ label=PIXL command=/home/kevin/.config/i3blocks/scripts/dexscreener ethereum 0x31c0ba10e4e12be6cdceb612e5e829d977532bfc interval=30 +[dexscreener-mc] +label=TRUMP +command=/home/kevin/.config/i3blocks/scripts/dexscreener-mc solana a8nphpcjqtqhdquk35uj9hy2ysgxfkczgunwvkd3k7vc +interval=30 + [kraken] label=ETH #TICKER=ETHUSDC @@ -78,11 +83,11 @@ label=PENGU command=/home/kevin/.config/i3blocks/scripts/dexscreener solana B4Vwozy1FGtp8SELXSXydWSzavPUGnJ77DURV2k4MhUV interval=5 -[kraken] -label=AVAX -#TICKER=AVAXUSD -command=/home/kevin/.config/i3blocks/scripts/kraken AVAXUSD -interval=30 +#[kraken] +#label=AVAX +##TICKER=AVAXUSD +#command=/home/kevin/.config/i3blocks/scripts/kraken AVAXUSD +#interval=30 #[dexscreener] #label=LOCK diff --git a/dot_config/i3blocks/scripts/executable_dexscreener-mc b/dot_config/i3blocks/scripts/executable_dexscreener-mc new file mode 100755 index 0000000..1aef6c0 --- /dev/null +++ b/dot_config/i3blocks/scripts/executable_dexscreener-mc @@ -0,0 +1,6 @@ +#!/bin/bash + +. "/home/kevin/.cache/wal/colors.sh" +#ticker=$(~/scripts/dexscreener $CHAIN $PAIR) +ticker=$(~/scripts/dexscreener-mc $1 $2) +printf "%s\n\n%s\n" "$ticker" "$color7" diff --git a/dot_config/i3blocks/scripts/executable_spotify b/dot_config/i3blocks/scripts/executable_spotify index 71836bb..b929ac3 100755 --- a/dot_config/i3blocks/scripts/executable_spotify +++ b/dot_config/i3blocks/scripts/executable_spotify @@ -9,6 +9,8 @@ case "$BLOCK_BUTTON" in esac . "/home/kevin/.cache/wal/colors.sh" -long_title=$(spotify-now -i "$LONG_NAME" -p '' -e '' | sed 's/&/&/g') -short_title=$(spotify-now -i "$SHORT_NAME" -p '' -e '' | sed 's/&/&/g') +#long_title=$(spotify-now -i "$LONG_NAME" -p '' -e '' | sed 's/&/&/g') +#short_title=$(spotify-now -i "$SHORT_NAME" -p '' -e '' | sed 's/&/&/g') +long_title=$(spotify-now) +short_title=$(spotify-now) printf "$long_title\n$short_title\n%s\n" "$color7" diff --git a/scripts/executable_dexscreener-mc b/scripts/executable_dexscreener-mc new file mode 100755 index 0000000..6cfc4fd --- /dev/null +++ b/scripts/executable_dexscreener-mc @@ -0,0 +1,24 @@ +# /bin/bash + +# curl -s https://api.dexscreener.com/latest/dex/pairs/$1/$2| jq -r '.pairs | .[] | .priceUsd' +#raw=$(curl -s "https://api.dexscreener.com/latest/dex/pairs/$1/$2") +#price=$(echo "$raw" | jq '.pairs[0].marketCap / 1000000000 | . as $marketCap | "\($marketCap | floor).$(($marketCap * 10 | floor % 10))"') +#price=$(echo "$raw" | jq -r '.pairs[0].marketCap / 1000000000 | "\(floor).\( (. * 10 | floor % 10) )B"') +#curl -s "https://api.dexscreener.com/latest/dex/pairs/$1/$2" | jq -r '.pairs[0].marketCap / 1000000000 | "\(floor).\( (. * 10 | floor % 10) )"' +curl -s "https://api.dexscreener.com/latest/dex/pairs/$1/$2" | jq -r '.pairs[0].marketCap / 1000000000 | "\(floor).\( (. * 10 | floor % 10) )"' | jq -r 'tostring | gsub("\\.";"")' + +# if (( $(echo "$price < .05" | bc -l) )); then + # printf "%0.4f\n" "$price" | cut -c 4- +# elif (( $(echo "$price < .1" | bc -l) )); then + # printf "%0.3f\n" "$price" | cut -c 4- +#if (( $(echo "$price < .09" | bc -l) )); then + #printf "%0.4f\n" "$price" | cut -c 4- +#elif (( $(echo "$price < .1" | bc -l) )); then + #printf "%0.3f\n" "$price" | cut -c 4- +#elif (( $(echo "$price < 1" | bc -l) )); then + #printf "%0.3f\n" "$price" | cut -c 3- +#elif (( $(echo "$price < 10" | bc -l) )); then + #printf "%0.2f\n" "$price" +#fi + + diff --git a/scripts/executable_spotify-now b/scripts/executable_spotify-now new file mode 100755 index 0000000..b3aa14c --- /dev/null +++ b/scripts/executable_spotify-now @@ -0,0 +1,34 @@ +#!/usr/bin/python + +import dbus +import os +import sys + + +try: + bus = dbus.SessionBus() + spotify = bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2") + + + if os.environ.get('BLOCK_BUTTON'): + control_iface = dbus.Interface(spotify, 'org.mpris.MediaPlayer2.Player') + if (os.environ['BLOCK_BUTTON'] == '1'): + control_iface.Previous() + elif (os.environ['BLOCK_BUTTON'] == '2'): + control_iface.PlayPause() + elif (os.environ['BLOCK_BUTTON'] == '3'): + control_iface.Next() + + spotify_iface = dbus.Interface(spotify, 'org.freedesktop.DBus.Properties') + props = spotify_iface.Get('org.mpris.MediaPlayer2.Player', 'Metadata') + + if (sys.version_info > (3, 0)): + print(str(props['xesam:artist'][0]) + " - " + str(props['xesam:title'])) + else: + print(props['xesam:artist'][0] + " - " + props['xesam:title']).encode('utf-8') + exit +except dbus.exceptions.DBusException: + exit + + +