From b31f48d09f786af5c1a3eb8bfb52cfb0490bda28 Mon Sep 17 00:00:00 2001 From: Piotr Russ Date: Thu, 3 Dec 2020 01:02:31 +0100 Subject: init comit --- README.md | 2 ++ arch-update | 4 ++++ backlight | 3 +++ battery | 8 ++++++++ bluetooth | 5 +++++ disk | 4 ++++ mail | 4 ++++ memory | 2 ++ mount | 3 +++ screenshot.jpg | Bin 0 -> 7786 bytes volume | 3 +++ wifi | 15 +++++++++++++++ 12 files changed, 53 insertions(+) create mode 100755 arch-update create mode 100755 backlight create mode 100755 battery create mode 100755 bluetooth create mode 100755 disk create mode 100755 mail create mode 100755 memory create mode 100755 mount create mode 100644 screenshot.jpg create mode 100755 volume create mode 100755 wifi diff --git a/README.md b/README.md index 7613eee..3bb1067 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # status-blocks Scripts that I use with DWM status bar +[status-blocks](screenshot.jpg) +*All scripts are POSIX compliant* diff --git a/arch-update b/arch-update new file mode 100755 index 0000000..dc09fef --- /dev/null +++ b/arch-update @@ -0,0 +1,4 @@ +#!/bin/sh +UPDATES=$(checkupdates | wc -l) +[ $UPDATES -ge 100 ] && COLOR=$(echo '\003') || COLOR='' +printf "%s%s%s\001" $COLOR " " "$UPDATES" diff --git a/backlight b/backlight new file mode 100755 index 0000000..53c9369 --- /dev/null +++ b/backlight @@ -0,0 +1,3 @@ +#!/usr/bin/sh +BRIGHTNESS=$(xbacklight -get | awk '{print int($1)}') +echo "☀ ${BRIGHTNESS}%" diff --git a/battery b/battery new file mode 100755 index 0000000..1df6222 --- /dev/null +++ b/battery @@ -0,0 +1,8 @@ +#!/bin/sh +BATTERY="/sys/class/power_supply/BAT0/" +CAPACITY=$(cat "$BATTERY"/capacity 2>/dev/null) || break +STATUS=$(sed "s/[Dd]ischarging/ /;s/[Nn]ot charging/ /;s/[Cc]harging/ /;s/[Uu]nknown/ /;s/[Ff]ull/ /" "$BATTERY"/status) +[ $CAPACITY -le 20 ] && COLOR=$(echo '\004') || COLOR='' +[ $CAPACITY -gt 20 ] && [ $CAPACITY -le 40 ] && COLOR=$(echo '\003') +[ $CAPACITY -ge 98 ] && CAPACITY=100 +printf "%s%s%s%%\001" $COLOR "$STATUS" "$CAPACITY" diff --git a/bluetooth b/bluetooth new file mode 100755 index 0000000..7354fc3 --- /dev/null +++ b/bluetooth @@ -0,0 +1,5 @@ +#!/bin/sh +STATUS=$(systemctl is-active bluetooth) +[ "$STATUS" != "active" ] && exit +HEADPHONES=$(bluetoothctl info 38:18:4C:59:C1:B0 | grep "Connected: yes") +if [ "$HEADPHONES" ]; then echo "\003\001"; else echo "\003\001"; fi; diff --git a/disk b/disk new file mode 100755 index 0000000..21e6a02 --- /dev/null +++ b/disk @@ -0,0 +1,4 @@ +#!/bin/sh +AVAIL=$(df -h --output=avail '/' | tail -1) +[ ${AVAIL%?} -le 50 ] && COLOR=$(echo '\004') || COLOR='' +printf '%s%s%s\001' $COLOR " " $AVAIL diff --git a/mail b/mail new file mode 100755 index 0000000..0fe7836 --- /dev/null +++ b/mail @@ -0,0 +1,4 @@ +#!/bin/sh +NEW_MAIL="$(find "$HOME/.local/share/mail/$1/INBOX/new/" -type f 2> /dev/null | wc -l)" +[ $NEW_MAIL -gt 0 ] && COLOR=$(echo '\003') || COLOR='' +printf '%s%s%s\001' $COLOR " $2" $NEW_MAIL diff --git a/memory b/memory new file mode 100755 index 0000000..614fe47 --- /dev/null +++ b/memory @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +free -m | awk 'NR==2{print "", $3, "MB"}' diff --git a/mount b/mount new file mode 100755 index 0000000..4af9435 --- /dev/null +++ b/mount @@ -0,0 +1,3 @@ +#!/bin/sh +MOUNTED="$(ls -m ~/Mounted)" +[ "$MOUNTED" = "" ] && exit 0 || echo "\003 $MOUNTED\001" diff --git a/screenshot.jpg b/screenshot.jpg new file mode 100644 index 0000000..30114b1 Binary files /dev/null and b/screenshot.jpg differ diff --git a/volume b/volume new file mode 100755 index 0000000..e5a76fe --- /dev/null +++ b/volume @@ -0,0 +1,3 @@ +#!/bin/sh +[ $(pamixer --get-mute) = true ] && echo "\004MUTE\001" && exit 1 +echo " $(pamixer --get-volume)%" diff --git a/wifi b/wifi new file mode 100755 index 0000000..aacc3b8 --- /dev/null +++ b/wifi @@ -0,0 +1,15 @@ +#!/bin/sh +case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in + down) + echo "\004 \001" + ;; + up) + ssid="$(iw dev | grep ssid | awk '{print $2}')" + percent="$(awk '/^\s*w/ { print int($3 * 100 / 70) }' /proc/net/wireless)" + wifiicon=" " + [ $percent -le 50 ] && [ $percent -gt 25 ] && color=$(echo '\003') || color='' + [ $percent -le 25 ] && color=$(echo '\004') + printf "%s%s%s%s\001" "$wifiicon" "$ssid " $color "($percent%)" + ;; +esac + -- cgit v1.2.3