Use zenity to select users and copy their tox ID to the clipboard

This commit is contained in:
Bob Mottram 2017-12-08 13:30:35 +00:00
parent 7bda738c8e
commit 8481a701eb
1 changed files with 23 additions and 7 deletions

View File

@ -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 <<EOF > $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