1

I'd like to set up the following workflow on my (Gnome) Ubuntu 21.10 laptop.

  • Enter a shortcut to run a program (let's say a bash script)
  • A GUI text-input (preferably GTK) pops up and offers a text input
  • I type in some task
  • I call an API and send task information to my todolist via a REST api

I know how to implement each part, except which CLI to use to prompt for text from a GUI (rather than a CLI).

Question

  • Which CLI can I use to perform to prompt for user input via a GUI textbox?
2
  • 2
    I think you're confusing your terminologies quite a bit. There's no real distinction between CLI and GUI programs. A "CLI" application that opens a GUI and doesn't interact with the user on the command line at all isn't a CLI. The manner in which a program was started, whether through the GUI application selector or through the shell bears no bearing on making an application CLI or GUI.
    – Lie Ryan
    Nov 6 '21 at 18:35
  • Apologies, the terminology was a little tricky. I was looking for a GUI with a useful CLI interface (like zenity), rather than a CLI that reads from a tty. But fair point, I'll keep this language clearer in future Nov 7 '21 at 13:28
3

Zenity is probably the easiest way to create simple GUI dialogs from shell scripts. The input dialog looks like this:

#!/bin/bash

TASK=`zenity --entry --text="Enter task:"`

echo $TASK

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.