aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbar.sh12
-rwxr-xr-xmodules/archupdates4
-rwxr-xr-xmodules/battery67
-rwxr-xr-xmodules/fanspeed13
-rwxr-xr-xmodules/internetbin177 -> 16536 bytes
-rwxr-xr-xmodules/kernel12
-rwxr-xr-xmodules/localip12
-rwxr-xr-xmodules/networkdowntraffic31
-rwxr-xr-xmodules/networkuptraffic32
-rwxr-xr-xmodules/publicip13
-rw-r--r--modules/src/internet.c10
-rwxr-xr-xmodules/voidupdates16
12 files changed, 180 insertions, 42 deletions
diff --git a/bar.sh b/bar.sh
index f9866f4..1055177 100755
--- a/bar.sh
+++ b/bar.sh
@@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-
MODULES_DIR="/usr/share/dwmbar/modules/"
OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/"
@@ -41,8 +40,8 @@ get_bar()
{
for module in $MODULES; do
if [[ $INTERNET -eq 0 ]] || [[ $ONLINE_MODULES != *"$module"* ]];then
- module_out=$(cat $OUTPUT_CACHE$module | sed 's/\.$//g')
- bar=$bar$module_out
+ module_out="$(cat $OUTPUT_CACHE$module | sed 's/\.$//g')"
+ bar="$bar$module_out"
fi
done
# Uncomment to remove last separator
@@ -60,15 +59,16 @@ run_module()
fi
[[ ! "$out" = "" ]] && [[ ! "$module" = "NULL" ]] && out="$out$SEPARATOR."
- echo $out > "$OUTPUT_CACHE$module"
+ echo "$out" > "$OUTPUT_CACHE$module"
}
run()
{
get_internet
for module in $MODULES; do
- if [[ $INTERNET -eq 0 ]]; then
- run_module $module
+ pgrep $module &> /dev/null
+ if [[ $INTERNET -eq 0 ]] && [[ $? -eq 1 ]]; then
+ run_module $module &
else
[[ $ONLINE_MODULES != *"$module"* ]] && run_module $module
fi
diff --git a/modules/archupdates b/modules/archupdates
index ea44e2e..ad8b405 100755
--- a/modules/archupdates
+++ b/modules/archupdates
@@ -4,7 +4,7 @@
# Requires an internet connection
# Depends on yay and checkupdates (pacman-contrib)
-PREFIX=' Updates:'
+PREFIX=' Updates: '
get_updates()
{
@@ -18,7 +18,7 @@ get_updates()
updates=$(("$updates_arch" + "$updates_aur"))
- echo "$PREFIX $updates"
+ echo "$PREFIX$updates"
}
get_updates
diff --git a/modules/battery b/modules/battery
index 2802be9..901a66e 100755
--- a/modules/battery
+++ b/modules/battery
@@ -2,43 +2,42 @@
# Prints out battery percentage
-CHARGING_ICON=''
-WARNING_ICON=''
-BATTERY_FULL_ICON=''
-BATTERY_2_ICON=''
-BATTERY_3_ICON=''
-BATTERY_4_ICON=''
+CHARGING_ICON=' '
+WARNING_ICON=' '
+BATTERY_FULL_ICON=' '
+BATTERY_2_ICON=' '
+BATTERY_3_ICON=' '
+BATTERY_4_ICON=' '
+
+FULL_AT=98
+
+BAT_ICON=""
+ICON=""
get_battery()
{
- if [ -d /sys/class/power_supply/BAT? ]; then
- ac_adapter=$(cat /sys/class/power_supply/BAT?/status)
- if [ "$ac_adapter" == "Charging" ]; then
- echo "$CHARGING_ICON"
- fi
-
- # Will show all batteries with approximate icon for remaining power.
- for x in /sys/class/power_supply/BAT?/capacity;
- do
- case "$(cat $x)" in
- 100) echo "$BATTERY_FULL_ICON" ;;
- 9[0-9]) echo "$BATTERY_FULL_ICON $(cat $x)%" ;;
- 8[0-9]|7[0-9]) echo "$BATTERY_2_ICON $(cat $x)%" ;;
- 6[0-9]|5[0-9]) echo "$BATTERY_3_ICON $(cat $x)%" ;;
- 4[0-9]|3[0-9]) echo "$BATTERY_4_ICON $(cat $x)%" ;;
- 2[0-9]|1[0-9]) if [ "$ac_adapter" == "Charging" ]; then
- echo "$BATTERY_4_ICON $(cat $x)%"
- else
- echo "$WARNING_ICON $BATTERY_4_ICON $(cat $x)%"
- fi ;;
- [0-9]) if [ "$ac_adapter" == "Charging" ]; then
- echo "$BATTERY_4_ICON $(cat $x)%"
- else
- echo "$WARNING_ICON $BATTERY_4_ICON $(cat $x)%"
- fi ;;
- esac
- done
- fi
+ # The vast majority of people only use one battery.
+
+ if [ -d /sys/class/power_supply/BAT0 ]; then
+ capacity=$(cat /sys/class/power_supply/BAT0/capacity)
+ charging=$(cat /sys/class/power_supply/BAT0/status)
+ if [[ "$charging" == "Charging" ]]; then
+ ICON="$CHARGING_ICON"
+ elif [[ $capacity -le 25 ]]; then
+ ICON="$WARNING_ICON"
+ fi
+
+ if [[ $capacity -ge $FULL_AT ]]; then
+ BAT_ICON=$BATTERY_FULL_ICON
+ elif [[ $capacity -le 25 ]]; then
+ BAT_ICON=$BATTERY_4_ICON
+ elif [[ $capacity -le 50 ]]; then
+ BAT_ICON=$BATTERY_3_ICON
+ elif [[ $capacity -le $FULL_AT ]]; then
+ BAT_ICON=$BATTERY_2_ICON
+ fi
+ fi
+ echo "$ICON $BAT_ICON $capacity%"
}
get_battery
diff --git a/modules/fanspeed b/modules/fanspeed
new file mode 100755
index 0000000..16af999
--- /dev/null
+++ b/modules/fanspeed
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Prints the fan RPM
+# Depends on lm_sensors
+
+PREFIX=' '
+
+get_fan_speed()
+{
+ echo "$PREFIX$(sensors | grep fan1 | cut -d " " -f 9) RPM"
+}
+
+get_fan_speed
diff --git a/modules/internet b/modules/internet
index 7c06858..6fe6aec 100755
--- a/modules/internet
+++ b/modules/internet
Binary files differ
diff --git a/modules/kernel b/modules/kernel
new file mode 100755
index 0000000..1ee3939
--- /dev/null
+++ b/modules/kernel
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Prints out the kernel version
+
+PREFIX=' '
+
+get_kernel()
+{
+ echo "$PREFIX$(uname -r)"
+}
+
+get_kernel
diff --git a/modules/localip b/modules/localip
new file mode 100755
index 0000000..39629db
--- /dev/null
+++ b/modules/localip
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Prints out your local IP
+
+PREFIX='ﯱ '
+
+get_local_ip()
+{
+ echo "$PREFIX$(hostname -i)"
+}
+
+get_local_ip
diff --git a/modules/networkdowntraffic b/modules/networkdowntraffic
new file mode 100755
index 0000000..f1b5584
--- /dev/null
+++ b/modules/networkdowntraffic
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# Prints out the current down network traffic in MB
+
+PREFIX=' '
+
+get_down_traffic()
+{
+ RECIEVE1=0
+ RECIEVE2=0
+
+ IFACES=$(ip -o link show | awk -F': ' '{print $2}')
+ for IFACE in $IFACES; do
+ if [ $IFACE != "lo" ]; then
+ RECIEVE1=$(($(ip -s -c link show wlan0 | tail -n3 | head -n 1 | cut -d " " -f5) + $RECIEVE1))
+ fi
+ done
+
+ sleep 1
+
+ IFACES=$(ip -o link show | awk -F': ' '{print $2}')
+ for IFACE in $IFACES; do
+ if [ $IFACE != "lo" ]; then
+ RECIEVE2=$(($(ip -s -c link show wlan0 | tail -n3 | head -n 1 | cut -d " " -f5) + $RECIEVE2))
+ fi
+ done
+
+ echo "$PREFIX$(expr $(expr $RECIEVE2 - $RECIEVE1 ) / 1000)KB/s"
+}
+
+get_down_traffic
diff --git a/modules/networkuptraffic b/modules/networkuptraffic
new file mode 100755
index 0000000..6b002e6
--- /dev/null
+++ b/modules/networkuptraffic
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# Prints out the current up network traffic in MB
+
+PREFIX=' '
+
+get_up_traffic()
+{
+ TRANSMIT1=0
+ TRANSMIT2=0
+
+ IFACES=$(ip -o link show | awk -F': ' '{print $2}')
+ for IFACE in $IFACES; do
+ if [ $IFACE != "lo" ]; then
+ TRANSMIT1=$(($(ip -s -c link show wlan0 | tail -n1 | cut -d " " -f5) + TRANSMIT1))
+ fi
+ done
+
+ sleep 1
+
+ IFACES=$(ip -o link show | awk -F': ' '{print $2}')
+ for IFACE in $IFACES; do
+ if [ $IFACE != "lo" ]; then
+ TRANSMIT2=$(($(ip -s -c link show wlan0 | tail -n1 | cut -d " " -f5) + TRANSMIT2))
+ fi
+ done
+
+ echo "$PREFIX$(expr $(expr $TRANSMIT2 - $TRANSMIT1) / 1000)KB/s"
+}
+
+get_up_traffic
+
diff --git a/modules/publicip b/modules/publicip
new file mode 100755
index 0000000..2e94e04
--- /dev/null
+++ b/modules/publicip
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# Prints out your public IP adress
+# Depends on curl
+
+PREFIX=' '
+
+get_pub_ip()
+{
+ echo "$PREFIX$(curl -s ifconfig.co)"
+}
+
+get_pub_ip
diff --git a/modules/src/internet.c b/modules/src/internet.c
new file mode 100644
index 0000000..d0f6afd
--- /dev/null
+++ b/modules/src/internet.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+int main()
+{
+ char *internet_icon = "";
+
+ printf("%s\n", internet_icon);
+
+ return 0;
+}
diff --git a/modules/voidupdates b/modules/voidupdates
new file mode 100755
index 0000000..229fd42
--- /dev/null
+++ b/modules/voidupdates
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Prints the number of updates for Void Linux
+
+PREFIX=' Updates: '
+
+get_updates()
+{
+ if ! updates=$(xbps-install -Mun 2> /dev/null | wc -l ); then
+ updates=0
+ fi
+
+ echo "$PREFIX$updates"
+}
+
+get_updates