From 086b6306baacf219c2e25a03a1a7b1c6b95f0547 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Mon, 30 Oct 2023 10:44:43 +0100 Subject: [PATCH] changed to unofficial SpeedTest in network utilities functions --- .config/picom.conf | 1 - .scripts/network_utilities.sh | 29 ++++++++++++++++++++++++++--- .zshrc | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) delete mode 120000 .config/picom.conf diff --git a/.config/picom.conf b/.config/picom.conf deleted file mode 120000 index ede6123..0000000 --- a/.config/picom.conf +++ /dev/null @@ -1 +0,0 @@ -picom.conf##class.arch_desktop \ No newline at end of file diff --git a/.scripts/network_utilities.sh b/.scripts/network_utilities.sh index e976ecd..279a201 100644 --- a/.scripts/network_utilities.sh +++ b/.scripts/network_utilities.sh @@ -1,8 +1,7 @@ # network utility functions # get the ip address of the host -function get_local_ip() { - echo -e "The interfaces and IPs are:\n$(ip -o -4 addr show | awk '/inet 192.168|inet 10.|inet 172.16/ {split($4, a, "/"); print $2 ": " a[1] "\n"}')" +function get_local_ip() { echo -e "The interfaces and IPs are:\n$(ip -o -4 addr show | awk '/inet 192.168|inet 10.|inet 172.16/ {split($4, a, "/"); print $2 ": " a[1] "\n"}')" } function get_public_ip() { @@ -11,7 +10,7 @@ function get_public_ip() { } function is_dns_working() { - dns_working=$(ping -c 1 google.com | grep "1 received" | wc -l) + dns_working=$(ping -4 -c 1 google.com | grep "1 received" | wc -l) if [ $dns_working -eq 1 ]; then return 0 else @@ -26,8 +25,32 @@ function reconnect_vpn_on_dns_failure() { if ! is_dns_working; then echo "DNS is not working, reconnecting VPN" mullvad reconnect + echo $(mullvad status) + else echo "DNS is working, no need to reconnect VPN" fi } +function check_internet_speed() { + # check if user has permissions to /var/log + if [ ! -w /var/log ]; then + echo "Permissions to /var/log are not available" + echo "Resorting to home directory for log file" + logfile=~/speedtest.log + else + echo "Permissions to /var/log are available" + logfile=/var/log/speedtest.log + fi + + # make sure dns is working properly + reconnect_vpn_on_dns_failure + + # add time and date to logfile + echo -e "\n\n$(date)" >> $logfile + + echo "Running speedtest" + SpeedTest | tee -a $logfile + echo "Speedtest complete" +} + diff --git a/.zshrc b/.zshrc index 2527895..a644abc 100644 --- a/.zshrc +++ b/.zshrc @@ -147,7 +147,7 @@ bindkey '5D' backward-word bindkey '5C' forward-word bindkey '^[[3~' delete-char -powerline-config tmux setup +#powerline-config tmux setup alias vim=nvim alias sudo='sudo '