| @ -1,2 +1,8 @@ | |||||
| # dwm-bar | # dwm-bar | ||||
| A modular statusbar for DWM thrown together in sh | A modular statusbar for DWM thrown together in sh | ||||
| ## Acknowledgements | |||||
| Code for some functions was modified from: | |||||
| * [Klemens Nanni](https://notabug.org/kl3) | |||||
| * [@boylemic](https://github.com/boylemic/configs/blob/master/dwm_status) | |||||
| * [Parket Johnson](https://github.com/ronno/scripts/blob/master/xsetcmus) | |||||
| * [suckless.org](https://dwm.suckless.org/status_monitor/) | |||||
| @ -0,0 +1,6 @@ | |||||
| Show SSID in dwm_network | |||||
| dwm_bat function | |||||
| Network speeds | |||||
| dwm_pulse function | |||||
| dwm_notifs function | |||||
| Swappable unicode and plaintext module identifiers | |||||
| @ -0,0 +1,30 @@ | |||||
| #!/bin/sh | |||||
| # A modular status bar for dwm | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # GNU GPLv3 | |||||
| # Dependencies: xorg-xsetroot | |||||
| # Import functions with "$include /route/to/module" | |||||
| # It is reccomended that you place functions in the subdirectory ./functions and use: . "$DIR/modules/dwm_example.sh" | |||||
| # Store the directory the script is running from | |||||
| LOC=$(readlink -f "$0") | |||||
| DIR=$(dirname "$LOC") | |||||
| # Import the modules | |||||
| . "$DIR/functions/dwm_countdown.sh" | |||||
| . "$DIR/functions/dwm_cmus.sh" | |||||
| . "$DIR/functions/dwm_resources.sh" | |||||
| . "$DIR/functions/dwm_mail.sh" | |||||
| . "$DIR/functions/dwm_alsa.sh" | |||||
| . "$DIR/functions/dwm_weather.sh" | |||||
| . "$DIR/functions/dwm_date.sh" | |||||
| # Update dwm's status bar every second | |||||
| while true | |||||
| do | |||||
| xsetroot -name "$(dwm_countdown)$(dwm_cmus)$(dwm_resources)$(dwm_mail)$(dwm_alsa)$(dwm_weather)$(dwm_date)" | |||||
| sleep 1 | |||||
| done | |||||
| @ -0,0 +1,21 @@ | |||||
| #!/bin/sh | |||||
| # A dwm_bar function to show the master volume of ALSA | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # GNU GPLv3 | |||||
| # Dependencies: alsa-utils | |||||
| dwm_alsa () { | |||||
| VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/") | |||||
| if [ $VOL -eq 0 ]; then | |||||
| printf "[\U1F507 $VOL]\n" | |||||
| elif [ $VOL -gt 0 ] && [ $VOL -le 33 ]; then | |||||
| printf "[\U1F508 $VOL]\n" | |||||
| elif [ $VOL -gt 33 ] && [ $VOL -le 66 ]; then | |||||
| printf "[\U1F509 $VOL]\n" | |||||
| else | |||||
| printf "[\U1F50A $VOL]\n" | |||||
| fi | |||||
| } | |||||
| dwm_alsa | |||||
| @ -0,0 +1,36 @@ | |||||
| #!/bin/sh | |||||
| # A dwm_bar function that shows the current artist, track, position, duration, and status from cmus | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # 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 [ $STATUS == "playing" ]; then | |||||
| STATUS="\U25B6" | |||||
| else | |||||
| STATUS="\U23F8" | |||||
| fi | |||||
| if [ $SHUFFLE == "true" ]; then | |||||
| SHUFFLE=" \U1F500" | |||||
| else | |||||
| SHUFFLE="" | |||||
| fi | |||||
| printf "[$STATUS $ARTIST - $TRACK " | |||||
| printf "%0d:%02d/" $(($POSITION%3600/60)) $(($POSITION%60)) | |||||
| printf "%0d:%02d" $(($DURATION%3600/60)) $(($DURATION%60)) | |||||
| printf "$SHUFFLE]\n" | |||||
| fi | |||||
| } | |||||
| dwm_cmus | |||||
| @ -0,0 +1,14 @@ | |||||
| #!/bin/sh | |||||
| # A dwm_status function that displays the status of countdown.sh | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # GNU GPLv3 | |||||
| # Dependencies: https://github.com/joestandring/countdown | |||||
| dwm_countdown () { | |||||
| if [ -e /tmp/countdown.* ]; then | |||||
| printf "[\U23F3 $(tail -1 /tmp/countdown.*)]" | |||||
| fi | |||||
| } | |||||
| dwm_countdown | |||||
| @ -0,0 +1,11 @@ | |||||
| #!/bin/sh | |||||
| # A dwm_bar function that shows the current date and time | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # GNU GPLv3 | |||||
| # Date is formatted like like this: "[Mon 01-01-00 00:00:00]" | |||||
| dwm_date () { | |||||
| printf "[\U23F2 $(date "+%a %d-%m-%y %T")]\n" | |||||
| } | |||||
| dwm_date | |||||
| @ -0,0 +1,12 @@ | |||||
| #!/bin/sh | |||||
| # A dwm_bar function that displays the current keyboard layout | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # GNU GPLv3 | |||||
| # Dependencies: xorg-setxkbmap | |||||
| dwm_keyboard () { | |||||
| printf "[\U2328 $(setxkbmap -query | awk '/layout/{print $2}')]\n" | |||||
| } | |||||
| dwm_keyboard | |||||
| @ -0,0 +1,17 @@ | |||||
| #!/bin/sh | |||||
| # A dwm_bar function to display the number of emails in an inbox | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # 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) | |||||
| if [ $MAILBOX -eq 0 ]; then | |||||
| printf "[\U1F4ED $MAILBOX]\n" | |||||
| else | |||||
| printf "[\U1F4EB $MAILBOX]\n" | |||||
| fi | |||||
| } | |||||
| dwm_mail | |||||
| @ -0,0 +1,20 @@ | |||||
| #!/bin/sh | |||||
| # A dwm_bar function to display information regarding system memory, CPU temperature, and storage | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # 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 $2}') | |||||
| STOTOT=$(df -h | grep '/home' | awk '{print $3}') | |||||
| STOPER=$(df -h | grep '/home' | awk '{print $5}') | |||||
| printf "[\U1F5A5 MEM $MEMUSED/$MEMTOT CPU $CPU STO $STOUSED/$STOTOT: $STOPER%]\n" | |||||
| } | |||||
| dwm_resources | |||||
| @ -0,0 +1,14 @@ | |||||
| #!/bin/sh | |||||
| # A dwm_bar function to print the weather from wttr.in | |||||
| # Joe Standring <jstandring@pm.me> | |||||
| # GNU GPLv3 | |||||
| # Dependencies: curl | |||||
| # Change the value of LOCATION to match your city | |||||
| dwm_weather() { | |||||
| LOCATION=city | |||||
| printf "[$(curl -s wttr.in/$LOCATION?format=1)]\n" | |||||
| } | |||||
| dwm_weather | |||||