From 8481a701eb9f0a9d5caa75ee31b57e900c013d17 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 8 Dec 2017 13:30:35 +0000 Subject: [PATCH] Use zenity to select users and copy their tox ID to the clipboard --- src/freedombone-image-customise | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index aa0370cb..e9cfdf6e 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -887,6 +887,10 @@ function configure_user_interface { # for gtk dialog entry chroot "$rootdir" apt-get -yq install zenity + StrMeshUsers=$"Mesh Users" + StrUsername=$'Username' + StrToxID=$'Tox ID' + # Produce a text file on the desktop listing users on the mesh cat < $rootdir/usr/bin/list-tox-users #!/bin/bash @@ -901,13 +905,25 @@ if [ \$no_of_users -gt 0 ]; then echo "\$users_list" > /tmp/Users.txt chown $MY_USERNAME:$MY_USERNAME /tmp/Users.txt - echo 'showing_users=\$(ps aux | grep $MESH_TEXT_EDITOR | grep "Users.txt")' > /home/$MY_USERNAME/showusers - echo 'if [ \${#showing_users} -eq 0 ]; then' >> /home/$MY_USERNAME/showusers - echo ' $MESH_TEXT_EDITOR /tmp/Users.txt' >> /home/$MY_USERNAME/showusers - echo 'fi' >> /home/$MY_USERNAME/showusers - echo 'exit 0' >> /home/$MY_USERNAME/showusers - chmod +x /home/$MY_USERNAME/showusers - chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/showusers + if [ ! -f /home/$MY_USERNAME/showusers ]; then + echo '#!/bin/bash' > /home/$MY_USERNAME/showusers + echo 'data=$(' >> /home/$MY_USERNAME/showusers + echo 'cat /tmp/Users.txt | \' >> /home/$MY_USERNAME/showusers + echo " awk -F ' ' '{" >> /home/$MY_USERNAME/showusers + echo ' for(i=1;i<=NF;i++){' >> /home/$MY_USERNAME/showusers + echo ' print $i;' >> /home/$MY_USERNAME/showusers + echo ' }' >> /home/$MY_USERNAME/showusers + echo "}' | \\" >> /home/$MY_USERNAME/showusers + echo ' zenity --list \' >> /home/$MY_USERNAME/showusers + echo " --title='$StrMeshUsers' \\" >> /home/$MY_USERNAME/showusers + echo " --column='$StrUsername' --column='$StrToxID' \\" >> /home/$MY_USERNAME/showusers + echo ' --print-column=2 --hide-column=2 --width=250 --height=400)' >> /home/$MY_USERNAME/showusers + echo 'if [ ! $data ]; then' >> /home/$MY_USERNAME/showusers + echo ' exit 0' >> /home/$MY_USERNAME/showusers + echo 'fi' >> /home/$MY_USERNAME/showusers + echo 'echo "$data" | xclip -selection clipboard' >> /home/$MY_USERNAME/showusers + chmod +x /home/$MY_USERNAME/showusers + fi echo '[Desktop Entry]' > /home/$MY_USERNAME/Desktop/Users.desktop if [ \$no_of_users -lt 2 ]; then