Browse Source

Add 'SEP1' and 'SEP2'

The 'SEP' contain the charachter(s) that are placed before and after a
module (respectively). For example, if SEP1="[" and SEP2="]" then each
module will be surrounded by those charachters.
main
joestandring 5 years ago
parent
commit
51fd3faa1b
17 changed files with 89 additions and 63 deletions
  1. +2
    -8
      README.md
  2. +10
    -8
      bar-functions/dwm_alsa.sh
  3. +1
    -1
      bar-functions/dwm_backlight.sh
  4. +5
    -3
      bar-functions/dwm_battery.sh
  5. +8
    -4
      bar-functions/dwm_ccurse.sh
  6. +2
    -2
      bar-functions/dwm_cmus.sh
  7. +4
    -2
      bar-functions/dwm_countdown.sh
  8. +4
    -2
      bar-functions/dwm_date.sh
  9. +4
    -2
      bar-functions/dwm_keyboard.sh
  10. +5
    -3
      bar-functions/dwm_mail.sh
  11. +4
    -2
      bar-functions/dwm_network.sh
  12. +11
    -8
      bar-functions/dwm_pulse.sh
  13. +4
    -2
      bar-functions/dwm_resources.sh
  14. +8
    -6
      bar-functions/dwm_transmission.sh
  15. +8
    -7
      bar-functions/dwm_vpn.sh
  16. +5
    -2
      bar-functions/dwm_weather.sh
  17. +4
    -1
      dwm_bar.sh

+ 2
- 8
README.md View File

@ -2,7 +2,6 @@
A modular statusbar for DWM A modular statusbar for DWM
![screenshot](sshot.png) ![screenshot](sshot.png)
## Table of Contents ## Table of Contents
- [Features](#features)
- [Current Functions](#current-functions) - [Current Functions](#current-functions)
- [dwm_alsa](#dwm_alsa) - [dwm_alsa](#dwm_alsa)
- [dwm_pulse](#dwm_pulse) - [dwm_pulse](#dwm_pulse)
@ -24,11 +23,6 @@ A modular statusbar for DWM
- [Customizing](#customizing) - [Customizing](#customizing)
- [Acknowledgements](#acknowledgements) - [Acknowledgements](#acknowledgements)
- [More to come!](#more-to-come) - [More to come!](#more-to-come)
## Features
* Fully modular! If you don't want to use a function, no worries.
* Lightweight! dwm-bar is written entirely in POSIX-compliant shell script so need to install a hundred different packages to get it working.
* Options! You can decide to use either unicode symbols or plaintext for module identifiers with the ```IDENTIFIER``` value.
## Current Functions
### dwm_alsa ### dwm_alsa
Displays the current master volume of ALSA Displays the current master volume of ALSA
``` ```
@ -139,8 +133,8 @@ If you would like your bar to be displayed when X starts, add this to your .xini
exec dwm exec dwm
``` ```
## Customizing ## Customizing
dwm-bar is completley modular, meaning you can mix and match functions to your hearts content. It's functions are located in the functions/ subdirectory and included in dwm_bar.sh
If you want to make your own function, for example dwm_myfunction.sh, you should create it in the functions/ subdirectory before including it in dwm_bar.sh and adding it to the xsetroot command:
dwm-bar is completley modular, meaning you can mix and match functions to your hearts content. It's functions are located in the bar-functions/ subdirectory and included in dwm_bar.sh
If you want to make your own function, for example dwm_myfunction.sh, you should create it in the bar-functions/ subdirectory before including it in dwm_bar.sh and adding it to the xsetroot command:
``` ```
# Import the modules # Import the modules
. "$DIR/bar-functions/dwm_myfucntion" . "$DIR/bar-functions/dwm_myfucntion"


+ 10
- 8
bar-functions/dwm_alsa.sh View File

@ -8,27 +8,29 @@
dwm_alsa () { dwm_alsa () {
VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/") VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/")
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$VOL" -eq 0 ]; then if [ "$VOL" -eq 0 ]; then
printf "🔇\n"
printf "🔇"
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
printf "🔈 %s%%\n" "$VOL"
printf "🔈 %s%%" "$VOL"
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
printf "🔉 %s%%\n" "$VOL"
printf "🔉 %s%%" "$VOL"
else else
printf "🔊 %s%%\n" "$VOL"
printf "🔊 %s%%" "$VOL"
fi fi
else else
if [ "$VOL" -eq 0 ]; then if [ "$VOL" -eq 0 ]; then
printf "MUTE\n"
printf "MUTE"
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
printf "VOL %s%%\n" "$VOL"
printf "VOL %s%%" "$VOL"
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
printf "VOL %s%%\n" "$VOL"
printf "VOL %s%%" "$VOL"
else else
printf "VOL %s%%\n" "$VOL"
printf "VOL %s%%" "$VOL"
fi fi
fi fi
printf "%s\n" "$SEP2"
} }
dwm_alsa dwm_alsa

+ 1
- 1
bar-functions/dwm_backlight.sh View File

@ -7,7 +7,7 @@
# Dependencies: xbacklight # Dependencies: xbacklight
dwm_backlight () { dwm_backlight () {
printf "☀ %.0f\n" "$(xbacklight)"
printf "%s☀ %.0f%s\n" "$SEP1" "$(xbacklight)" "$SEP2"
} }
dwm_backlight dwm_backlight

+ 5
- 3
bar-functions/dwm_battery.sh View File

@ -9,15 +9,17 @@ dwm_battery () {
CHARGE=$(cat /sys/class/power_supply/BAT1/capacity) CHARGE=$(cat /sys/class/power_supply/BAT1/capacity)
STATUS=$(cat /sys/class/power_supply/BAT1/status) STATUS=$(cat /sys/class/power_supply/BAT1/status)
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$STATUS" = "Charging" ]; then if [ "$STATUS" = "Charging" ]; then
printf "🔌 %s%% %s\n" "$CHARGE" "$STATUS"
printf "🔌 %s%% %s" "$CHARGE" "$STATUS"
else else
printf "🔋 %s%% %s\n" "$CHARGE" "$STATUS"
printf "🔋 %s%% %s" "$CHARGE" "$STATUS"
fi fi
else else
printf "BAT %s%% %s\n" "$CHARGE" "$STATUS"
printf "BAT %s%% %s" "$CHARGE" "$STATUS"
fi fi
printf "%s\n" "$SEP2"
} }
dwm_battery dwm_battery


+ 8
- 4
bar-functions/dwm_ccurse.sh View File

@ -9,10 +9,14 @@
dwm_ccurse () { dwm_ccurse () {
APPOINTMENT=$(calcurse -a | head -n 3 | tr -d '\n+>-' | awk '$1=$1' | sed 's/://') APPOINTMENT=$(calcurse -a | head -n 3 | tr -d '\n+>-' | awk '$1=$1' | sed 's/://')
if [ "$IDENTIFIER" = "unicode" ]; then
printf "💡 %s\n" "$APPOINTMENT"
else
printf "APT %s\n" "$APPOINTMENT"
if [ "$APPOINTMENT" != "" ]; then
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then
printf "💡 %s" "$APPOINTMENT"
else
printf "APT %s" "$APPOINTMENT"
fi
printf "%s\n" "$SEP2"
fi fi
} }


+ 2
- 2
bar-functions/dwm_cmus.sh View File

@ -41,10 +41,10 @@ dwm_cmus () {
fi fi
fi fi
printf "%s %s - %s " "$STATUS" "$ARTIST" "$TRACK"
printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK"
printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60)) printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60))
printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60)) printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60))
printf "%s\n" "$SHUFFLE"
printf "%s%s\n" "$SHUFFLE" "$SEP2"
fi fi
} }


+ 4
- 2
bar-functions/dwm_countdown.sh View File

@ -9,11 +9,13 @@
dwm_countdown () { dwm_countdown () {
for f in /tmp/countdown.*; do for f in /tmp/countdown.*; do
if [ -e "$f" ]; then if [ -e "$f" ]; then
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
printf "⏳ %s\n" "$(tail -1 /tmp/countdown.*)"
printf "⏳ %s" "$(tail -1 /tmp/countdown.*)"
else else
printf "CDN %s\n" "$(tail -1 /tmp/countdown.*)"
printf "CDN %s" "$(tail -1 /tmp/countdown.*)"
fi fi
printf "%s\n" "$SEP2"
break break
fi fi


+ 4
- 2
bar-functions/dwm_date.sh View File

@ -6,11 +6,13 @@
# Date is formatted like like this: "[Mon 01-01-00 00:00:00]" # Date is formatted like like this: "[Mon 01-01-00 00:00:00]"
dwm_date () { dwm_date () {
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
printf "📆 %s\n" "$(date "+%a %d-%m-%y %T")"
printf "📆 %s" "$(date "+%a %d-%m-%y %T")"
else else
printf "DAT %s\n" "$(date "+%a %d-%m-%y %T")"
printf "DAT %s" "$(date "+%a %d-%m-%y %T")"
fi fi
printf "%s\n" "$SEP2"
} }
dwm_date dwm_date

+ 4
- 2
bar-functions/dwm_keyboard.sh View File

@ -7,11 +7,13 @@
# Dependencies: xorg-setxkbmap # Dependencies: xorg-setxkbmap
dwm_keyboard () { dwm_keyboard () {
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
printf "⌨ %s\n" "$(setxkbmap -query | awk '/layout/{print $2}')"
printf "⌨ %s" "$(setxkbmap -query | awk '/layout/{print $2}')"
else else
printf "KEY %s\n" "$(setxkbmap -query | awk '/layout/{print $2}')"
printf "KEY %s" "$(setxkbmap -query | awk '/layout/{print $2}')"
fi fi
printf "%s\n" "$SEP2"
} }
dwm_keyboard dwm_keyboard

+ 5
- 3
bar-functions/dwm_mail.sh View File

@ -9,15 +9,17 @@
dwm_mail () { dwm_mail () {
MAILBOX=$(ls /path/to/inbox | wc -l) MAILBOX=$(ls /path/to/inbox | wc -l)
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$MAILBOX" -eq 0 ]; then if [ "$MAILBOX" -eq 0 ]; then
printf "📪 %s\n" "$MAILBOX"
printf "📪 %s" "$MAILBOX"
else else
printf "📫 %s\n" "$MAILBOX"
printf "📫 %s" "$MAILBOX"
fi fi
else else
printf "MAI %s\n" "$MAILBOX"
printf "MAI %s" "$MAILBOX"
fi fi
printf "%s\n" "$SEP2"
} }
dwm_mail dwm_mail

+ 4
- 2
bar-functions/dwm_network.sh View File

@ -15,11 +15,13 @@ dwm_network () {
PRIVATE=$(nmcli -a | grep 'inet4 192' | awk '{print $2}') PRIVATE=$(nmcli -a | grep 'inet4 192' | awk '{print $2}')
PUBLIC=$(curl -s https://ipinfo.io/ip) PUBLIC=$(curl -s https://ipinfo.io/ip)
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
printf "🌐 %s %s | %s\n" "$CONNAME" "$PRIVATE" "$PUBLIC"
printf "🌐 %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC"
else else
printf "NET %s %s | %s\n" "$CONNAME" "$PRIVATE" "$PUBLIC"
printf "NET %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC"
fi fi
printf "%s\n" "$SEP2"
} }
dwm_network dwm_network

+ 11
- 8
bar-functions/dwm_pulse.sh View File

@ -8,27 +8,30 @@
dwm_pulse () { dwm_pulse () {
VOL=$(pamixer --get-volume-human | tr -d '%') VOL=$(pamixer --get-volume-human | tr -d '%')
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then
printf "🔇\n"
printf "🔇"
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
printf "🔈 %s%%\n" "$VOL"
printf "🔈 %s%%" "$VOL"
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
printf "🔉 %s%%\n" "$VOL"
printf "🔉 %s%%" "$VOL"
else else
printf "🔊 %s%%\n" "$VOL"
printf "🔊 %s%%" "$VOL"
fi fi
else else
if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then
printf "MUTE\n"
printf "MUTE"
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
printf "VOL %s%%\n" "$VOL"
printf "VOL %s%%" "$VOL"
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
printf "VOL %s%%\n" "$VOL"
printf "VOL %s%%" "$VOL"
else else
printf "VOL %s%%\n" "$VOL"
printf "VOL %s%%" "$VOL"
fi fi
fi fi
printf "%s\n" "$SEP2"
} }
dwm_pulse dwm_pulse

+ 4
- 2
bar-functions/dwm_resources.sh View File

@ -15,11 +15,13 @@ dwm_resources () {
STOTOT=$(df -h | grep '/home$' | awk '{print $2}') STOTOT=$(df -h | grep '/home$' | awk '{print $2}')
STOPER=$(df -h | grep '/home$' | awk '{print $5}') STOPER=$(df -h | grep '/home$' | awk '{print $5}')
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
printf "💻 MEM %s/%s CPU %s STO %s/%s: %s\n" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER"
printf "💻 MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER"
else else
printf "STA | MEM %s/%s CPU %s STO %s/%s: %s\n" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER"
printf "STA | MEM %s/%s CPU %s STO %s/%s: %s" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER"
fi fi
printf "%s\n" "$SEP2"
} }
dwm_resources dwm_resources

+ 8
- 6
bar-functions/dwm_transmission.sh View File

@ -17,31 +17,33 @@ dwm_transmission () {
DOWN=$(printf "%s" "$TORRENT" | awk '{print $5;}') DOWN=$(printf "%s" "$TORRENT" | awk '{print $5;}')
if [ "$ID" != "Sum:" ]; then if [ "$ID" != "Sum:" ]; then
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
case "$STATUS" in case "$STATUS" in
"Idle") "Idle")
printf "🛑 %s | %s %s ⬆%s ⬇%s\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN"
printf "🛑 %s | %s %s ⬆%s ⬇%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN"
;; ;;
"Seeding") "Seeding")
printf "🌱 %s | ⬆%s ⬇%s\n" "$NAME" "$UP" "$DOWN"
printf "🌱 %s | ⬆%s ⬇%s" "$NAME" "$UP" "$DOWN"
;; ;;
"Downloading") "Downloading")
printf "⏬ %s | %s %s ⬆%s ⬇%s\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN"
printf "⏬ %s | %s %s ⬆%s ⬇%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN"
;; ;;
esac esac
else else
case "$STATUS" in case "$STATUS" in
"Idle") "Idle")
printf "IDLE %s | %s %s ⬆%s ⬇%s\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN"
printf "IDLE %s | %s %s ⬆%s ⬇%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN"
;; ;;
"Seeding") "Seeding")
printf "SEEDING %s | ⬆%s ⬇%s\n" "$NAME" "$UP" "$DOWN"
printf "SEEDING %s | ⬆%s ⬇%s" "$NAME" "$UP" "$DOWN"
;; ;;
"Downloading") "Downloading")
printf "DOWNLOADING %s | %s %s ⬆%s ⬇%s\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN"
printf "DOWNLOADING %s | %s %s ⬆%s ⬇%s" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN"
;; ;;
esac esac
fi fi
printf "%s\n" "$SEP2"
fi fi
} }


+ 8
- 7
bar-functions/dwm_vpn.sh View File

@ -8,14 +8,15 @@
dwm_vpn () { dwm_vpn () {
VPN=$(nmcli -a | grep 'VPN connection' | sed -e 's/\( VPN connection\)*$//g') VPN=$(nmcli -a | grep 'VPN connection' | sed -e 's/\( VPN connection\)*$//g')
if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$VPN" != "" ]; then
printf "🔒 %s\n" "$VPN"
fi
else
if [ "$VPN" != "" ]; then
printf "VPN %s\n" "$VPN"
if [ "$VPN" != "" ]; then
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then
printf "🔒 %s" "$VPN"
else
printf "VPN %s" "$VPN"
fi fi
printf "%s" "$SEP2"
fi fi
} }


+ 5
- 2
bar-functions/dwm_weather.sh View File

@ -9,11 +9,14 @@
# Change the value of LOCATION to match your city # Change the value of LOCATION to match your city
dwm_weather() { dwm_weather() {
LOCATION=city LOCATION=city
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then if [ "$IDENTIFIER" = "unicode" ]; then
printf "%s\n" "$(curl -s wttr.in/$LOCATION?format=1)"
printf "%s" "$(curl -s wttr.in/$LOCATION?format=1)"
else else
printf "WEA %s\n" "$(curl -s wttr.in/$LOCATION?format=1 | grep -o "[0-9].*")"
printf "WEA %s" "$(curl -s wttr.in/$LOCATION?format=1 | grep -o "[0-9].*")"
fi fi
printf "%s" "$SEP2"
} }
dwm_weather dwm_weather

+ 4
- 1
dwm_bar.sh View File

@ -16,6 +16,9 @@ DIR=$(dirname "$LOC")
# Change the appearance of the module identifier. if this is set to "unicode", then symbols will be used as identifiers instead of text. E.g. [📪 0] instead of [MAIL 0]. # Change the appearance of the module identifier. if this is set to "unicode", then symbols will be used as identifiers instead of text. E.g. [📪 0] instead of [MAIL 0].
# Requires a font with adequate unicode character support # Requires a font with adequate unicode character support
export IDENTIFIER="unicode" export IDENTIFIER="unicode"
# Change the charachter(s) used to seperate modules. If two are used, they will be placed at the start and end.
export SEP1="["
export SEP2="]"
# Import the modules # Import the modules
. "$DIR/bar-functions/dwm_countdown.sh" . "$DIR/bar-functions/dwm_countdown.sh"
@ -37,6 +40,6 @@ export IDENTIFIER="unicode"
# Update dwm status bar every second # Update dwm status bar every second
while true while true
do do
xsetroot -name "[$(dwm_countdown)][$(dwm_transmission)][$(dwm_cmus)][$(dwm_resources)][$(dwm_battery)][$(dwm_mail)][$(dwm_backlight)][$(dwm_alsa)][$(dwm_weather)][$(dwm_vpn)][$(dwm_network)][$(dwm_keyboard)][$(dwm_date)]"
xsetroot -name "$(dwm_countdown)$(dwm_transmission)$(dwm_cmus)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_backlight)$(dwm_alsa)$(dwm_pulse)$(dwm_weather)$(dwm_vpn)$(dwm_network)$(dwm_keyboard)$(dwm_date)]"
sleep 1 sleep 1
done done

Loading…
Cancel
Save