diff options
| author | Blista Kanjo | 2023-07-18 19:22:58 -0400 |
|---|---|---|
| committer | Blista Kanjo | 2023-07-18 19:22:58 -0400 |
| commit | 4a439d18320b1d993156a99a9796c37dbb055b7c (patch) | |
| tree | adf008387814d02822a7271dd8adb05c2da781e8 /.local/bin | |
| parent | 4366404defb751f8acb35ffa6566664a5ec11f7f (diff) | |
feat: trying out some `dwmblocks`-style widgets
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/awesome-widgets/widget-RAM | 3 | ||||
| -rwxr-xr-x | .local/bin/awesome-widgets/widget-cpu_usage | 31 | ||||
| -rwxr-xr-x | .local/bin/awesome-widgets/widget-disks | 13 | ||||
| -rwxr-xr-x | .local/bin/awesome-widgets/widget-newsboat | 5 | ||||
| -rwxr-xr-x | .local/bin/awesome-widgets/widget-pacman_updates | 9 | ||||
| -rwxr-xr-x | .local/bin/awesome-widgets/widget-sensors | 3 | ||||
| -rwxr-xr-x | .local/bin/awesome-widgets/widget-weather | 3 |
7 files changed, 67 insertions, 0 deletions
diff --git a/.local/bin/awesome-widgets/widget-RAM b/.local/bin/awesome-widgets/widget-RAM new file mode 100755 index 0000000..a6b451c --- /dev/null +++ b/.local/bin/awesome-widgets/widget-RAM @@ -0,0 +1,3 @@ +#!/bin/sh + +free --mebi | sed -n '2{p;q}' | awk '{printf (" 🧠 %2.1fGiB/%2.0fGiB\n", ( $3 / 1024), ($2 / 1024))}' diff --git a/.local/bin/awesome-widgets/widget-cpu_usage b/.local/bin/awesome-widgets/widget-cpu_usage new file mode 100755 index 0000000..14997fd --- /dev/null +++ b/.local/bin/awesome-widgets/widget-cpu_usage @@ -0,0 +1,31 @@ +#!/bin/sh + +# Cache in tmpfs to improve speed and reduce SSD load +cache=/tmp/cpubarscache + +stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) +[ ! -f $cache ] && echo "$stats" > "$cache" +old=$(cat "$cache") +printf " 📊 " +echo "$stats" | while read -r row; do + id=${row%% *} + rest=${row#* } + total=${rest%% *} + idle=${rest##* } + + case "$(echo "$old" | awk '{if ($1 == id) + printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \ + id="$id" total="$total" idle="$idle")" in + + "0") printf "▁";; + "1") printf "▂";; + "2") printf "▃";; + "3") printf "▄";; + "4") printf "▅";; + "5") printf "▆";; + "6") printf "▇";; + "7") printf "█";; + "8") printf "█";; + esac +done; printf "\\n" +echo "$stats" > "$cache" diff --git a/.local/bin/awesome-widgets/widget-disks b/.local/bin/awesome-widgets/widget-disks new file mode 100755 index 0000000..49a5e9c --- /dev/null +++ b/.local/bin/awesome-widgets/widget-disks @@ -0,0 +1,13 @@ +#!/bin/sh + +location=${1:-/} + +[ -d "$location" ] || exit + +case "$location" in + "/home"* ) icon="🏠" ;; + "/mnt"* ) icon="💾" ;; + *) icon="🖥";; +esac + +printf "%s%s" " $icon " "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2 " "} ')" diff --git a/.local/bin/awesome-widgets/widget-newsboat b/.local/bin/awesome-widgets/widget-newsboat new file mode 100755 index 0000000..a3eadf7 --- /dev/null +++ b/.local/bin/awesome-widgets/widget-newsboat @@ -0,0 +1,5 @@ +#!/bin/sh + +newsboat -x reload + +cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print " 📰 " $1 " "}')$(cat "${XDG_CONFIG_HOME:-$HOME/.config}"/newsboat/.update 2>/dev/null)" diff --git a/.local/bin/awesome-widgets/widget-pacman_updates b/.local/bin/awesome-widgets/widget-pacman_updates new file mode 100755 index 0000000..dfd21e4 --- /dev/null +++ b/.local/bin/awesome-widgets/widget-pacman_updates @@ -0,0 +1,9 @@ +#!/bin/sh + +if ! command -v yay >/dev/null 2>&1; then + notify-send "awesomewm widget error" "the 'yay' package is required for the widget to work." +else + yay -Sy >/dev/null + count=$(yay -Qu | wc -l) + echo " 📤 $count" +fi diff --git a/.local/bin/awesome-widgets/widget-sensors b/.local/bin/awesome-widgets/widget-sensors new file mode 100755 index 0000000..248acc0 --- /dev/null +++ b/.local/bin/awesome-widgets/widget-sensors @@ -0,0 +1,3 @@ +#!/bin/sh + +sensors -f | awk '/Core 0/ {print " 🌡" $3}' diff --git a/.local/bin/awesome-widgets/widget-weather b/.local/bin/awesome-widgets/widget-weather new file mode 100755 index 0000000..d48599e --- /dev/null +++ b/.local/bin/awesome-widgets/widget-weather @@ -0,0 +1,3 @@ +#!/bin/sh + +curl -s wttr.in/?format=%c%t |
