From c367348bf2d386f677a81e7f4032c5b32d6d2367 Mon Sep 17 00:00:00 2001 From: AngeD Date: Mon, 26 Jun 2023 18:05:56 +0200 Subject: [PATCH] fix: wlp not working properly --- .config/nvim/lua/pack-lspconfig.lua | 1 + bin/sbar | 4 ++-- bin/wlp | 31 ++++++++++++++++++----------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.config/nvim/lua/pack-lspconfig.lua b/.config/nvim/lua/pack-lspconfig.lua index 39c9cc3..6eeed36 100644 --- a/.config/nvim/lua/pack-lspconfig.lua +++ b/.config/nvim/lua/pack-lspconfig.lua @@ -2,6 +2,7 @@ vim.cmd("packadd lspconfig") lspconfig = require"lspconfig" local servers = { + "pyright", } local on_attach = function(client, bufnr) diff --git a/bin/sbar b/bin/sbar index d3f922f..4ee50fe 100755 --- a/bin/sbar +++ b/bin/sbar @@ -84,8 +84,8 @@ trap 'update_crypto;display' 'RTMIN+2' sec=0 while true; do - [ "$((sec % 3600))" = 0 ] && update_crypto - [ "$((sec % 5 ))" = 0 ] && { + [ "$((sec % 300))" = 0 ] && update_crypto + [ "$((sec % 5 ))" = 0 ] && { update_time update_cpu update_memory diff --git a/bin/wlp b/bin/wlp index e1d4e23..3ba1d7a 100755 --- a/bin/wlp +++ b/bin/wlp @@ -5,21 +5,27 @@ CON=("${NMCLI[@]}" connect) RESCAN=0 function rescan() { - if [ "$RESCAN" = 0 ]; then - RESCAN=1 - "${NMCLI[@]}" list --rescan yes > /dev/null + if [ "$RESCAN" = 1 ]; then + return 1 fi + RESCAN=1 + "${NMCLI[@]}" list --rescan yes > /dev/null readarray -t NET <<< "$("${NMCLI[@]}" list | awk '!w[$1]++' | tail -n+2)" } function connect() { - if ! ( - "${CON[@]}" "$1" || ([ "$?" = 4 ] && "${CON[@]}" "$1" password "$(zenity --entry --text "Enter password for $1")") - ) 2> /dev/null; then - rescan || return 1 - if ! "${CON[@]}" "$1"; then - return 1 - fi + local pass + + if ! "${CON[@]}" "$1"; then + case "$?" in + 4) + pass="$(zenity --entry --text "Enter password for $1")" + "${CON[@]}" "$1" password "$pass" + ;; + 10) + rescan && connect "$@" + ;; + esac fi kill -36 "$(cat "$HOME/.cache/pidofbar")" exit @@ -31,11 +37,12 @@ fi readarray -t NET <<< "$("${NMCLI[@]}" list | awk '!w[$1]++' | tail -n+2)" while true; do - n="$(printf '%s\n' "${NET[@]}" reload | dmenu -i -l 10)" + n="$(printf '%s\n' "${NET[@]}" rescan | dmenu -i -l 10)" if [ -z "$n" ]; then exit fi - if [ "$n" = reload ]; then + if [ "$n" = rescan ]; then + RESCAN=0 rescan else connect "$(awk '{print $1}' <<< "$n")"