diff options
Diffstat (limited to 'dwmbar-functions')
| -rwxr-xr-x | dwmbar-functions/dwm_alsa.sh | 35 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_backlight.sh | 13 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_battery.sh | 26 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_ccurse.sh | 24 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_cmus.sh | 51 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_countdown.sh | 25 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_date.sh | 18 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_keyboard.sh | 19 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_mail.sh | 25 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_network.sh | 27 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_pulse.sh | 37 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_resources.sh | 27 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_transmission.sh | 50 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_vpn.sh | 24 | ||||
| -rwxr-xr-x | dwmbar-functions/dwm_weather.sh | 22 |
15 files changed, 423 insertions, 0 deletions
diff --git a/dwmbar-functions/dwm_alsa.sh b/dwmbar-functions/dwm_alsa.sh new file mode 100755 index 0000000..e250368 --- /dev/null +++ b/dwmbar-functions/dwm_alsa.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# A dwm_bar function to show the master volume of ALSA +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: alsa-utils + +dwm_alsa () { + VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/") + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + if [ "$VOL" -eq 0 ]; then + printf "š" + elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then + printf "š %s%%" "$VOL" + elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then + printf "š %s%%" "$VOL" + else + printf "š %s%%" "$VOL" + fi + else + if [ "$VOL" -eq 0 ]; then + printf "MUTE" + elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then + printf "VOL %s%%" "$VOL" + elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then + printf "VOL %s%%" "$VOL" + else + printf "VOL %s%%" "$VOL" + fi + fi + printf "%s\n" "$SEP2" +} + diff --git a/dwmbar-functions/dwm_backlight.sh b/dwmbar-functions/dwm_backlight.sh new file mode 100755 index 0000000..c0968d8 --- /dev/null +++ b/dwmbar-functions/dwm_backlight.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# A dwm_bar module to display the current backlight brighness with xbacklight +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: xbacklight + +dwm_backlight () { + printf "%sā %.0f%s\n" "$SEP1" "$(xbacklight)" "$SEP2" +} + +dwm_backlight diff --git a/dwmbar-functions/dwm_battery.sh b/dwmbar-functions/dwm_battery.sh new file mode 100755 index 0000000..6321e64 --- /dev/null +++ b/dwmbar-functions/dwm_battery.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# A dwm_bar function to read the battery level and status +# Joe Standring <[email protected]> +# GNU GPLv3 + +dwm_battery () { + # Change BAT1 to whatever your battery is identified as. Typically BAT0 or BAT1 + CHARGE=$(cat /sys/class/power_supply/BAT1/capacity) + STATUS=$(cat /sys/class/power_supply/BAT1/status) + + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + if [ "$STATUS" = "Charging" ]; then + printf "š %s%% %s" "$CHARGE" "$STATUS" + else + printf "š %s%% %s" "$CHARGE" "$STATUS" + fi + else + printf "BAT %s%% %s" "$CHARGE" "$STATUS" + fi + printf "%s\n" "$SEP2" +} + +dwm_battery + diff --git a/dwmbar-functions/dwm_ccurse.sh b/dwmbar-functions/dwm_ccurse.sh new file mode 100755 index 0000000..578336c --- /dev/null +++ b/dwmbar-functions/dwm_ccurse.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# A dwm_bar function to show the closest appointment in calcurse +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: calcurse + +dwm_ccurse () { + APTSFILE="$HOME/.calcurse/apts" + APPOINTMENT=$(head -n 1 "$APTSFILE" | sed -r 's/\[1\] //') + + if [ "$APPOINTMENT" != "" ]; then + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "š” %s" "$APPOINTMENT" + else + printf "APT %s" "$APPOINTMENT" + fi + printf "%s\n" "$SEP2" + fi +} + +dwm_ccurse diff --git a/dwmbar-functions/dwm_cmus.sh b/dwmbar-functions/dwm_cmus.sh new file mode 100755 index 0000000..43f6c76 --- /dev/null +++ b/dwmbar-functions/dwm_cmus.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# A dwm_bar function that shows the current artist, track, position, duration, and status from cmus +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: cmus + +dwm_cmus () { + if ps -C cmus > /dev/null; then + ARTIST=$(cmus-remote -Q | grep -a '^tag artist' | awk '{gsub("tag artist ", "");print}') + TRACK=$(cmus-remote -Q | grep -a '^tag title' | awk '{gsub("tag title ", "");print}') + POSITION=$(cmus-remote -Q | grep -a '^position' | awk '{gsub("position ", "");print}') + DURATION=$(cmus-remote -Q | grep -a '^duration' | awk '{gsub("duration ", "");print}') + STATUS=$(cmus-remote -Q | grep -a '^status' | awk '{gsub("status ", "");print}') + SHUFFLE=$(cmus-remote -Q | grep -a '^set shuffle' | awk '{gsub("set shuffle ", "");print}') + + if [ "$IDENTIFIER" = "unicode" ]; then + if [ "$STATUS" = "playing" ]; then + STATUS="ā¶" + else + STATUS="āø" + fi + + if [ "$SHUFFLE" = "true" ]; then + SHUFFLE=" š" + else + SHUFFLE="" + fi + else + if [ "$STATUS" = "playing" ]; then + STATUS="PLA" + else + STATUS="PAU" + fi + + if [ "$SHUFFLE" = "true" ]; then + SHUFFLE=" S" + else + SHUFFLE="" + fi + fi + + printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK" + printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60)) + printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60)) + printf "%s%s\n" "$SHUFFLE" "$SEP2" + fi +} + +dwm_cmus diff --git a/dwmbar-functions/dwm_countdown.sh b/dwmbar-functions/dwm_countdown.sh new file mode 100755 index 0000000..cc4db51 --- /dev/null +++ b/dwmbar-functions/dwm_countdown.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# A dwm_status function that displays the status of countdown.sh +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: https://github.com/joestandring/countdown + +dwm_countdown () { + for f in /tmp/countdown.*; do + if [ -e "$f" ]; then + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "ā³ %s" "$(tail -1 /tmp/countdown.*)" + else + printf "CDN %s" "$(tail -1 /tmp/countdown.*)" + fi + printf "%s\n" "$SEP2" + + break + fi + done +} + +dwm_countdown diff --git a/dwmbar-functions/dwm_date.sh b/dwmbar-functions/dwm_date.sh new file mode 100755 index 0000000..654def1 --- /dev/null +++ b/dwmbar-functions/dwm_date.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# A dwm_bar function that shows the current date and time +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Date is formatted like like this: "[Mon 01-01-00 00:00:00]" +dwm_date () { + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "š %s" "$(date "+%a %d-%m-%y %T")" + else + printf "DAT %s" "$(date "+%a %d-%m-%y %T")" + fi + printf "%s\n" "$SEP2" +} + +dwm_date diff --git a/dwmbar-functions/dwm_keyboard.sh b/dwmbar-functions/dwm_keyboard.sh new file mode 100755 index 0000000..a9ae912 --- /dev/null +++ b/dwmbar-functions/dwm_keyboard.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# A dwm_bar function that displays the current keyboard layout +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: xorg-setxkbmap + +dwm_keyboard () { + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "⨠%s" "$(setxkbmap -query | awk '/layout/{print $2}')" + else + printf "KEY %s" "$(setxkbmap -query | awk '/layout/{print $2}')" + fi + printf "%s\n" "$SEP2" +} + +dwm_keyboard diff --git a/dwmbar-functions/dwm_mail.sh b/dwmbar-functions/dwm_mail.sh new file mode 100755 index 0000000..27f3d51 --- /dev/null +++ b/dwmbar-functions/dwm_mail.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# A dwm_bar function to display the number of emails in an inbox +# Joe Standring <[email protected]> +# GNU GPLv3 + +# To count mail in an inbox, change "/path/to/inbox" below to the location of your inbox. For example, "/home/$USER/.mail/new" + +dwm_mail () { + MAILBOX=$(ls /path/to/inbox | wc -l) + + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + if [ "$MAILBOX" -eq 0 ]; then + printf "šŖ %s" "$MAILBOX" + else + printf "š« %s" "$MAILBOX" + fi + else + printf "MAI %s" "$MAILBOX" + fi + printf "%s\n" "$SEP2" +} + +dwm_mail diff --git a/dwmbar-functions/dwm_network.sh b/dwmbar-functions/dwm_network.sh new file mode 100755 index 0000000..9398bbb --- /dev/null +++ b/dwmbar-functions/dwm_network.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# A dwm_bar function to show the current network connection/SSID, private IP, and public IP +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: NetworkManager, curl + +dwm_network () { + CONNAME=$(nmcli -a | grep 'Wired connection' | awk 'NR==1{print $1}') + if [ "$CONNAME" = "" ]; then + CONNAME=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -c 5-) + fi + + PRIVATE=$(nmcli -a | grep 'inet4 192' | awk '{print $2}') + PUBLIC=$(curl -s https://ipinfo.io/ip) + + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "š %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC" + else + printf "NET %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC" + fi + printf "%s\n" "$SEP2" +} + +dwm_network diff --git a/dwmbar-functions/dwm_pulse.sh b/dwmbar-functions/dwm_pulse.sh new file mode 100755 index 0000000..e4e9149 --- /dev/null +++ b/dwmbar-functions/dwm_pulse.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# A dwm_bar function to show the master volume of PulseAudio +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: pamixer + +dwm_pulse () { + VOL=$(pamixer --get-volume-human | tr -d '%') + + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then + printf "š" + elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then + printf "š %s%%" "$VOL" + elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then + printf "š %s%%" "$VOL" + else + printf "š %s%%" "$VOL" + fi + else + if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then + printf "MUTE" + elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then + printf "VOL %s%%" "$VOL" + elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then + printf "VOL %s%%" "$VOL" + else + printf "VOL %s%%" "$VOL" + fi + fi + printf "%s\n" "$SEP2" +} + +dwm_pulse diff --git a/dwmbar-functions/dwm_resources.sh b/dwmbar-functions/dwm_resources.sh new file mode 100755 index 0000000..ca064c2 --- /dev/null +++ b/dwmbar-functions/dwm_resources.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# A dwm_bar function to display information regarding system memory, CPU temperature, and storage +# Joe Standring <[email protected]> +# GNU GPLv3 + +dwm_resources () { + # Used and total memory + MEMUSED=$(free -h | awk '(NR == 2) {print $3}') + MEMTOT=$(free -h |awk '(NR == 2) {print $2}') + # CPU temperature + CPU=$(sysctl -n hw.sensors.cpu0.temp0 | cut -d. -f1) + # Used and total storage in /home (rounded to 1024B) + STOUSED=$(df -h | grep '/home$' | awk '{print $3}') + STOTOT=$(df -h | grep '/home$' | awk '{print $2}') + STOPER=$(df -h | grep '/home$' | awk '{print $5}') + + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "š» MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER" + else + printf "STA | MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER" + fi + printf "%s\n" "$SEP2" +} + +dwm_resources diff --git a/dwmbar-functions/dwm_transmission.sh b/dwmbar-functions/dwm_transmission.sh new file mode 100755 index 0000000..f11c719 --- /dev/null +++ b/dwmbar-functions/dwm_transmission.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +# A dwm_bar function to show the status of a torrent woth transmission-remote +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: transmission-remote + +dwm_transmission () { + TORRENT=$(transmission-remote -l | sed '2q;d' | sed 's/\(.\) /\1/g') + ID=$(printf "%s" "$TORRENT" | awk '{print $1;}') + STATUS=$(printf "%s" "$TORRENT" | awk '{print $8;}') + ETA=$(printf "%s" "$TORRENT" | awk '{print $4;}') + NAME=$(printf "%s" "$TORRENT" | awk '{for(i=9;i<=NF;++i)print $i}' | tr -d "\n" | head -c 20; printf "...") + DONE=$(printf "%s" "$TORRENT" | awk '{print $2;}') + UP=$(printf "%s" "$TORRENT" | awk '{print $5;}') + DOWN=$(printf "%s" "$TORRENT" | awk '{print $5;}') + + if [ "$ID" != "Sum:" ]; then + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + case "$STATUS" in + "Idle") + printf "š %s | %s %s ā¬%s ā¬%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + ;; + "Seeding") + printf "š± %s | ā¬%s ā¬%s" "$NAME" "$UP" "$DOWN" + ;; + "Downloading") + printf "⬠%s | %s %s ā¬%s ā¬%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + ;; + esac + else + case "$STATUS" in + "Idle") + printf "IDLE %s | %s %s ā¬%s ā¬%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + ;; + "Seeding") + printf "SEEDING %s | ā¬%s ā¬%s" "$NAME" "$UP" "$DOWN" + ;; + "Downloading") + printf "DOWNLOADING %s | %s %s ā¬%s ā¬%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + ;; + esac + fi + printf "%s\n" "$SEP2" + fi +} + +dwm_transmission diff --git a/dwmbar-functions/dwm_vpn.sh b/dwmbar-functions/dwm_vpn.sh new file mode 100755 index 0000000..b57b114 --- /dev/null +++ b/dwmbar-functions/dwm_vpn.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# A dwm_bar function to show VPN connections (if any are active) +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: NetworkManager-openvpn + +dwm_vpn () { + VPN=$(nmcli -a | grep 'VPN connection' | sed -e 's/\( VPN connection\)*$//g') + + if [ "$VPN" != "" ]; then + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "š %s" "$VPN" + else + printf "VPN %s" "$VPN" + fi + printf "%s\n" "$SEP2" + fi +} + + +dwm_vpn diff --git a/dwmbar-functions/dwm_weather.sh b/dwmbar-functions/dwm_weather.sh new file mode 100755 index 0000000..ac43add --- /dev/null +++ b/dwmbar-functions/dwm_weather.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# A dwm_bar function to print the weather from wttr.in +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: curl + +# Change the value of LOCATION to match your city +dwm_weather() { + LOCATION=city + + printf "%s" "$SEP1" + if [ "$IDENTIFIER" = "unicode" ]; then + printf "%s" "$(curl -s wttr.in/$LOCATION?format=1)" + else + printf "WEA %s" "$(curl -s wttr.in/$LOCATION?format=1 | grep -o "[0-9].*")" + fi + printf "%s\n" "$SEP2" +} + +dwm_weather |
