dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit a81a8740186d1b9be57f33fc3b376e8e2754180a
parent e02f6e8f350acfc988509fe10ba545c35655ad7b
Author: hhvn <dev@hhvn.uk>
Date:   Fri, 15 Apr 2022 12:37:03 +0100

Use git://hhvn.uk/s2dblocks with dwmbar

Diffstat:
A.scripts/dwmbar/Makefile | 15+++++++++++++++
D.scripts/dwmbar/README | 9---------
D.scripts/dwmbar/bat | 27---------------------------
D.scripts/dwmbar/cal | 13-------------
D.scripts/dwmbar/cpu | 58----------------------------------------------------------
M.scripts/dwmbar/dwmbar | 12++++--------
D.scripts/dwmbar/mail | 4----
D.scripts/dwmbar/mem | 21---------------------
D.scripts/dwmbar/mus | 26--------------------------
D.scripts/dwmbar/net | 9---------
D.scripts/dwmbar/time | 18------------------
D.scripts/dwmbar/time2 | 15---------------
D.scripts/dwmbar/torrent | 17-----------------
D.scripts/dwmbar/vol | 51---------------------------------------------------
14 files changed, 19 insertions(+), 276 deletions(-)

diff --git a/.scripts/dwmbar/Makefile b/.scripts/dwmbar/Makefile @@ -0,0 +1,15 @@ +install: build + install -m0755 blocks/bat bat + install -m0755 blocks/cpu cpu + install -m0755 blocks/mem mem + install -m0755 blocks/vol vol + install -m0755 blocks/date date + install -m0755 blocks/time time + +build: get + [ -d blocks ] && { cd blocks; make; } || false + +get: + [ ! -d blocks ] && { git clone git://hhvn.uk/s2dblocks blocks || exit 1; } || true + +.PHONY: install build get diff --git a/.scripts/dwmbar/README b/.scripts/dwmbar/README @@ -1,9 +0,0 @@ - -[BAT stat] [IP ADDR] [TORRENTS] [CPU usage% tempC] [MEM] [VOL vol%] [DAY DATE] [TIME] - - ^ ^ ^ .---------------^ ^ .-------^ ^ ^-----------. ^ - | | red = no net | S = seeding/uploading | temps go from green | ditto cpu temps | normal = unmuted | green = weekend | white = winter | black = night - | | I = idle | to red as they rise | grey = muted | grey = weekday | yellow = spring | dark blue = twilight - | + = charging | D = downloading | green = summer | pink = day (sunny) - | - = discharching | Q = queued | red = autumn | white = day (cloudy) - | light blue = day (rainy) diff --git a/.scripts/dwmbar/bat b/.scripts/dwmbar/bat @@ -1,27 +0,0 @@ -#!/bin/sh - -total=100 -[ "$(uname)" = "Linux" ] && { - case "$(acpi | awk '{print $3}' | tr -d ',')" in - "Charging") charging=y ;; - "Discharging") discharging=y ;; - esac - charge=$(acpi | awk '{print $NF}' | tr -d ',%') -} - -[ "$(uname)" = "OpenBSD" ] && { - case "$(apm | head -n 2 | tail -n 1 | sed 's/.*: //')" in - "not"*) discharging=y ;; - *) charging=y ;; - esac - charge=$(apm | head -n 1 | sed -E 's/%.*//;s/.*([0-9])/\1/') -} -num=$(echo "scale=2; ($charge/$total)*100" | bc | sed 's~\..*$~~') -[ "$charging" = "y" ] && ind="^c#00aa00^+" -[ $num -ge 98 ] && ind="" -[ "$discharging" = "y" ] && ind="^c#aa0000^-" - -[ "$discharging" != "y" ] && [ $num -ge 50 ] && col="^c#00aa00^" -[ "$discharging" = "y" ] && [ $num -lt 20 ] && col="^c#aa0000^" - -printf '[^c#7777cc^B%s%s%%%s]\n' "${col:-^c#aa7700^}" "$num" "$ind" diff --git a/.scripts/dwmbar/cal b/.scripts/dwmbar/cal @@ -1,13 +0,0 @@ -#!/bin/sh - -get_cal() { - calcurse -D $HOME/.config/calcurse $1 | awk "/$2/" | wc -l -} -todo=$(get_cal -t) -if [ "$todo" = "0" ] -then - todo=$todo -else - todo=$(($todo-1)) -fi -echo "[CAL A:$(get_cal -a "*")/T:$todo]" diff --git a/.scripts/dwmbar/cpu b/.scripts/dwmbar/cpu @@ -1,58 +0,0 @@ -#!/bin/sh - -tempt=$(acpi -t | awk '{s+=$4} END {print s}') -tempc=$(acpi -t | wc -l) -temp=$(($tempt/$tempc)) -temp="$temp" -[ $temp -gt 65 ] && temp="^c#aa0000^$temp" -[ $temp -lt 65 ] && temp="^c#aaaa00^$temp" -[ $temp -lt 55 ] && temp="^c#00aa00^$temp" - -cpu=$( - ( - cat /proc/stat - sleep 1 - cat /proc/stat - ) | awk ' - BEGIN { - pass = 0; - height = 10; # pixels - } - - /intr/ { pass = 1; } - - /^cpu[0-9][0-9]*/ && !pass { - sub(/cpu/, "", $1); - total = 0; - for (i = 2; i <= NF; i++) - total = total + $i; - ctotal[$1] = total; - cidle[$1] = $5; - } - - /^cpu[0-9][0-9]*/ && pass { - sub(/cpu/, "", $1); - total = 0; - for (i = 2; i <= NF; i++) - total += $i; - diff = total - ctotal[$1]; - idle = $5 - cidle[$1]; - used = diff - idle; - decimal = used / diff; - barheight = decimal * height; - - if (decimal > 0.8) - col = "^c#aa0000^"; - else if (decimal > 0.5) - col = "^c#aa7700^"; - else - col = "^c#00aa00^"; - - printf("^c#000000^^r0,2,5,1^^r0,3,1,%d^^f1^%s^r0,%d,3,%d^^c#000000^^r0,12,3,1^^f3^^r0,3,1,%d^^f2^", - height, - col, (height - barheight + 3), barheight, - height); - }' -) - -echo "[^f1^$cpu^d^${temp}C]" diff --git a/.scripts/dwmbar/dwmbar b/.scripts/dwmbar/dwmbar @@ -22,7 +22,6 @@ fn sigexit { } block vol -# block mus while (true) { block bat block cpu @@ -31,20 +30,17 @@ while (true) { } & while (true) { - # block mus - block time2 + block time sleep 1 } & while (true) { - block time - block net + block date sleep 900 } & +printf ' ' > sep while (true) { sleep 0.1 - xsetroot -name ``(''){cat mus bat torrent cpu mem vol time time2 >[2]/dev/null | - tr -d '\n' | - sed 's/^\[/^f4^/;s~\[~^c#000000^^r0,0,1,50^^d^^f4^~g;s~\]~^f4^~g'} + xsetroot -name ``(''){cat bat sep cpu sep mem sep vol sep date sep time sep >[2]/dev/null | tr -d '\n'} } diff --git a/.scripts/dwmbar/mail b/.scripts/dwmbar/mail @@ -1,4 +0,0 @@ -#!/bin/sh -read LINE < /tmp/mail -[ "$LINE" = '' ] && exit 1 -echo "[$LINE]" diff --git a/.scripts/dwmbar/mem b/.scripts/dwmbar/mem @@ -1,21 +0,0 @@ -#!/bin/sh -# Copyright (c) 2019-2021 Hayden Hamilton. - -[ "$(uname)" = "Linux" ] && { - mem=$(free -h | awk '{print $3 "/" $2}' | head -n 2 | tail -n 1) - echo "$mem" | grep 'Mi/' >/dev/null && col="^c#00aa00^" - echo "$mem" | grep '1\.[0-4]Gi/' >/dev/null && col="^c#aaaa00^" - echo "$mem" | grep '1\.[5-9]Gi/' >/dev/null && col="^c#aa7700^" - echo "$mem" | grep '2\..Gi/' >/dev/null && col="^c#aa0000^" -} -[ "$(uname)" = "OpenBSD" ] && { - total=$(dmesg | grep "^real mem" | awk '{print $5}' | tr -d 'MB()') - avail=$(dmesg | grep "^avail mem" | awk '{print $5}' | tr -d 'MB()') - used=$(echo "$total - $avail" | bc) - mem="${used}M/${avail}M" - [ $used -le 1000 ] && col="^c#00aa00^" - [ $used -gt 1000 ] && col="^c#aaaa00^" - [ $used -gt 1500 ] && col="^c#aa7700^" - [ $used -gt 2000 ] && col="^c#aa0000^" -} -echo "[^c#7777cc^M^d^${col}${mem}]" diff --git a/.scripts/dwmbar/mus b/.scripts/dwmbar/mus @@ -1,26 +0,0 @@ -#!/bin/rc - -cmus-remote -Q | awk ' -/status paused/ { - print "[^c#7777cc^Paused]" - exit(1) -} - -/^tag/ { - name = $0 - sub(/[^ ]* /, "", name) - sub(/ .*/, "", name) - sub(/[^ ]* [^ ]* /, "") - metadata[name] = $0 - p = 1 -} - -END { - if (p == 1) { - printf("[%s - %s - %s. %s]", - metadata["artist"], - metadata["album"], - metadata["tracknumber"], - metadata["title"]) - } -}' | tee curtxt diff --git a/.scripts/dwmbar/net b/.scripts/dwmbar/net @@ -1,9 +0,0 @@ -#!/bin/sh -# -# haydenvh.com -# Copyright (c) 2019 Hayden Hamilton. - -ip=$(curl -s gopher://hlirc.net/0/ip.cgi || echo "^c#aa0000^no net...") -[ -z $ip ] && exit -ip=$(echo "$ip" | tail -n 1) -echo "[$ip]" diff --git a/.scripts/dwmbar/time b/.scripts/dwmbar/time @@ -1,18 +0,0 @@ -#!/bin/sh - -echo $(curl wttr.in/?format=%D) > $HOME/.cache/wttrD -echo $(curl wttr.in/?format=%d) > $HOME/.cache/wttrd -echo $(curl wttr.in/?format=%S) > $HOME/.cache/wttrS -echo $(curl wttr.in/?format=%s) > $HOME/.cache/wttrs -echo $(curl wttr.in/?format=%C) > $HOME/.cache/wttrC - -day=$(date +%a | tr '[:lower:]' '[:upper:]') -[ $(date +%u) -eq 6 ] || [ $(date +%u) -eq 7 ] && col="^c#007700^" || col="^c#888888^" - -month=$(date +%m) -[ $month -ge 3 ] && [ $month -le 5 ] && col2="^c#aaaa00^" #spring -[ $month -ge 6 ] && [ $month -le 7 ] && col2="^c#00aa00^" # summer -[ $month -ge 8 ] && [ $month -le 11 ] && col2="^c#a61028^" # autumn -[ $month -eq 12 ] || [ $month -eq 1 ] || [ $month -eq 2 ] && col2="^c#cccccc^" # winter - -printf "[%s%s%s%s]" "$col" "$day" "$col2" "$(date +%d/%m)" diff --git a/.scripts/dwmbar/time2 b/.scripts/dwmbar/time2 @@ -1,15 +0,0 @@ -#!/bin/sh - -currdate=$(date +%H:%M:%S) -datediff $(cat $HOME/.cache/wttrD) $currdate | grep '^-' >/dev/null && col="^c#000000^" -datediff $(cat $HOME/.cache/wttrd) $currdate | grep -v '^-' >/dev/null && col="^c#000000^" - -[ "$col" = "" ] && { - <$HOME/.cache/wttrC grep -Ei 'clear|sun' >/dev/null && col="^c#eeaaaa^" - <$HOME/.cache/wttrC grep -Ei 'rain|shower' >/dev/null && col="^c#8888ee^" - datediff $(cat $HOME/.cache/wttrS) $currdate | grep '^-' >/dev/null && col="^c#000099^" - datediff $(cat $HOME/.cache/wttrs) $currdate | grep -v '^-' >/dev/null && col="^c#000099^" -} -[ "$col" = "" ] && col="^c#cccccc^" - -echo "[${col}${currdate}]" diff --git a/.scripts/dwmbar/torrent b/.scripts/dwmbar/torrent @@ -1,17 +0,0 @@ -#!/bin/sh - -pgrep transmission >/dev/null || { - echo '[^c#cc0000^none]' - exit 1 -} - -transmission-remote -l | sed 's/Up & Down/Updown/' | awk '$8 != "Status" && $8 != ""' \ - | sed 's/.*Seeding/Seeding/;s/.*Updown/Downloading\nSeeding/; - s/.*Downloading/Downloading/;s/.*Idle/Idle/;s/.*Queued/Queued/; - s/.*Stopped/Stopped/' | awk '{print $1}' | sort | uniq -c | tr '\n' ' ' \ - | sed 's/ /|/g' | tr -s ' |' | sed 's/|/ |/g;s/^ |/[^c#aaaaaa^/;s/ $/] /;' | sed -E ' - s/([0-9]*) Downloading/^c#892b2b^\1D^c#aaaaaa^/; - s/ Idle/I/; - s/ Queued/Q/; - s/([0-9]*) Seeding/^c#3fc1ce^\1S^c#aaaaaa^/; - s/([0-9]*) Stopped/^c#777b8e^\1N^c#aaaaaa^/;' diff --git a/.scripts/dwmbar/vol b/.scripts/dwmbar/vol @@ -1,51 +0,0 @@ -#!/bin/sh -# Copyright (c) 2019-2021 Hayden Hamilton. - -[ "$(uname)" = "Linux" ] && { - toggled=$(amixer sget Master | awk '/Mono/ {print $6}' | tr -d '[]\n') - volume=$(amixer sget Master | awk '/Mono/ {print $4}' | tr -d '[]\n') -} -[ "$(uname)" = "OpenBSD" ] && { - toggled=$(sndioctl output.mute | sed 's/.*=//;s/0/on/;s/1/off/' | tr -d '\n') - volume=$(sndioctl output.level | sed -E 's/.*=//;s/(.)\.(..)(.)/\1\2.\3/;s/^0*//;s/\.0$//;s/$/%/' | tr -d '\n') -} - -echo "$toggled" | grep on >/dev/null && { -icon=" - - - # - #### # # -# # # # # -# # # # # -# # # # # -# # # # # -# # # # # - #### # # - #" -} || { -icon=" - - - - #### -# # # # -# # # # -# # # -# # # # -# # # # - ####" -} - -printf '%s' "[" -printf '%s' "$icon" | awk ' - BEGIN { line = 0; } - { - split($0, chars, ""); - for (i=1; i <= length($0); i++) - if (chars[i] == "#") - printf("^r%d,%d,1,1^", i, line); - line++; - }' - -printf '^f14^%s]\n' "$volume"