~magdesign

traveling

https://brandisbrandisbrand.com

i hate git send email


#603 sxmo_networks.sh shows duplicated wifi names 19 days ago

on ~mil/sxmo-tickets

On Sun Nov 10, 2024 at 5:36 AM CET, ~magdesign wrote:

Thanks for your replay. there is one bug in this patch! when there exists a WEP secured wifi, it will not be able to connect. the correct and tested line to fix all the trouble is:

NAMES=$(echo "$SSID" | awk -F ' ' '{ $NF=""; print $0 }' | sed 's/[[:space:]]*$//' | sed 's/ WPA\w//g')

Thanks, I sent a v2 patch with this fix included: https://lists.sr.ht/~mil/sxmo-devel/patches/55964

#603 sxmo_networks.sh shows duplicated wifi names 2 months ago

Comment by ~magdesign on ~mil/sxmo-tickets

and here the code for copy-pasta:

addnetworkwpamenu() {
    SSID="$(cat <<EOF | sxmo_dmenu.sh -p "SSID"
$icon_cls Close Menu
$(nmcli -f SSID,SECURITY dev wifi | tail -n +2 | awk '!seen[$0]++' | sed '/^--/d')
EOF
    )"
    [ -z "$SSID" ] && return
    echo "$SSID" | grep -q "Close Menu" && return

    SECURITY_TYPE="$(echo "$SSID" | awk '{print $NF}')"

    # If security type is '--', skip passphrase input
    if [ "$SECURITY_TYPE" != "--" ]; then
        PASSPHRASE="$(cat <<EOF | sxmo_dmenu.sh -p "Passphrase"
$icon_cls Close Menu
None
EOF
        )"

        if [ -z "$PASSPHRASE" ] || [ "None" = "$PASSPHRASE" ]; then
            unset PASSPHRASE
        fi
        echo "$PASSPHRASE" | grep -q "Close Menu" && return
    fi

    # splits $SSID name from Security
    NAMES=$(echo "$SSID" | awk -F ' ' '{ $NF=""; print $0 }' | sed 's/[[:space:]]*$//')

    notify_sucess "Adding connection" \
        nmcli c add type wifi ifname wlan0 con-name "$NAMES" ssid "$NAMES" \
        ${PASSPHRASE:+802-11-wireless-security.key-mgmt wpa-psk 802-11-wireless-security.psk "$PASSPHRASE"}
}

#603 sxmo_networks.sh shows duplicated wifi names 2 months ago

Comment by ~magdesign on ~mil/sxmo-tickets

#Fix and Patch

Following modification of sxmo_networks.sh hides duplicated wifi ssid's and shows the security, if you select to connect to a wifi without security, it will not ask you for a password anymore.

here is the patch:

--- sxmo_networks.sh.original	2024-05-20 11:42:12.557487928 -0300
+++ sxmo_networks.sh.patch	2024-09-13 23:41:42.277220175 -0300
@@ -143,30 +143,39 @@
 }
 
 addnetworkwpamenu() {
-	SSID="$(cat <<EOF | sxmo_dmenu.sh -p "SSID"
+    SSID="$(cat <<EOF | sxmo_dmenu.sh -p "SSID"
 $icon_cls Close Menu
-$(nmcli d wifi list | tail -n +2 | grep -v '^\*' | awk -F'  ' '{ print $6 }' | grep -v '\-\-')
+$(nmcli -f SSID,SECURITY dev wifi | tail -n +2 | awk '!seen[$0]++' | sed '/^--/d')
 EOF
-	)"
-	[ -z "$SSID" ] && return
-	echo "$SSID" | grep -q "Close Menu" && return
+    )"
+    [ -z "$SSID" ] && return
+    echo "$SSID" | grep -q "Close Menu" && return
 
-	PASSPHRASE="$(cat <<EOF | sxmo_dmenu.sh -p "Passphrase"
+    SECURITY_TYPE="$(echo "$SSID" | awk '{print $NF}')"
+
+    # If security type is '--', skip passphrase input
+    if [ "$SECURITY_TYPE" != "--" ]; then
+        PASSPHRASE="$(cat <<EOF | sxmo_dmenu.sh -p "Passphrase"
 $icon_cls Close Menu
 None
 EOF
-	)"
+        )"
+
+        if [ -z "$PASSPHRASE" ] || [ "None" = "$PASSPHRASE" ]; then
+            unset PASSPHRASE
+        fi
+        echo "$PASSPHRASE" | grep -q "Close Menu" && return
+    fi
 
-	if [ -z "$PASSPHRASE" ] || [ "None" = "$PASSPHRASE" ]; then
-		unset PASSPHRASE
-	fi
-	echo "$PASSPHRASE" | grep -q "Close Menu" && return
-
-	notify_sucess "Adding connection" \
-		nmcli c add type wifi ifname wlan0 con-name "$SSID" ssid "$SSID" \
-		${PASSPHRASE:+802-11-wireless-security.key-mgmt wpa-psk 802-11-wireless-security.psk "$PASSPHRASE"}
+    # splits $SSID name from Security
+    NAMES=$(echo "$SSID" | awk -F ' ' '{ $NF=""; print $0 }' | sed 's/[[:space:]]*$//')
+
+    notify_sucess "Adding connection" \
+        nmcli c add type wifi ifname wlan0 con-name "$NAMES" ssid "$NAMES" \
+        ${PASSPHRASE:+802-11-wireless-security.key-mgmt wpa-psk 802-11-wireless-security.psk "$PASSPHRASE"}
 }
 
+
 addhotspotusbmenu() {
 	CONNNAME="$(
 		echo "$icon_cls Close Menu" |

If you tell me how to send the patch without git send-email i am happy to send it, otherwise i am sure you now how to apply.

#603 sxmo_networks.sh shows duplicated wifi names 4 months ago

Comment by ~magdesign on ~mil/sxmo-tickets

now it does what it should, also with wifis having white spaces or emojis in its name starting on line 145 in sxmo-utils/scripts/core/sxmo_networks.sh

addnetworkwpamenu() {
	SSID="$(cat <<EOF | sxmo_dmenu.sh -p "SSID"
$icon_cls Close Menu
$(nmcli -f SSID,SECURITY dev wifi | tail -n +2 | awk '!seen[$0]++' | sed '/^--/d' ) 

EOF
	)"
	[ -z "$SSID" ] && return
	echo "$SSID" | grep -q "Close Menu" && return

	PASSPHRASE="$(cat <<EOF | sxmo_dmenu.sh -p "Passphrase"
$icon_cls Close Menu
None
EOF
	)"

	if [ -z "$PASSPHRASE" ] || [ "None" = "$PASSPHRASE" ]; then
		unset PASSPHRASE
	fi
	echo "$PASSPHRASE" | grep -q "Close Menu" && return
	# NAMES splits $SSID name from Security, even if there are whitespaces
	NAMES=$(echo "$SSID" | awk -F ' ' '{ $NF=""; print $0 }' | sed 's/[[:space:]]*$//')

	notify_sucess "Adding connection" \

		nmcli c add type wifi ifname wlan0 con-name "$NAMES" ssid "$NAMES" \
		${PASSPHRASE:+802-11-wireless-security.key-mgmt wpa-psk 802-11-wireless-security.psk "$PASSPHRASE"}
}

#603 sxmo_networks.sh shows duplicated wifi names 4 months ago

Comment by ~magdesign on ~mil/sxmo-tickets

i think there is now an issue that when you want to add a WPA network with a white space in the name, it will only take the first part of the name... to be fixed soon

#78 Ability to use image/icon for pins 4 months ago

Comment by ~magdesign on ~mil/mepo-tickets

On 2024-07-24 01:42, ~mil wrote:

Ah interesting idea - we could have a property for pin's icons.

We would need two different icons (or an SVG with fill) for each pin though as there is an 'unselected' and 'active' style (e.g. black vs red pin in current implementation).

I would accept a patch for something like this

sorry but i dont dig the coding language of mepo (failed compiling as well), but i will spend time making .svg with different styles and provide them. the most important ones are: drinking_water, shelter, picnic-sites, toilets, showers, groceries, petrol

#603 sxmo_networks.sh shows duplicated wifi names 4 months ago

Comment by ~magdesign on ~mil/sxmo-tickets

when the ssids are too long, the security does not show in bmenu... depending on a scaling, no big deal.

i do not send a patch, the last few times i messed it up with git-mail.. feel free to add it to the code.

#603 sxmo_networks.sh shows duplicated wifi names 4 months ago

Comment by ~magdesign on ~mil/sxmo-tickets

i am currently on the street testing this and there is the issue that the security value only show up as expected when i am already connected to a wifi

#603 sxmo_networks.sh shows duplicated wifi names 4 months ago

Ticket created by ~magdesign on ~mil/sxmo-tickets

When you are in a public space like a train station, there exist several wifi access points with the same name. In the moment, sxmo shows all of them to add a wpa network. It would be enough to show it once.

Also, we do not know if a network is open or closed, which is annoying on public places.

Following modification of sxmo_networks.sh hides duplicated wifi ssid's and shows the security:

addnetworkwpamenu() {
	SSID="$(cat <<EOF | sxmo_dmenu.sh -p "SSID"
$icon_cls Close Menu
$(nmcli -f SSID,SECURITY dev wifi | tail -n +2 | awk '!seen[$0]++' | sed '/^--/d' ) 
EOF
	)"
	[ -z "$SSID" ] && return
	echo "$SSID" | grep -q "Close Menu" && return

	PASSPHRASE="$(cat <<EOF | sxmo_dmenu.sh -p "Passphrase"
$icon_cls Close Menu
None
EOF
	)"

	if [ -z "$PASSPHRASE" ] || [ "None" = "$PASSPHRASE" ]; then
		unset PASSPHRASE
	fi
	echo "$PASSPHRASE" | grep -q "Close Menu" && return

	notify_sucess "Adding connection" \
		nmcli c add type wifi ifname wlan0 con-name "${SSID%% *}" ssid "${SSID%% *}" \
		${PASSPHRASE:+802-11-wireless-security.key-mgmt wpa-psk 802-11-wireless-security.psk "$PASSPHRASE"}
}

#79 Ability to customize pin size 4 months ago

Ticket created by ~magdesign on ~mil/mepo-tickets

at least on sway (sxmo, pmos) my position is displayed with a tiny, red, 2px square. it would be helpful to have something like the gps icon from the nerd fonts package for better visibility of the actual position.

(i know we talked about this on the channel, but i was not able to familiarize me with the code mepo is written in and therefore can not provide a patch)