From 26d3628594fd20313f19675851051c3bbbc91c44 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 18:33:10 +0100 Subject: [PATCH 1/5] Moved the internet module to c --- modules/internet | Bin 177 -> 16536 bytes modules/src/internet.c | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 modules/src/internet.c diff --git a/modules/internet b/modules/internet index 7c06858b3d69237f78df682927f293647151c544..6fe6aec66207af99205414b77c71dde9c36e05cc 100755 GIT binary patch literal 16536 zcmeHOUu;`f89%n0HeDMh?OGbzvY4%%(uug~zmTlTYA11egWNx~$<~Rrw@&OP7LHxn z*IQbU7Byp%)urnLJOB^$v6^^5XhIwC&?;5wL?2onpa>ztv_ghpO@X2?Sk3p{`~94I zubpY)0fD$DvVZ6NzVAEdJKsI``kdTzUXI24{XU;U3aDokmm*CT6A{6&F3Au?RHs@+ z-=9&N)p9B?GdW8hv4Esj8uL4`UibhZ+g%p98#jv{5FRqJ-BRgToh1P(=?B}HA}NCh z-jxP`;4AHgq(v7tiyhEz$FZ4fv+U-&ov2B_4-3MMi)^*QZ??jXa$7b7s-zO{G7TbyW{=}V@vSdm&a@9D~i(yhowWE zE*b@;>mw5h{Zu-e$fVDvsK|1?U?lQ}KAuQt)&BTEPp`f+yfeH<=>vlY^kgcZ8ci3B zRDSS4Zzh*b4JL*&Y&klf%ZjCLsn%3vr~DFEKgE>)tk|=pxG}wwMZk-I7XdEoU)O+)X2jkOqFVYlT zn{FtRmNwmeo1nZtPj-L3NX54)qfOU+pP_5PSWitK&dHsBt)*&O*nd^0%iSQktITdbfd4=6jGp82w+<&g`{ZY~#qB%>PG>iWyi0i|MAkF=EUgX!31Z zy`ugit^S$kclWdR%4J@0tG*TH8@w%)<#sL;A0kx2rv6~_7aCW+R6nWqZQT3Rt}W(k zO}2f3KHnrCo@Bjfu<2EQZ^QBgH9$pL;;XOH=Mu?NgsMN-^tyi_*nA-n3x=kb#e%J` z)%6A2UtO*RJEvCc4@R=V&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r;1+n*~W;4zBj66S9>ck9+i z8F-UyX_iv4$9iC1&Lu;SRLq1jkp1JagZ8m*z`5pG4h|)ZFWBKa{+48{0(-14?#M)^ zm5pr)_Q2nf%xE(ZXb$Rnjx`=pKg1UA5eztg8!IbwTnI4fj+lo zPajf&IZ>~OU@z0S3J-fbV(e9vD5If52|VA&d`aOCo(n69gYT5BB#nONX%0Jil-LkrIsip z=jY|6CYNO9=K<9Rr52WE7Nz1;!R6@};u_@V8WQj6?C)o*{=R9AIu}=ZYDqlIJPl2* ZYAyvJNKMYjS5Q(x(V)ati>jK73jm~&IuQT> 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 + +int main() +{ + char *internet_icon = ""; + + printf("%s\n", internet_icon); + + return 0; +} From 549ccc0f41f20dfce4d3da52a4ff5199a2c03c08 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 20:09:35 +0100 Subject: [PATCH 2/5] Added networkup and networkdown modules --- modules/archupdates | 4 ++-- modules/fanspeed | 13 +++++++++++++ modules/kernel | 12 ++++++++++++ modules/localip | 12 ++++++++++++ modules/networkdowntraffic | 31 +++++++++++++++++++++++++++++++ modules/networkuptraffic | 32 ++++++++++++++++++++++++++++++++ modules/publicip | 13 +++++++++++++ modules/voidupdates | 16 ++++++++++++++++ 8 files changed, 131 insertions(+), 2 deletions(-) create mode 100755 modules/fanspeed create mode 100755 modules/kernel create mode 100755 modules/localip create mode 100755 modules/networkdowntraffic create mode 100755 modules/networkuptraffic create mode 100755 modules/publicip create mode 100755 modules/voidupdates 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/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/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..d82d24b --- /dev/null +++ b/modules/networkdowntraffic @@ -0,0 +1,31 @@ +#!/bin/bash + +# Prints out the current down network traffic in DJNADJNA + +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 2 + + 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 ) / 1000000)MB" +} + +get_down_traffic diff --git a/modules/networkuptraffic b/modules/networkuptraffic new file mode 100755 index 0000000..6907928 --- /dev/null +++ b/modules/networkuptraffic @@ -0,0 +1,32 @@ +#!/bin/bash + +# Prints out the current up network traffic in DJNADJNA + +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 2 + + 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) / 1000000)MB" +} + +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/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 From 8a259103551d200fc5b5b641e36b7eada0728759 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 24 Oct 2019 20:14:42 +0100 Subject: [PATCH 3/5] Added a delta var for the network up and down modules --- modules/networkdowntraffic | 5 +++-- modules/networkuptraffic | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/networkdowntraffic b/modules/networkdowntraffic index d82d24b..ea270e3 100755 --- a/modules/networkdowntraffic +++ b/modules/networkdowntraffic @@ -1,11 +1,12 @@ #!/bin/bash -# Prints out the current down network traffic in DJNADJNA +# Prints out the current down network traffic in MB PREFIX=' ' get_down_traffic() { + DELTA=2 RECIEVE1=0 RECIEVE2=0 @@ -16,7 +17,7 @@ get_down_traffic() fi done - sleep 2 + sleep $DELTA IFACES=$(ip -o link show | awk -F': ' '{print $2}') for IFACE in $IFACES; do diff --git a/modules/networkuptraffic b/modules/networkuptraffic index 6907928..5c7dc13 100755 --- a/modules/networkuptraffic +++ b/modules/networkuptraffic @@ -1,11 +1,12 @@ #!/bin/bash -# Prints out the current up network traffic in DJNADJNA +# Prints out the current up network traffic in MB PREFIX=' ' get_up_traffic() { + DELTA=2 TRANSMIT1=0 TRANSMIT2=0 @@ -16,7 +17,7 @@ get_up_traffic() fi done - sleep 2 + sleep $DELTA IFACES=$(ip -o link show | awk -F': ' '{print $2}') for IFACE in $IFACES; do From 21d96d4758812cda52d6bcb310f1a62f2db422ce Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Fri, 25 Oct 2019 12:24:25 +0100 Subject: [PATCH 4/5] Added todo item --- TODO.org | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO.org b/TODO.org index fdf747e..c99764c 100644 --- a/TODO.org +++ b/TODO.org @@ -12,6 +12,8 @@ Each module writes to stdout. * Todo List - Delay in archupdates module (if minutes divisible by 5/4) - Add dependencies like bc +- Networkup/down modules in kb instead of mb? and change sleep to 1s so that + output is XMb/s Bugs to fix: None From fe7633cd1b14275540dfba051b67c6bcef03ecc7 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Fri, 25 Oct 2019 12:39:51 +0100 Subject: [PATCH 5/5] Changed units in networkup/down modules --- TODO.org | 2 -- modules/networkdowntraffic | 5 ++--- modules/networkuptraffic | 5 ++--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/TODO.org b/TODO.org index c99764c..fdf747e 100644 --- a/TODO.org +++ b/TODO.org @@ -12,8 +12,6 @@ Each module writes to stdout. * Todo List - Delay in archupdates module (if minutes divisible by 5/4) - Add dependencies like bc -- Networkup/down modules in kb instead of mb? and change sleep to 1s so that - output is XMb/s Bugs to fix: None diff --git a/modules/networkdowntraffic b/modules/networkdowntraffic index ea270e3..f1b5584 100755 --- a/modules/networkdowntraffic +++ b/modules/networkdowntraffic @@ -6,7 +6,6 @@ PREFIX=' ' get_down_traffic() { - DELTA=2 RECIEVE1=0 RECIEVE2=0 @@ -17,7 +16,7 @@ get_down_traffic() fi done - sleep $DELTA + sleep 1 IFACES=$(ip -o link show | awk -F': ' '{print $2}') for IFACE in $IFACES; do @@ -26,7 +25,7 @@ get_down_traffic() fi done - echo "$PREFIX$(expr $(expr $RECIEVE2 - $RECIEVE1 ) / 1000000)MB" + echo "$PREFIX$(expr $(expr $RECIEVE2 - $RECIEVE1 ) / 1000)KB/s" } get_down_traffic diff --git a/modules/networkuptraffic b/modules/networkuptraffic index 5c7dc13..6b002e6 100755 --- a/modules/networkuptraffic +++ b/modules/networkuptraffic @@ -6,7 +6,6 @@ PREFIX=' ' get_up_traffic() { - DELTA=2 TRANSMIT1=0 TRANSMIT2=0 @@ -17,7 +16,7 @@ get_up_traffic() fi done - sleep $DELTA + sleep 1 IFACES=$(ip -o link show | awk -F': ' '{print $2}') for IFACE in $IFACES; do @@ -26,7 +25,7 @@ get_up_traffic() fi done - echo "$PREFIX$(expr $(expr $TRANSMIT2 - $TRANSMIT1) / 1000000)MB" + echo "$PREFIX$(expr $(expr $TRANSMIT2 - $TRANSMIT1) / 1000)KB/s" } get_up_traffic