From 3f9c43864fa7b761b0207efc1180259b0c23dca5 Mon Sep 17 00:00:00 2001 From: joestandring Date: Thu, 27 Jun 2019 17:49:28 +0100 Subject: [PATCH] Modified dwm_bar.sh formatting - Individual functions no longer contain the square brackets to act as seperators. These are instead included in the xsetroot command within dwm_bar.sh itself so that they can be modified much more easily if the user desires. - Fixed dwm_battery.sh showing a space between the level and '%' symbol when discharging. - Added dwm_ccurse to dwm_bar.sh. Guess I forgot that. --- bar-functions/dwm_alsa.sh | 16 ++++++++-------- bar-functions/dwm_battery.sh | 6 +++--- bar-functions/dwm_ccurse.sh | 4 ++-- bar-functions/dwm_cmus.sh | 4 ++-- bar-functions/dwm_countdown.sh | 4 ++-- bar-functions/dwm_date.sh | 4 ++-- bar-functions/dwm_keyboard.sh | 4 ++-- bar-functions/dwm_mail.sh | 6 +++--- bar-functions/dwm_network.sh | 4 ++-- bar-functions/dwm_pulse.sh | 16 ++++++++-------- bar-functions/dwm_resources.sh | 4 ++-- bar-functions/dwm_transmission.sh | 12 ++++++------ bar-functions/dwm_vpn.sh | 4 ++-- bar-functions/dwm_weather.sh | 4 ++-- dwm_bar.sh | 3 ++- 15 files changed, 48 insertions(+), 47 deletions(-) diff --git a/bar-functions/dwm_alsa.sh b/bar-functions/dwm_alsa.sh index dca6204..d670256 100755 --- a/bar-functions/dwm_alsa.sh +++ b/bar-functions/dwm_alsa.sh @@ -10,23 +10,23 @@ dwm_alsa () { VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/") if [ "$IDENTIFIER" = "unicode" ]; then if [ "$VOL" -eq 0 ]; then - printf "[🔇]\n" + printf "🔇\n" elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then - printf "[🔈 %s%%]\n" "$VOL" + printf "🔈 %s%%\n" "$VOL" elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then - printf "[🔉 %s%%]\n" "$VOL" + printf "🔉 %s%%\n" "$VOL" else - printf "[🔊 %s%%]\n" "$VOL" + printf "🔊 %s%%\n" "$VOL" fi else if [ "$VOL" -eq 0 ]; then - printf "[MUTE]\n" + printf "MUTE\n" elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then - printf "[VOL %s%%]\n" "$VOL" + printf "VOL %s%%\n" "$VOL" elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then - printf "[VOL %s%%]\n" "$VOL" + printf "VOL %s%%\n" "$VOL" else - printf "[VOL %s%%]\n" "$VOL" + printf "VOL %s%%\n" "$VOL" fi fi } diff --git a/bar-functions/dwm_battery.sh b/bar-functions/dwm_battery.sh index 6c139cf..b26c00f 100755 --- a/bar-functions/dwm_battery.sh +++ b/bar-functions/dwm_battery.sh @@ -11,12 +11,12 @@ dwm_battery () { if [ "$IDENTIFIER" = "unicode" ]; then if [ "$STATUS" = "Charging" ]; then - printf "[🔌 %s%% %s]\n" "$CHARGE" "$STATUS" + printf "🔌 %s%% %s\n" "$CHARGE" "$STATUS" else - printf "[🔋 %s %%%s]\n" "$CHARGE" "$STATUS" + printf "🔋 %s%% %s\n" "$CHARGE" "$STATUS" fi else - printf "[BAT %s%% %s]\n" "$CHARGE" "$STATUS" + printf "BAT %s%% %s\n" "$CHARGE" "$STATUS" fi } diff --git a/bar-functions/dwm_ccurse.sh b/bar-functions/dwm_ccurse.sh index 10e6cee..981bb1e 100755 --- a/bar-functions/dwm_ccurse.sh +++ b/bar-functions/dwm_ccurse.sh @@ -10,9 +10,9 @@ dwm_ccurse () { APPOINTMENT=$(calcurse -a | head -n 3 | tr -d '\n+>-' | awk '$1=$1' | sed 's/://') if [ "$IDENTIFIER" = "unicode" ]; then - printf "[💡 %s]\n" "$APPOINTMENT" + printf "💡 %s\n" "$APPOINTMENT" else - printf "[APT %s]\n" "$APPOINTMENT" + printf "APT %s\n" "$APPOINTMENT" fi } diff --git a/bar-functions/dwm_cmus.sh b/bar-functions/dwm_cmus.sh index 2b8294c..0c4595c 100755 --- a/bar-functions/dwm_cmus.sh +++ b/bar-functions/dwm_cmus.sh @@ -41,10 +41,10 @@ dwm_cmus () { fi fi - printf "[%s %s - %s " "$STATUS" "$ARTIST" "$TRACK" + printf "%s %s - %s " "$STATUS" "$ARTIST" "$TRACK" printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60)) printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60)) - printf "%s]\n" "$SHUFFLE" + printf "%s\n" "$SHUFFLE" fi } diff --git a/bar-functions/dwm_countdown.sh b/bar-functions/dwm_countdown.sh index 7ba938e..b89e36c 100755 --- a/bar-functions/dwm_countdown.sh +++ b/bar-functions/dwm_countdown.sh @@ -10,9 +10,9 @@ dwm_countdown () { for f in /tmp/countdown.*; do if [ -e "$f" ]; then if [ "$IDENTIFIER" = "unicode" ]; then - printf "[⏳ %s]\n" "$(tail -1 /tmp/countdown.*)" + printf "⏳ %s\n" "$(tail -1 /tmp/countdown.*)" else - printf "[CDN %s]\n" "$(tail -1 /tmp/countdown.*)" + printf "CDN %s\n" "$(tail -1 /tmp/countdown.*)" fi break diff --git a/bar-functions/dwm_date.sh b/bar-functions/dwm_date.sh index 4550fa2..43a4a96 100755 --- a/bar-functions/dwm_date.sh +++ b/bar-functions/dwm_date.sh @@ -7,9 +7,9 @@ # Date is formatted like like this: "[Mon 01-01-00 00:00:00]" dwm_date () { if [ "$IDENTIFIER" = "unicode" ]; then - printf "[📆 %s]\n" "$(date "+%a %d-%m-%y %T")" + printf "📆 %s\n" "$(date "+%a %d-%m-%y %T")" else - printf "[DAT %s]\n" "$(date "+%a %d-%m-%y %T")" + printf "DAT %s\n" "$(date "+%a %d-%m-%y %T")" fi } diff --git a/bar-functions/dwm_keyboard.sh b/bar-functions/dwm_keyboard.sh index 686afb6..38f514c 100755 --- a/bar-functions/dwm_keyboard.sh +++ b/bar-functions/dwm_keyboard.sh @@ -8,9 +8,9 @@ dwm_keyboard () { if [ "$IDENTIFIER" = "unicode" ]; then - printf "[⌨ %s]\n" "$(setxkbmap -query | awk '/layout/{print $2}')" + printf "⌨ %s\n" "$(setxkbmap -query | awk '/layout/{print $2}')" else - printf "[KEY %s]\n" "$(setxkbmap -query | awk '/layout/{print $2}')" + printf "KEY %s\n" "$(setxkbmap -query | awk '/layout/{print $2}')" fi } diff --git a/bar-functions/dwm_mail.sh b/bar-functions/dwm_mail.sh index c50ee90..19478a0 100755 --- a/bar-functions/dwm_mail.sh +++ b/bar-functions/dwm_mail.sh @@ -11,12 +11,12 @@ dwm_mail () { if [ "$IDENTIFIER" = "unicode" ]; then if [ "$MAILBOX" -eq 0 ]; then - printf "[📪 %s]\n" "$MAILBOX" + printf "📪 %s\n" "$MAILBOX" else - printf "[📫 %s]\n" "$MAILBOX" + printf "📫 %s\n" "$MAILBOX" fi else - printf "[MAI %s]\n" "$MAILBOX" + printf "MAI %s\n" "$MAILBOX" fi } diff --git a/bar-functions/dwm_network.sh b/bar-functions/dwm_network.sh index 536fe7c..8d6e6fb 100755 --- a/bar-functions/dwm_network.sh +++ b/bar-functions/dwm_network.sh @@ -16,9 +16,9 @@ dwm_network () { PUBLIC=$(curl -s https://ipinfo.io/ip) if [ "$IDENTIFIER" = "unicode" ]; then - printf "[🌐 %s %s | %s]\n" "$CONNAME" "$PRIVATE" "$PUBLIC" + printf "🌐 %s %s | %s\n" "$CONNAME" "$PRIVATE" "$PUBLIC" else - printf "[NET %s %s | %s]\n" "$CONNAME" "$PRIVATE" "$PUBLIC" + printf "NET %s %s | %s\n" "$CONNAME" "$PRIVATE" "$PUBLIC" fi } diff --git a/bar-functions/dwm_pulse.sh b/bar-functions/dwm_pulse.sh index 84f40fc..f137436 100755 --- a/bar-functions/dwm_pulse.sh +++ b/bar-functions/dwm_pulse.sh @@ -10,23 +10,23 @@ dwm_pulse () { VOL=$(pamixer --get-volume-human | tr -d '%') if [ "$IDENTIFIER" = "unicode" ]; then if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then - printf "[🔇]\n" + printf "🔇\n" elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then - printf "[🔈 %s%%]\n" "$VOL" + printf "🔈 %s%%\n" "$VOL" elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then - printf "[🔉 %s%%]\n" "$VOL" + printf "🔉 %s%%\n" "$VOL" else - printf "[🔊 %s%%]\n" "$VOL" + printf "🔊 %s%%\n" "$VOL" fi else if [ "$VOL" = "muted" ] || [ "$VOL" -eq 0 ]; then - printf "[MUTE]\n" + printf "MUTE\n" elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then - printf "[VOL %s%%]\n" "$VOL" + printf "VOL %s%%\n" "$VOL" elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then - printf "[VOL %s%%]\n" "$VOL" + printf "VOL %s%%\n" "$VOL" else - printf "[VOL %s%%]\n" "$VOL" + printf "VOL %s%%\n" "$VOL" fi fi } diff --git a/bar-functions/dwm_resources.sh b/bar-functions/dwm_resources.sh index 87db9bb..2213316 100755 --- a/bar-functions/dwm_resources.sh +++ b/bar-functions/dwm_resources.sh @@ -16,9 +16,9 @@ dwm_resources () { STOPER=$(df -h | grep '/home$' | awk '{print $5}') 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\n" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER" 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\n" "$MEMUSED" "$MEMTOT" "$CPU" "$STOUSED" "$STOTOT" "$STOPER" fi } diff --git a/bar-functions/dwm_transmission.sh b/bar-functions/dwm_transmission.sh index ee21b4f..5a990c2 100755 --- a/bar-functions/dwm_transmission.sh +++ b/bar-functions/dwm_transmission.sh @@ -20,25 +20,25 @@ dwm_transmission () { if [ "$IDENTIFIER" = "unicode" ]; then case "$STATUS" in "Idle") - printf "[🛑 %s | %s %s ⬆%s ⬇%s]\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + printf "🛑 %s | %s %s ⬆%s ⬇%s\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" ;; "Seeding") - printf "[🌱 %s | ⬆%s ⬇%s]\n" "$NAME" "$UP" "$DOWN" + printf "🌱 %s | ⬆%s ⬇%s\n" "$NAME" "$UP" "$DOWN" ;; "Downloading") - printf "[⏬ %s | %s %s ⬆%s ⬇%s]\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + printf "⏬ %s | %s %s ⬆%s ⬇%s\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" ;; esac else case "$STATUS" in "Idle") - printf "[IDLE %s | %s %s ⬆%s ⬇%s]\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + printf "IDLE %s | %s %s ⬆%s ⬇%s\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" ;; "Seeding") - printf "[SEEDING %s | ⬆%s ⬇%s]\n" "$NAME" "$UP" "$DOWN" + printf "SEEDING %s | ⬆%s ⬇%s\n" "$NAME" "$UP" "$DOWN" ;; "Downloading") - printf "[DOWNLOADING %s | %s %s ⬆%s ⬇%s]\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + printf "DOWNLOADING %s | %s %s ⬆%s ⬇%s\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" ;; esac fi diff --git a/bar-functions/dwm_vpn.sh b/bar-functions/dwm_vpn.sh index a2558ad..8566d8c 100755 --- a/bar-functions/dwm_vpn.sh +++ b/bar-functions/dwm_vpn.sh @@ -10,11 +10,11 @@ dwm_vpn () { VPN=$(nmcli -a | grep 'VPN connection' | sed -e 's/\( VPN connection\)*$//g') if [ "$IDENTIFIER" = "unicode" ]; then if [ "$VPN" != "" ]; then - printf "[🔒 %s]\n" "$VPN" + printf "🔒 %s\n" "$VPN" fi else if [ "$VPN" != "" ]; then - printf "[VPN %s]\n" "$VPN" + printf "VPN %s\n" "$VPN" fi fi } diff --git a/bar-functions/dwm_weather.sh b/bar-functions/dwm_weather.sh index 678475d..6b82cef 100755 --- a/bar-functions/dwm_weather.sh +++ b/bar-functions/dwm_weather.sh @@ -10,9 +10,9 @@ dwm_weather() { LOCATION=city if [ "$IDENTIFIER" = "unicode" ]; then - printf "[%s]\n" "$(curl -s wttr.in/$LOCATION?format=1)" + printf "%s\n" "$(curl -s wttr.in/$LOCATION?format=1)" else - printf "[WEA %s]\n" "$(curl -s wttr.in/$LOCATION?format=1 | grep -o "[0-9].*")" + printf "WEA %s\n" "$(curl -s wttr.in/$LOCATION?format=1 | grep -o "[0-9].*")" fi } diff --git a/dwm_bar.sh b/dwm_bar.sh index a07114b..f635da3 100755 --- a/dwm_bar.sh +++ b/dwm_bar.sh @@ -30,11 +30,12 @@ export IDENTIFIER="unicode" . "$DIR/bar-functions/dwm_vpn.sh" . "$DIR/bar-functions/dwm_network.sh" . "$DIR/bar-functions/dwm_keyboard.sh" +. "$DIR/bar-functions/dwm_ccurse.sh" . "$DIR/bar-functions/dwm_date.sh" # Update dwm status bar every second while true do - xsetroot -name "$(dwm_countdown)$(dwm_transmission)$(dwm_cmus)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(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_alsa)][$(dwm_weather)][$(dwm_vpn)][$(dwm_network)][$(dwm_keyboard)][$(dwm_date)]" sleep 1 done