When visiting a mesh site choose from a list of users
This commit is contained in:
parent
64d843d615
commit
dec2f54a1b
|
@ -49,6 +49,10 @@ if [ ! -f $USERS_FILE ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
USERS_FILE_LINES=$(wc -l $USERS_FILE | awk -F ' ' '{print $1}')
|
||||||
|
|
||||||
|
if [ $USERS_FILE_LINES -gt 200 ]; then
|
||||||
|
# If there are more than a Dunbar number of peers then ask for the peer name or ID
|
||||||
data=$(zenity --entry --title="Visit IPFS site" --text="Enter the username or Tox ID for the site you wish to visit")
|
data=$(zenity --entry --title="Visit IPFS site" --text="Enter the username or Tox ID for the site you wish to visit")
|
||||||
sel=$?
|
sel=$?
|
||||||
case $sel in
|
case $sel in
|
||||||
|
@ -63,14 +67,10 @@ case $sel in
|
||||||
|
|
||||||
if [ ${#TOX_ID} -gt 5 ]; then
|
if [ ${#TOX_ID} -gt 5 ]; then
|
||||||
if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
|
if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
|
||||||
dialog --title $"Visit IPFS site" \
|
zenity --info --title $"Visit a site" --text $"An IPFS site was not found for the user '$TOX_USERNAME_OR_ID'" --width 500
|
||||||
--backtitle $"Freedombone mesh" \
|
|
||||||
--msgbox $"An IPFS site was not found for the user '$TOX_USERNAME_OR_ID'" 8 60
|
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
|
IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
|
||||||
clear
|
|
||||||
echo $'Opening browser. Please wait...'
|
|
||||||
pkill $BROWSER
|
pkill $BROWSER
|
||||||
setsid sh -c "$BROWSER $BROWSER_OPTIONS $IPFS_FULL_URL$SUFFIX" > /dev/null 2>&1 < /dev/null &
|
setsid sh -c "$BROWSER $BROWSER_OPTIONS $IPFS_FULL_URL$SUFFIX" > /dev/null 2>&1 < /dev/null &
|
||||||
|
|
||||||
|
@ -82,5 +82,28 @@ case $sel in
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
else
|
||||||
|
# If there are a relatively small number of users then choose from a list
|
||||||
|
TOX_ID=$(
|
||||||
|
cat $USERS_FILE | \
|
||||||
|
awk -F ' ' '{
|
||||||
|
for(i=1;i<=NF;i++){
|
||||||
|
print $i;
|
||||||
|
}
|
||||||
|
}' | \
|
||||||
|
zenity --list \
|
||||||
|
--title='Visit the site of another user' \
|
||||||
|
--column='Username' --column='Tox ID' \
|
||||||
|
--print-column=2 --hide-column=2 --width=300 --height=400)
|
||||||
|
if [ ! $TOX_ID ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
|
||||||
|
pkill $BROWSER
|
||||||
|
setsid sh -c "$BROWSER $BROWSER_OPTIONS $IPFS_FULL_URL$SUFFIX" > /dev/null 2>&1 < /dev/null &
|
||||||
|
|
||||||
|
# Need to wait a while for the browser to begin opening
|
||||||
|
sleep 3
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue