summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rwxr-xr-xarch-update4
-rwxr-xr-xbacklight3
-rwxr-xr-xbattery8
-rwxr-xr-xbluetooth5
-rwxr-xr-xdisk4
-rwxr-xr-xmail4
-rwxr-xr-xmemory2
-rwxr-xr-xmount3
-rw-r--r--screenshot.jpgbin0 -> 7786 bytes
-rwxr-xr-xvolume3
-rwxr-xr-xwifi15
12 files changed, 53 insertions, 0 deletions
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
--- /dev/null
+++ b/screenshot.jpg
Binary files 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
+