Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] GUI for multi-line text input for bash script

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
hiltuspeke
Posts: 15
Joined: 2016-11-14 18:37

[SOLVED] GUI for multi-line text input for bash script

#1 Post by hiltuspeke »

Hi.

I've written very simple bash script to read user input for a variable and then echo that variable to a text file for later use.

I want this script to work on a graphical interface without a terminal window, so currently I'm using Zenity to read the input. It is working marvelously, but the text entry dialog in Zenity only has one line. I need to have a input dialog that allows me to input a string of text with line breaks in it. I couldn't find a way around this in the documentation of Zenity, which leaves me to the conclusion it simply is not possible with Zenity.

Is there another, similar software I could use? Of course there is dialog, but as mentioned, I'd like to stay graphical. I found some ~10 years old discussion online about this very same issue, and they recommended using gtkdialog, but I can't find it in the repos anymore.

And yes, I could theoretically just add -e -switch for echo in my script and use \n instead of enter when writing the input, but that is far from easy-to-use and minimalism I'm aiming for.

What should I use?
Last edited by hiltuspeke on 2016-11-17 18:17, edited 1 time in total.

User avatar
alan stone
Posts: 269
Joined: 2011-10-22 14:08
Location: In my body.

Re: GUI for multi-line text input for bash script

#2 Post by alan stone »

Did you have a look here and here?

User avatar
kiyop
Posts: 3983
Joined: 2011-05-05 15:16
Location: Where persons without desire to improve themselves fear to tread, in Japan
Been thanked: 3 times

Re: GUI for multi-line text input for bash script

#3 Post by kiyop »

Yad and so on may be good.

Code: Select all

# PREPARATION - install dialog and xterm
apt update
apt install dialog xterm
# END OF PREPARATION

touch /PATH/TO/FILE
xterm -e "dialog --editbox /PATH/TO/FILE 0 0"
ADDED AT Sat Nov 19 13:03:57 JST 2016;

Thank hiltuspeke for telling the option "--text-info --editable" :)
Last edited by kiyop on 2016-11-19 04:06, edited 1 time in total.
Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
http://kiyoandkei.bbs.fc2.com/

hiltuspeke
Posts: 15
Joined: 2016-11-14 18:37

Re: GUI for multi-line text input for bash script

#4 Post by hiltuspeke »

It turned out that this is indeed possible in Zenity.

I found it out while reading the documentation for YAD.
In YAD it is possible to input many lines using Text-info dialog and mark it editable:

Code: Select all

--text-info --editable
After this success in YAD I tried the very same syntax for Zenity, and it indeed is possible with the very same syntax. Case closed.
(Now that I have YAD compiled, I may still stick to that, as it uses GTK+2 and looks nicer on my Mate setup. )

Post Reply