From 39fa1856a488dc35f1d6d1c84ec3c378b77979ff Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Mon, 9 Jul 2018 15:34:49 +0100 Subject: [PATCH] Replace nameservers block with dns block that can do multiple types of dns lookup --- i3/blocks/dns | 33 +++++++++++++++++++++++++++++++++ i3/blocks/nameservers | 18 ------------------ 2 files changed, 33 insertions(+), 18 deletions(-) create mode 100755 i3/blocks/dns delete mode 100755 i3/blocks/nameservers diff --git a/i3/blocks/dns b/i3/blocks/dns new file mode 100755 index 00000000..9a41997b --- /dev/null +++ b/i3/blocks/dns @@ -0,0 +1,33 @@ +#!/usr/bin/sh + + +case $BLOCK_BUTTON in + 1) + echo "HI" + echo "HI" + echo "" + exit 0 + ;; +esac + +LOOKUP="a" +if [ ! -z "$2" ]; then + LOOKUP="$2" +fi + +COLOR="" + +NAMESERVERS=$(drill "$LOOKUP" "$1" | sed -ne '/ANSWER SECTION/,/AUTHORITY SECTION/ p' | head -n -2 | tail -n +2 | awk '{ print $5" " }' | xargs echo) + +if [ ! -z "$3" ]; then + if [ "$NAMESERVERS" = "$3" ]; then + COLOR="#00FF00" + else + COLOR="#FF8000" + fi +fi + +echo "$NAMESERVERS" +echo "$NAMESERVERS" +echo "$COLOR" + diff --git a/i3/blocks/nameservers b/i3/blocks/nameservers deleted file mode 100755 index 0dbed38d..00000000 --- a/i3/blocks/nameservers +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/sh - -#drill ns racingblue.com | sed -ne '/ANSWER SECTION/,/AUTHORITY SECTION/ p' - -case $BLOCK_BUTTON in - 1) - echo "HI" - echo "HI" - echo "" - exit 0 - ;; -esac - -NAMESERVERS=$(drill ns "$1" | sed -ne '/ANSWER SECTION/,/AUTHORITY SECTION/ p' | head -n -2 | tail -n +2 | awk '{ print $5" " }' | xargs echo) - -echo "$NAMESERVERS" -echo "$NAMESERVERS" -echo ""