Applet password input option

About programming and getting involved with Linux Mint development
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Post Reply
nerdyedad
Level 1
Level 1
Posts: 1
Joined: Thu Dec 07, 2023 10:31 am

Applet password input option

Post by nerdyedad »

Hi community,

I'm writing a small applet for cinnamon and I need to prompt for password into the applet's configuration dialog.
Do it exist any option7property to set on the "entry" widget to hide text using a "password" character ?

Thanks for any hint on the topic and cheers,

NeD
Last edited by SMG on Thu Dec 07, 2023 10:43 am, edited 1 time in total.
Reason: Moved from Software & Applications to Programming & Development because the question relates to writing an applet for Cinnamon.
t42
Level 11
Level 11
Posts: 3747
Joined: Mon Jan 20, 2014 6:48 pm

Re: Applet password input option

Post by t42 »

there is systemd-ask-password, see man 1, and plymouth for that matter as well.
-=t42=-
User avatar
Drugwash
Level 5
Level 5
Posts: 734
Joined: Fri Jun 07, 2019 6:40 am
Location: Ploieşti, RO
Contact:

Re: Applet password input option

Post by Drugwash »

nerdyedad wrote: Thu Dec 07, 2023 10:37 am I need to prompt for password into the applet's configuration dialog.
How are you building the configuration dialog? Is it using the default controls available through settings.json, or are you using some custom Python script(s)?
For the latter you can use Gtk.Entry's features. Example:

Code: Select all

cPass = Gtk.Entry(hexpand=True)
cPass.set_visibility(False)
cPass.set_invisible_char("●") # can be replaced with asterisk or anything else
cPass.set_input_purpose(Gtk.InputPurpose.PASSWORD)
and then to retrieve the actual text you do password = cPass.get_text().
You can also add a toggle button in case the user wants to see the actual password:

Code: Select all

cPasRev = Gtk.ToggleButton(label="👁") # pass revealer button
cPasRev.connect("toggled", passVisible, cPass)

def passVisible(self, button, passfield):
	"""Password field visibility toggle."""
	is_active = btn.get_active()
	passfield.set_visibility(is_active)
Hopefully you're not storing that password anywhere in plain text.

I may be wrong - please someone correct me if so - but I think there is no way to add a password-type entry control to the configuration dialog using the currently available default options provided by settings.json.
Post Reply

Return to “Programming & Development”