Browse Source

Added dwm_network and dwm_vpn

main
joestandring 5 years ago
parent
commit
9db18469c4
13 changed files with 318 additions and 16 deletions
  1. +18
    -4
      README.md
  2. +34
    -0
      bar-functions/dwm_alsa.sh
  3. +51
    -0
      bar-functions/dwm_cmus.sh
  4. +23
    -0
      bar-functions/dwm_countdown.sh
  5. +16
    -0
      bar-functions/dwm_date.sh
  6. +17
    -0
      bar-functions/dwm_keyboard.sh
  7. +23
    -0
      bar-functions/dwm_mail.sh
  8. +21
    -0
      bar-functions/dwm_network.sh
  9. +34
    -0
      bar-functions/dwm_pulse.sh
  10. +25
    -0
      bar-functions/dwm_resources.sh
  11. +23
    -0
      bar-functions/dwm_vpn.sh
  12. +19
    -0
      bar-functions/dwm_weather.sh
  13. +14
    -12
      dwm_bar.sh

+ 18
- 4
README.md View File

@ -4,6 +4,7 @@ A modular statusbar for DWM
- [Features](#features) - [Features](#features)
- [Current Functions](#current-functions) - [Current Functions](#current-functions)
- [dwm_alsa](#dwm_alsa) - [dwm_alsa](#dwm_alsa)
- [dwm_pulse](#dwm_pulse)
- [dwm_countdown](#dwm_countdown) - [dwm_countdown](#dwm_countdown)
- [dwm_keyboard](#dwm_keyboard) - [dwm_keyboard](#dwm_keyboard)
- [dwm_resources](#dwm_resources) - [dwm_resources](#dwm_resources)
@ -11,6 +12,8 @@ A modular statusbar for DWM
- [dwm_date](#dwm_date) - [dwm_date](#dwm_date)
- [dwm_mail](#dwm_mail) - [dwm_mail](#dwm_mail)
- [dwm_weather](#dwm_weather) - [dwm_weather](#dwm_weather)
- [dwm_network](#dwm_network)
- [dwm_vpn](#dwm_vpn)
- [Installation](#installation) - [Installation](#installation)
- [Usage](#usage) - [Usage](#usage)
- [Customizing](#customizing) - [Customizing](#customizing)
@ -26,18 +29,19 @@ Displays the current master volume of ALSA
``` ```
[🔉 55] [🔉 55]
``` ```
Dependencies: ```alsa-utils```
### dwm_pulse ### dwm_pulse
Displays the current master volume of PulseAudio Displays the current master volume of PulseAudio
``` ```
[🔉 55] [🔉 55]
``` ```
Dependencies: ```alsa-utils```
Dependencies: ```pamixer```
### dwm_countdown ### dwm_countdown
Displays the status of [countdown](https://github.com/joestandring/countdown) Displays the status of [countdown](https://github.com/joestandring/countdown)
``` ```
[⏳ 00:10:00] [⏳ 00:10:00]
``` ```
Dependeincies: ```[countdown](https://github.com/joestandring/countdown)```
Dependencies: ```[countdown](https://github.com/joestandring/countdown)```
### dwm_keyboard ### dwm_keyboard
Displays the current keyboard layout Displays the current keyboard layout
``` ```
@ -70,6 +74,18 @@ Displays the current weather provided by [wttr.in](https://wttr.in)
``` ```
[☀ +20°C] [☀ +20°C]
``` ```
### dwm_network
Displays the current network connection, private IP, and public IP
```
[🌐 enp7s0: 192.168.0.1/24 | 185.199.109.153]
```
Dependencies: ```NetworkManager, curl```
### dwm_vpn
Displays the current VPN connection
```
[🔒 Sweden - Stockholm]
```
Dependencies: ```NetworkManager-openvpn```
## Installation ## Installation
1. Clone and enter the repository: 1. Clone and enter the repository:
``` ```
@ -123,6 +139,4 @@ Code for some functions was modified from:
* [suckless.org](https://dwm.suckless.org/status_monitor/) * [suckless.org](https://dwm.suckless.org/status_monitor/)
## More to come! ## More to come!
* dwm_bat function to display battery percentage and status * dwm_bat function to display battery percentage and status
* dwm_notifs function to show the last recieved notification in the bar
* dwm_bluez function to show currently connected Bluetooth device using bluez * dwm_bluez function to show currently connected Bluetooth device using bluez
* The ability to show network speeds and SSID in dwm_network

+ 34
- 0
bar-functions/dwm_alsa.sh View File

@ -0,0 +1,34 @@
#!/bin/sh
# A dwm_bar function to show the master volume of ALSA
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: alsa-utils
dwm_alsa () {
VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/")
if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$VOL" -eq 0 ]; then
printf "[🔇 %s]\n" "$VOL]\n"
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
printf "[🔈 %s]\n" "$VOL"
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
printf "[🔉 %s]\n" "$VOL"
else
printf "[🔊 %s]\n" "$VOL"
fi
else
if [ "$VOL" -eq 0 ]; then
printf "[VOL %s]\n" "$VOL]\n"
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
printf "[VOL %s]\n" "$VOL"
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
printf "[VOL %s]\n" "$VOL"
else
printf "[VOL %s]\n" "$VOL"
fi
fi
}
dwm_alsa

+ 51
- 0
bar-functions/dwm_cmus.sh View File

@ -0,0 +1,51 @@
#!/bin/sh
# A dwm_bar function that shows the current artist, track, position, duration, and status from cmus
# Joe Standring <git@joestandring.com>
# 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 " "$STATUS" "$ARTIST" "$TRACK"
printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60))
printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60))
printf "%s]\n" "$SHUFFLE"
fi
}
dwm_cmus

+ 23
- 0
bar-functions/dwm_countdown.sh View File

@ -0,0 +1,23 @@
#!/bin/sh
# A dwm_status function that displays the status of countdown.sh
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: https://github.com/joestandring/countdown
dwm_countdown () {
for f in /tmp/countdown.*; do
if [ -e "$f" ]; then
if [ "$IDENTIFIER" = "unicode" ]; then
printf "[⏳ %s]\n" "$(tail -1 /tmp/countdown.*)"
else
printf "[CDN %s]\n" "$(tail -1 /tmp/countdown.*)"
fi
break
fi
done
}
dwm_countdown

+ 16
- 0
bar-functions/dwm_date.sh View File

@ -0,0 +1,16 @@
#!/bin/sh
# A dwm_bar function that shows the current date and time
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# 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")"
else
printf "[DAT %s]\n" "$(date "+%a %d-%m-%y %T")"
fi
}
dwm_date

+ 17
- 0
bar-functions/dwm_keyboard.sh View File

@ -0,0 +1,17 @@
#!/bin/sh
# A dwm_bar function that displays the current keyboard layout
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: xorg-setxkbmap
dwm_keyboard () {
if [ "$IDENTIFIER" = "unicode" ]; then
printf "[⌨ %s]\n" "$(setxkbmap -query | awk '/layout/{print $2}')"
else
printf "[KEY %s]\n" "$(setxkbmap -query | awk '/layout/{print $2}')"
fi
}
dwm_keyboard

+ 23
- 0
bar-functions/dwm_mail.sh View File

@ -0,0 +1,23 @@
#!/bin/sh
# A dwm_bar function to display the number of emails in an inbox
# Joe Standring <git@joestandring.com>
# 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 [ "$IDENTIFIER" = "unicode" ]; then
if [ "$MAILBOX" -eq 0 ]; then
printf "[📪 %s]\n" "$MAILBOX"
else
printf "[📫 %s]\n" "$MAILBOX"
fi
else
printf "[MAI %s]\n" "$MAILBOX"
fi
}
dwm_mail

+ 21
- 0
bar-functions/dwm_network.sh View File

@ -0,0 +1,21 @@
#!/bin/sh
# A dwm_bar function to show the current network connection, private IP, and public IP
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: NetworkManager, curl
dwm_network () {
CONNAME=$(nmcli -a | grep 'Wired connection' | awk 'NR==1{print $1}')
PRIVATE=$(nmcli -a | grep 'inet4 192' | awk '{print $2}')
PUBLIC=$(curl -s https://ipinfo.io/ip)
if [ "$IDENTIFIER" = "unicode" ]; then
printf "[🌐 %s %s | %s]\n" "$CONNAME" "$PRIVATE" "$PUBLIC"
else
printf "[NET %s %s | %s]\n" "$CONNAME" "$PRIVATE" "$PUBLIC"
fi
}
dwm_network

+ 34
- 0
bar-functions/dwm_pulse.sh View File

@ -0,0 +1,34 @@
#!/bin/sh
# A dwm_bar function to show the master volume of PulseAudio
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: pamixer
dwm_pulse () {
VOL=$(pamixer --get-volume)
if [ "$IDENTIFIER" = "unicode" ]; then
if [ "$VOL" -eq 0 ]; then
printf "[🔇 %s]\n" "$VOL]\n"
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
printf "[🔈 %s]\n" "$VOL"
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
printf "[🔉 %s]\n" "$VOL"
else
printf "[🔊 %s]\n" "$VOL"
fi
else
if [ "$VOL" -eq 0 ]; then
printf "[VOL %s]\n" "$VOL]\n"
elif [ "$VOL" -gt 0 ] && [ "$VOL" -le 33 ]; then
printf "[VOL %s]\n" "$VOL"
elif [ "$VOL" -gt 33 ] && [ "$VOL" -le 66 ]; then
printf "[VOL %s]\n" "$VOL"
else
printf "[VOL %s]\n" "$VOL"
fi
fi
}
dwm_pulse

+ 25
- 0
bar-functions/dwm_resources.sh View File

@ -0,0 +1,25 @@
#!/bin/sh
# A dwm_bar function to display information regarding system memory, CPU temperature, and storage
# Joe Standring <git@joestandring.com>
# 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}')
if [ "$IDENTIFIER" = "unicode" ]; then
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"
fi
}
dwm_resources

+ 23
- 0
bar-functions/dwm_vpn.sh View File

@ -0,0 +1,23 @@
#!/bin/sh
# A dwm_bar function to show VPN connections (if any are active)
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: NetworkManager-openvpn
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"
fi
else
if [ "$VPN" != "" ]; then
printf "[VPN %s]\n" "$VPN"
fi
fi
}
dwm_vpn

+ 19
- 0
bar-functions/dwm_weather.sh View File

@ -0,0 +1,19 @@
#!/bin/sh
# A dwm_bar function to print the weather from wttr.in
# Joe Standring <git@joestandring.com>
# GNU GPLv3
# Dependencies: curl
# Change the value of LOCATION to match your city
dwm_weather() {
LOCATION=city
if [ "$IDENTIFIER" = "unicode" ]; then
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].*")"
fi
}
dwm_weather

+ 14
- 12
dwm_bar.sh View File

@ -7,7 +7,7 @@
# Dependencies: xorg-xsetroot # Dependencies: xorg-xsetroot
# Import functions with "$include /route/to/module" # Import functions with "$include /route/to/module"
# It is recommended that you place functions in the subdirectory ./functions and use: . "$DIR/modules/dwm_example.sh"
# It is recommended that you place functions in the subdirectory ./bar-functions and use: . "$DIR/bar-functions/dwm_example.sh"
# Store the directory the script is running from # Store the directory the script is running from
LOC=$(readlink -f "$0") LOC=$(readlink -f "$0")
@ -15,22 +15,24 @@ 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"
# Import the modules # 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_pulse.sh"
. "$DIR/functions/dwm_weather.sh"
. "$DIR/functions/dwm_keyboard.sh"
. "$DIR/functions/dwm_date.sh"
. "$DIR/bar-functions/dwm_countdown.sh"
. "$DIR/bar-functions/dwm_cmus.sh"
. "$DIR/bar-functions/dwm_resources.sh"
. "$DIR/bar-functions/dwm_mail.sh"
. "$DIR/bar-functions/dwm_alsa.sh"
. "$DIR/bar-functions/dwm_pulse.sh"
. "$DIR/bar-functions/dwm_weather.sh"
. "$DIR/bar-functions/dwm_vpn.sh"
. "$DIR/bar-functions/dwm_network.sh"
. "$DIR/bar-functions/dwm_keyboard.sh"
. "$DIR/bar-functions/dwm_date.sh"
# Update dwm status bar every second # Update dwm status bar every second
while true while true
do do
xsetroot -name "$(dwm_countdown)$(dwm_cmus)$(dwm_resources)$(dwm_mail)$(dwm_alsa)$(dwm_weather)$(dwm_keyboard)$(dwm_date)"
xsetroot -name "$(dwm_countdown)$(dwm_cmus)$(dwm_resources)$(dwm_mail)$(dwm_alsa)$(dwm_weather)$(dwm_vpn)$(dwm_network)$(dwm_keyboard)$(dwm_date)"
sleep 1 sleep 1
done done

Loading…
Cancel
Save