From 16874b6716a2f040077cac61b08cf3b21ec74fc6 Mon Sep 17 00:00:00 2001 From: Gregory Chamberlain Date: Sun, 31 May 2020 20:10:53 +0100 Subject: [PATCH 1/8] Remove unnecessary double quotes --- .local/bin/statusbar/nettraf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf index c9b003f1..6972b7e4 100755 --- a/.local/bin/statusbar/nettraf +++ b/.local/bin/statusbar/nettraf @@ -4,18 +4,18 @@ # transmitted (TX) since the previous time this script ran. So if run every # second, gives network traffic per second. -case "$BLOCK_BUTTON" in +case $BLOCK_BUTTON in 3) notify-send "🌐 Network traffic module" "🔻: Traffic received 🔺: Traffic transmitted" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -logfile="${XDG_CACHE_HOME:-$HOME/.cache}/netlog" +logfile=${XDG_CACHE_HOME:-$HOME/.cache}/netlog [ -f "$logfile" ] || echo "0 0" > "$logfile" read -r rxprev txprev < "$logfile" -rxcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/rx_bytes)))" -txcurrent="$(($(paste -d '+' /sys/class/net/[ew]*/statistics/tx_bytes)))" +rxcurrent=$(($(paste -d '+' /sys/class/net/[ew]*/statistics/rx_bytes))) +txcurrent=$(($(paste -d '+' /sys/class/net/[ew]*/statistics/tx_bytes))) printf "🔻%dKiB 🔺%dKiB\\n" "$(((rxcurrent-rxprev)/1024))" "$(((txcurrent-txprev)/1024))" From 63aef514d7b6e0793c01989a58eb0529d56052d9 Mon Sep 17 00:00:00 2001 From: Gregory Chamberlain Date: Sun, 31 May 2020 20:30:52 +0100 Subject: [PATCH 2/8] Refactor nettraf No longer relies on paste(1p). --- .local/bin/statusbar/nettraf | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf index 6972b7e4..42da6d07 100755 --- a/.local/bin/statusbar/nettraf +++ b/.local/bin/statusbar/nettraf @@ -10,13 +10,19 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -logfile=${XDG_CACHE_HOME:-$HOME/.cache}/netlog -[ -f "$logfile" ] || echo "0 0" > "$logfile" -read -r rxprev txprev < "$logfile" +update() { + sum=0 + for arg; do + read -r i < "$arg" + sum=$(( "$sum" + "$i" )) + done + cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/} + [ -f "$cache" ] && read -r old < "$cache" || old=0 + printf %d\\n "$sum" > "$cache" + printf %d\\n $(( ("$sum" - "$old") / 1024 )) +} -rxcurrent=$(($(paste -d '+' /sys/class/net/[ew]*/statistics/rx_bytes))) -txcurrent=$(($(paste -d '+' /sys/class/net/[ew]*/statistics/tx_bytes))) +rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes) +tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes) -printf "🔻%dKiB 🔺%dKiB\\n" "$(((rxcurrent-rxprev)/1024))" "$(((txcurrent-txprev)/1024))" - -echo "$rxcurrent $txcurrent" > "$logfile" +printf "🔻%dKiB 🔺%dKiB\\n" "$rx" "$tx" From 43f0f899ae4a0134930830fbccf7af614c87c92e Mon Sep 17 00:00:00 2001 From: Gregory Chamberlain Date: Sun, 31 May 2020 21:26:05 +0100 Subject: [PATCH 3/8] Fix arithmetic expansions --- .local/bin/statusbar/nettraf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf index 42da6d07..fa9eb300 100755 --- a/.local/bin/statusbar/nettraf +++ b/.local/bin/statusbar/nettraf @@ -14,12 +14,12 @@ update() { sum=0 for arg; do read -r i < "$arg" - sum=$(( "$sum" + "$i" )) + sum=$(( $sum + $i )) done cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/} [ -f "$cache" ] && read -r old < "$cache" || old=0 printf %d\\n "$sum" > "$cache" - printf %d\\n $(( ("$sum" - "$old") / 1024 )) + printf %d\\n $(( ($sum - $old) / 1024 )) } rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes) From 88dfd0afe9df8b613e292f2e288d9b775735c9b5 Mon Sep 17 00:00:00 2001 From: Hekuran <62762955+narukeh@users.noreply.github.com> Date: Mon, 1 Jun 2020 23:45:47 +0200 Subject: [PATCH 4/8] cleaning (#677) making it a variable since its used 5 times --- .local/bin/statusbar/weather | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.local/bin/statusbar/weather b/.local/bin/statusbar/weather index 9a6c40ab..e04bac0b 100755 --- a/.local/bin/statusbar/weather +++ b/.local/bin/statusbar/weather @@ -6,17 +6,18 @@ # If we have internet, get a weather report from wttr.in and store it locally. # You could set up a shell alias to view the full file in a pager in the # terminal if desired. This function will only be run once a day when needed. -getforecast() { curl -sf "wttr.in/$LOCATION" > "${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" || exit 1 ;} +weatherreport="${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" +getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;} # Some very particular and terse stream manipulation. We get the maximum # precipication chance and the daily high and low from the downloaded file and # display them with coresponding emojis. -showweather() { printf "%s" "$(sed '16q;d' "${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" | +showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" | grep -wo "[0-9]*%" | sort -rn | sed "s/^/☔/g;1q" | tr -d '\n')" -sed '13q;d' "${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶" $1 "°","🌞" $2 "°"}' ;} +sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " 🥶" $1 "°","🌞" $2 "°"}' ;} case $BLOCK_BUTTON in - 1) setsid -f "$TERMINAL" -e less -Srf "${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" ;; + 1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;; 2) getforecast && showweather ;; 3) notify-send "🌈 Weather module" "\- Left click for full forecast. - Middle click to update forecast. @@ -28,7 +29,7 @@ esac # The test if our forcecast is updated to the day. If it isn't download a new # weather report from wttr.in with the above function. -[ "$(stat -c %y "${XDG_DATA_HOME:-$HOME/.local/share}/weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || +[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || getforecast showweather From 0df700f504cedeac1ae354c650ea80b32ab7668c Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 2 Jun 2020 12:45:26 -0400 Subject: [PATCH 5/8] nettraf --- .local/bin/statusbar/nettraf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/statusbar/nettraf b/.local/bin/statusbar/nettraf index fa9eb300..ac434165 100755 --- a/.local/bin/statusbar/nettraf +++ b/.local/bin/statusbar/nettraf @@ -14,12 +14,12 @@ update() { sum=0 for arg; do read -r i < "$arg" - sum=$(( $sum + $i )) + sum=$(( sum + i )) done cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/} [ -f "$cache" ] && read -r old < "$cache" || old=0 printf %d\\n "$sum" > "$cache" - printf %d\\n $(( ($sum - $old) / 1024 )) + printf %d\\n $(( (sum - old) / 1024 )) } rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes) From 78be66e28ed7346e841d7557a0a6e4b7a0cd7e72 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 2 Jun 2020 12:47:20 -0400 Subject: [PATCH 6/8] fix --- .local/bin/rotdir | 2 +- .local/bin/sysact | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/rotdir b/.local/bin/rotdir index 7d320409..7313a424 100755 --- a/.local/bin/rotdir +++ b/.local/bin/rotdir @@ -9,4 +9,4 @@ [ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1 base="$(basename "$1")" -find "$PWD" | awk "BEGIN { lines = \"\"; m = 0; } /^$base$/ { m = 1; } { if (!m) { if (lines) { lines = lines\"\n\"; } lines = lines\"\"\$0; } else { print \$0; } } END { print lines; }" + ls "$PWD" | awk "BEGIN { lines = \"\"; m = 0; } /^$base$/ { m = 1; } { if (!m) { if (lines) { lines = lines\"\n\"; } lines = lines\"\"\$0; } else { print \$0; } } END { print lines; }" diff --git a/.local/bin/sysact b/.local/bin/sysact index ce925ce1..0a7cdd02 100755 --- a/.local/bin/sysact +++ b/.local/bin/sysact @@ -18,4 +18,4 @@ cmds="\ choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1 -echo "$cmds" | grep "^$choice " | cut -d ' ' -f2- +`echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-` From 84db80292adbb227a55fafd1595853eda2f6466f Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 2 Jun 2020 15:22:23 -0400 Subject: [PATCH 7/8] funding file for github sponsors --- FUNDING.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 FUNDING.yml diff --git a/FUNDING.yml b/FUNDING.yml new file mode 100644 index 00000000..5b856dc9 --- /dev/null +++ b/FUNDING.yml @@ -0,0 +1,5 @@ +github: lukesmithxyz +custom: "https://lukesmith.xyz/donate" +custom: "https://paypal.me/lukemsmith" +patreon: lukesmith +custom: "https://lukesmith.xyz/crypto" From 32e0623424c5b7de4c83523d87302ce1de12a1c6 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 2 Jun 2020 15:33:56 -0400 Subject: [PATCH 8/8] boomer futilely attempts to understand soydev ui --- FUNDING.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/FUNDING.yml b/FUNDING.yml index 5b856dc9..f8e60767 100644 --- a/FUNDING.yml +++ b/FUNDING.yml @@ -1,5 +1,3 @@ github: lukesmithxyz -custom: "https://lukesmith.xyz/donate" -custom: "https://paypal.me/lukemsmith" +custom: ["https://lukesmith.xyz/donate", "https://paypal.me/lukemsmith", "https://lukesmith.xyz/crypto"] patreon: lukesmith -custom: "https://lukesmith.xyz/crypto"