Use zenity to set the initial username on mesh client

This commit is contained in:
Bob Mottram 2017-10-26 23:35:42 +01:00
parent 576011af74
commit 7800ebf4ec
2 changed files with 9 additions and 13 deletions

View File

@ -779,18 +779,11 @@ function mesh_client_startup_applications {
echo '' >> $START_DESKTOP
echo 'INITIAL_TOX_USERNAME=""' >> $START_DESKTOP
echo 'while [ ${#INITIAL_TOX_USERNAME} -eq 0 ]; do' >> $START_DESKTOP
echo ' data=$(tempfile 2>/dev/null)' >> $START_DESKTOP
echo ' trap "rm -f $data" 0 1 2 5 15' >> $START_DESKTOP
echo -n " dialog --title \"${MESH_TITLE}\" " >> $START_DESKTOP
echo -n "--backtitle \"${MESH_TITLE}\" " >> $START_DESKTOP
echo -n "--inputbox \"${MESH_SET_USERNAME}\" 12 60 Anon " >> $START_DESKTOP
echo '2>$data' >> $START_DESKTOP
echo ' sel=$?' >> $START_DESKTOP
echo ' case $sel in' >> $START_DESKTOP
echo ' 0)' >> $START_DESKTOP
echo ' INITIAL_TOX_USERNAME=$(<$data)' >> $START_DESKTOP
echo ' ;;' >> $START_DESKTOP
echo ' esac' >> $START_DESKTOP
echo " data=\$(zenity --forms --title=\"$MESH_TITLE\" --text=\"$MESH_SET_USERNAME\" --separator=\",\" --add-entry=\"Username\")" >> $START_DESKTOP
echo ' accepted=$?' >> $START_DESKTOP
echo ' if ((accepted == 0)); then' >> $START_DESKTOP
echo " INITIAL_TOX_USERNAME=\$(awk -F, '{print \$1}' <<<\$data)" >> $START_DESKTOP
echo ' fi' >> $START_DESKTOP
echo 'done' >> $START_DESKTOP
echo '' >> $START_DESKTOP
echo 'toxid --setuser "$INITIAL_TOX_USERNAME"' >> $START_DESKTOP
@ -892,6 +885,9 @@ function configure_user_interface {
# audio recording
chroot "$rootdir" apt-get -yq install audacity
# for gtk dialog entry
chroot "$rootdir" apt-get -yq install zenity
# Produce a text file on the desktop listing users on the mesh
cat <<EOF > $rootdir/usr/bin/list-tox-users
#!/bin/bash

View File

@ -147,7 +147,7 @@ function detect_new_tox_users {
# Produce notifications if new users appear
if [ -f $PREV_TOX_USERS_FILE ]; then
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ $line != "Failed*" && $line != "data "* && $line != "Anon "* && $line != "anon "* ]]; then
if [[ $line != "Failed*" && $line != "data "* && $line != "Anon "* && $line != "anon "* && $line != "anonymous "* && $line != "Anonymous "* ]]; then
if ! grep -q "$line" $PREV_TOX_USERS_FILE; then
# get the nick of the user
toxidstr=$(echo "$line" | awk -F ' ' '{print $(NF)}')