From 84089d6b3f1b05b6d3022e260e2943b23374475a Mon Sep 17 00:00:00 2001 From: samedamci Date: Mon, 18 Jan 2021 15:22:42 +0100 Subject: [PATCH] Update statusbar scripts --- .local/bin/scripts/dwmbar/crypto | 61 ------------------ .local/bin/scripts/dwmbar/internet | 13 ---- .local/bin/scripts/dwmbar/lamp | 6 -- .local/bin/scripts/dwmbar/news | 9 --- .../{dwmbar/alsa => statusbar/sb-alsa} | 6 +- .../{dwmbar/clock => statusbar/sb-clock} | 1 - .../{dwmbar/date => statusbar/sb-date} | 1 - .../{dwmbar/disk => statusbar/sb-disk} | 1 - .local/bin/scripts/statusbar/sb-internet | 5 ++ .../{dwmbar/mails => statusbar/sb-mails} | 0 .local/bin/scripts/statusbar/sb-minexmr | 62 +++++++++++++++++++ .../{dwmbar/music => statusbar/sb-music} | 10 +-- .../packages => statusbar/sb-packages} | 2 +- .../{dwmbar/torrent => statusbar/sb-torrent} | 0 14 files changed, 73 insertions(+), 104 deletions(-) delete mode 100755 .local/bin/scripts/dwmbar/crypto delete mode 100755 .local/bin/scripts/dwmbar/internet delete mode 100755 .local/bin/scripts/dwmbar/lamp delete mode 100755 .local/bin/scripts/dwmbar/news rename .local/bin/scripts/{dwmbar/alsa => statusbar/sb-alsa} (87%) rename .local/bin/scripts/{dwmbar/clock => statusbar/sb-clock} (75%) rename .local/bin/scripts/{dwmbar/date => statusbar/sb-date} (72%) rename .local/bin/scripts/{dwmbar/disk => statusbar/sb-disk} (93%) create mode 100755 .local/bin/scripts/statusbar/sb-internet rename .local/bin/scripts/{dwmbar/mails => statusbar/sb-mails} (100%) create mode 100755 .local/bin/scripts/statusbar/sb-minexmr rename .local/bin/scripts/{dwmbar/music => statusbar/sb-music} (55%) rename .local/bin/scripts/{dwmbar/packages => statusbar/sb-packages} (60%) rename .local/bin/scripts/{dwmbar/torrent => statusbar/sb-torrent} (100%) diff --git a/.local/bin/scripts/dwmbar/crypto b/.local/bin/scripts/dwmbar/crypto deleted file mode 100755 index a3e9530..0000000 --- a/.local/bin/scripts/dwmbar/crypto +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 - -import subprocess -import json - - -def __LBC(): - try: - data = subprocess.run( - ["lbrynet", "account", "list"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - if data.stderr != b"": - return None - data = json.loads(data.stdout) - balance: float = 0 - for i in range(len(data["items"])): - d = data["items"][i]["coins"] - balance += float(d) - return round(balance, 1) - except json.decoder.JSONDecodeError: - return None - - -def __DOGE(): - try: - data = subprocess.run( - ["dogecoin-cli", "getbalance"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - if data.stderr != b"": - return None - balance = json.loads(data.stdout) - return round(balance, 1) - except json.decoder.JSONDecodeError: - return None - - -def __BTC(): - try: - data = subprocess.run( - ["bitcoin-cli", "getbalance"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - if data.stderr != b"": - return None - balance = json.loads(data.stdout) - return round(balance, 1) - except json.decoder.JSONDecodeError: - return None - - -def main(): - print(f" LBC: {__LBC()}, DOGE: {__DOGE()}, BTC: {__BTC()}") - - -if __name__ == "__main__": - main() diff --git a/.local/bin/scripts/dwmbar/internet b/.local/bin/scripts/dwmbar/internet deleted file mode 100755 index f4578dd..0000000 --- a/.local/bin/scripts/dwmbar/internet +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -if [ "$(cat /etc/hostname)" = "pc" ]; then - ip="$(eth-ip)" - echo "" -elif [ "$(cat /etc/hostname)" = "laptop" ]; then - ip="$(wifi-ip)" - echo "" -fi - -ping -q -c 1 1.1.1.1 >/dev/null || { echo "dis" && exit 1; } - -echo "$ip" diff --git a/.local/bin/scripts/dwmbar/lamp b/.local/bin/scripts/dwmbar/lamp deleted file mode 100755 index c213258..0000000 --- a/.local/bin/scripts/dwmbar/lamp +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -status=$(curl -s 192.168.1.201/status.php) - -echo "" -[ "$status" = 1 ] && echo "" || echo "" diff --git a/.local/bin/scripts/dwmbar/news b/.local/bin/scripts/dwmbar/news deleted file mode 100755 index 446b0d6..0000000 --- a/.local/bin/scripts/dwmbar/news +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -icon="$(cat "/tmp/newsupdate" 2>/dev/null)" - -unread="$(cat "$HOME/.cache/news_unread" 2>/dev/null)" - -printf "" -[ "$unread" ] && printf " %s" "$unread" -echo "$icon" diff --git a/.local/bin/scripts/dwmbar/alsa b/.local/bin/scripts/statusbar/sb-alsa similarity index 87% rename from .local/bin/scripts/dwmbar/alsa rename to .local/bin/scripts/statusbar/sb-alsa index 5e792f4..ee5dcda 100755 --- a/.local/bin/scripts/dwmbar/alsa +++ b/.local/bin/scripts/statusbar/sb-alsa @@ -13,11 +13,11 @@ v2="" v3="" if [ "$revel" -lt 35 ]; then - echo "$v1" + printf "$v1 " elif [ "$revel" -lt 60 ]; then - echo "$v2" + printf "$v2 " elif [ "$revel" -lt 100 ]; then - echo "$v3" + printf "$v3 " fi echo "$level" diff --git a/.local/bin/scripts/dwmbar/clock b/.local/bin/scripts/statusbar/sb-clock similarity index 75% rename from .local/bin/scripts/dwmbar/clock rename to .local/bin/scripts/statusbar/sb-clock index ba2c4c1..1bb4062 100755 --- a/.local/bin/scripts/dwmbar/clock +++ b/.local/bin/scripts/statusbar/sb-clock @@ -1,4 +1,3 @@ #!/usr/bin/env sh -echo "" date "+%H:%M" diff --git a/.local/bin/scripts/dwmbar/date b/.local/bin/scripts/statusbar/sb-date similarity index 72% rename from .local/bin/scripts/dwmbar/date rename to .local/bin/scripts/statusbar/sb-date index 1e801f3..34f8690 100755 --- a/.local/bin/scripts/dwmbar/date +++ b/.local/bin/scripts/statusbar/sb-date @@ -1,4 +1,3 @@ #!/bin/sh -echo "" date "+%a, %d-%m" diff --git a/.local/bin/scripts/dwmbar/disk b/.local/bin/scripts/statusbar/sb-disk similarity index 93% rename from .local/bin/scripts/dwmbar/disk rename to .local/bin/scripts/statusbar/sb-disk index 328126b..198ff7b 100755 --- a/.local/bin/scripts/dwmbar/disk +++ b/.local/bin/scripts/statusbar/sb-disk @@ -7,5 +7,4 @@ used() { root="$(used /)" home="$(used /home)" -echo "" echo "/ $root,  $home" diff --git a/.local/bin/scripts/statusbar/sb-internet b/.local/bin/scripts/statusbar/sb-internet new file mode 100755 index 0000000..8d1b387 --- /dev/null +++ b/.local/bin/scripts/statusbar/sb-internet @@ -0,0 +1,5 @@ +#!/bin/sh + +ping -q -c 1 1.1.1.1 >/dev/null || { echo "dis" && exit 1; } + +eth-ip diff --git a/.local/bin/scripts/dwmbar/mails b/.local/bin/scripts/statusbar/sb-mails similarity index 100% rename from .local/bin/scripts/dwmbar/mails rename to .local/bin/scripts/statusbar/sb-mails diff --git a/.local/bin/scripts/statusbar/sb-minexmr b/.local/bin/scripts/statusbar/sb-minexmr new file mode 100755 index 0000000..5dccc1e --- /dev/null +++ b/.local/bin/scripts/statusbar/sb-minexmr @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 + +import requests +import json + +API = "https://beta.minexmr.com/api" + + +class ctx(object): + addr = "47XzeAyPKPBevVHZucf8vYZjZqtf7322hRP3VrwQf3cnP9HvLf9Qh12H9sZxcA7BnHBmnmJVvH13rjH5Ggadysji162m4do" + + +def get_balance(): + resp = requests.get(f"{API}/main/user/stats?address={ctx.addr}") + bal = int(json.loads(resp.text)["balance"]) * 0.000000000001 + return round(bal, 6) + + +def get_PLN(): + price = json.loads( + requests.get( + "https://api.coingecko.com/api/v3/simple/price?ids=monero&vs_currencies=pln" + ).text + )["monero"]["pln"] + + return round(price * get_balance(), 2) + + +def get_workers(): + resp = requests.get(f"{API}/main/user/workers?address={ctx.addr}") + data = json.loads(resp.text) + workers = [] + for i in data: + if i["hashrate"] > 0: + workers.append([i["name"], i["hashrate"]]) + return workers + + +def get_hashrate(worker: str = False) -> int: + workers = get_workers() + if worker: + for i in workers: + if i[0] == worker: + return int(i[1]) + return None + else: + sum_ = 0 + for i in workers: + sum_ += int(i[1]) + return sum_ # h/s + + +def main(): + bal = get_balance() + pln = get_PLN() + hashrate = get_hashrate() + workers = len(get_workers()) + print(f"{bal} XMR ({pln} PLN), HR: {hashrate} h/s,  {workers}") + + +if __name__ == "__main__": + main() diff --git a/.local/bin/scripts/dwmbar/music b/.local/bin/scripts/statusbar/sb-music similarity index 55% rename from .local/bin/scripts/dwmbar/music rename to .local/bin/scripts/statusbar/sb-music index dfcc2b9..31d4350 100755 --- a/.local/bin/scripts/dwmbar/music +++ b/.local/bin/scripts/statusbar/sb-music @@ -1,11 +1,5 @@ #!/bin/sh -if playerctl metadata --format={{playerName}} | grep -q "spotifyd"; then - echo "" -else - echo "" -fi - # if mpc status | grep -q "playing"; then # mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[playing\\].*//g" # elif mpc status | grep -q "paused"; then @@ -14,9 +8,9 @@ fi # echo "" # fi -if playerctl --player=spotifyd status | grep -q "Playing"; then +if playerctl --player=spotify status | grep -q "Playing"; then playerctl metadata --format "{{ artist }} - {{ title }}" -elif playerctl --player=spotifyd status | grep -q "Paused"; then +elif playerctl --player=spotify status | grep -q "Paused"; then echo "" else echo "" diff --git a/.local/bin/scripts/dwmbar/packages b/.local/bin/scripts/statusbar/sb-packages similarity index 60% rename from .local/bin/scripts/dwmbar/packages rename to .local/bin/scripts/statusbar/sb-packages index 489234e..9c10c4f 100755 --- a/.local/bin/scripts/dwmbar/packages +++ b/.local/bin/scripts/statusbar/sb-packages @@ -1,4 +1,4 @@ #!/bin/sh icon="$(cat /tmp/packagesupdate 2>/dev/null)" -echo " $(pacman -Qu | wc -l)$icon" +echo "$(pacman -Qu | wc -l)$icon" diff --git a/.local/bin/scripts/dwmbar/torrent b/.local/bin/scripts/statusbar/sb-torrent similarity index 100% rename from .local/bin/scripts/dwmbar/torrent rename to .local/bin/scripts/statusbar/sb-torrent