From 679a0ff8ced55d127105ea01c2291639d3d14846 Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Tue, 24 Jan 2023 23:56:39 +0100 Subject: [PATCH] big update --- emails | 2 +- lock_and_suspend | 2 +- startsync | 20 ++++++++------------ term | 5 +++-- wifi_chooser | 22 +++++++++++++++++++--- 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/emails b/emails index a18ff00..5edd936 100755 --- a/emails +++ b/emails @@ -2,4 +2,4 @@ # We setup xauthority file to display stuff auth="$(xauth extract - "$DISPLAY" | base64)" -exec sudo -u emails sh -c "echo -n '$auth' | base64 -d > ~/.Xauthority && . ~/.bashrc && cd ~/attachements && exec aerc" +exec sudo -u emails sh -c "echo -n '$auth' | base64 -d > ~/.Xauthority && . ~/.bashrc && cd ~/attachements && exec neomutt" diff --git a/lock_and_suspend b/lock_and_suspend index 03fe95a..0b7f840 100755 --- a/lock_and_suspend +++ b/lock_and_suspend @@ -1,3 +1,3 @@ #!/bin/sh # Lock screen and suspend if enabled in config file -i3lock -e -c 000000 -u && [ -z "$(grep off "/run/user/1000/enable_suspend")" ] && systemctl suspend +i3lock -e -c 000000 -u && [ "$(cat "$XDG_RUNTIME_DIR/enable_suspend")" != off ] && systemctl suspend diff --git a/startsync b/startsync index 49ffc4e..10247f5 100755 --- a/startsync +++ b/startsync @@ -1,12 +1,8 @@ -nextcloud & -feedreader & -#jami-gnome & -offlineimap -vdirsyncer sync -birthday_reminder -while true ; do - offlineimap -q - #mpop -a - #notmuch new - sleep 30 -done +#!/bin/bash + +#feedreader &>/dev/null & +#jami-gnome &>/dev/null & +nicotine &>/dev/null & +qbittorrent &>/dev/null & +#vdirsyncer sync +sudo -u emails syncmails diff --git a/term b/term index ba31728..9772e24 100755 --- a/term +++ b/term @@ -1,3 +1,4 @@ -#!/bin/sh -cd "$(readlink -f "/proc/$(pgrep -P $(xdotool getwindowpid "$(xdotool getactivewindow)"))/cwd")" &>/dev/null || cd "$HOME" +#!/bin/bash +pid="$(xdotool getactivewindow getwindowpid)" +[ -n "$pid" ] && cd "$(readlink -f "/proc/$(pgrep -P "$pid")/cwd")" &>/dev/null || cd "$HOME" exec st "${SHELL:-bash}" diff --git a/wifi_chooser b/wifi_chooser index 3e13a66..3f08f77 100755 --- a/wifi_chooser +++ b/wifi_chooser @@ -60,13 +60,29 @@ ssid="$(nmcli -f IN-USE,SSID,BARS d wifi list | dmenu -l 8)" ssid="$(echo "${ssid:2:-5}" | sed 's/^ *//g' | sed 's/ *$//g')" # We get a clean version of SSIDs. It is a fix to connect to wifis that begin or end with spaces -ssid="$(nmcli -f SSID -m multiline -t -c no d wifi list | grep -F "$ssid")" +ssid="$(nmcli -f SSID -m multiline -t -c no d wifi list | grep -F -- "$ssid")" ssid="${ssid:5}" [ $verb -gt 0 ] && echo "ssid: $ssid" [ -z "$ssid" ] && notify "No SSID selected" && exit 1 notify "Connecting to $ssid" -out="$(nmcli d wifi connect "$ssid" 2>&1 | grep -i error)" +#out="$(nmcli d wifi connect "$ssid" 2>&1 | grep -i error)" +out="$(nmcli con up "$ssid" 2>&1 | grep -i error)" res="$?" -[ -z "$out" ] && notify "Connected :)" || notify "Error connecting :(\n$out" +# 10 If the connexion does not exist already # +# 4 If the SSID got multiple bad connexion names # +if [ "$res" -ne 0 ] ; then + out2="$out" + out="$(nmcli device wifi connect "$ssid" 2>&1 | grep -i error)" + res="$?" +fi +if [ -n "$(echo $out | grep -i 'secrets were required')" ] ; then + out2="$out2$out" + notify "Need password" + pass="$(zenity --password)" + out="$(nmcli device wifi connect "$ssid" --password "$pass" 2>&1 | grep -i error)" + res="$?" +fi + +[ -z "$out" ] && notify "Connected :)" || notify "Error connecting :(\n$out\n$out2"