Author Topic: Creating custom gui dialogs for shell / bash scripts  (Read 20835 times)

Offline growbag

  • Full Member
  • ***
  • Posts: 90
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #45 on: September 08, 2010, 06:27:32 AM »
I'm trying to use a GUI box to pass my password to the cryptsetup command and failing miserably :(.

Anyone know how to do that? 

I know that PCLOS does it at boot when you have a LUKS encrypted partition set to automount (very impressive, and the only distro I've seen that has such a cool thing), but I don't know how it's done, and I don't have an encrypted partition, just an encrypted container file - hence using cryptsetup.

I've been trying to use Xdialog, here is my code attempt:

Code: [Select]
Xdialog --password --inputbox --stdout "Enter LUKS password:" 10 60 | sudo cryptsetup create myhome /dev/loop0
It work as far as it echoes my password back onto the terminal command line, but then it just sits there waiting for me to press enter (in the terminal) which completely defeats the purpose of using a GUI!

I haven't tried with zenity yet, would that be easier?

Thanks :)
desktop - ASUS M4A79XTD Evo, PhenomII X2-550, 4gigs DDR3, nVidia GTX260.

laptop - Alienware m17x, i7, 6gigs DDR3, single MXM type IIIb ATI 4870.

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #46 on: September 08, 2010, 06:44:42 AM »
you could just use kdesu or gksu depending on weather or not you are using KDE or not:
Code: [Select]
kdesu "cryptsetup create myhome /dev/loop0"


..or if you prefer to auto-detect which is available:
Code: [Select]
GUI_SU=`which gksu 2>/dev/null` || GUI_SU=`which kdesu 2>/dev/null`
$GUI_SU "cryptsetup create myhome /dev/loop0"



EDIT:
..gksudo is also available if you specifically need sudo; use it in place of kdesu or gksu.  ;)
« Last Edit: September 08, 2010, 06:51:38 AM by travisn000 »

Offline growbag

  • Full Member
  • ***
  • Posts: 90
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #47 on: September 08, 2010, 07:09:23 AM »
Thanks for the quick reply.

Although it's not the system password that's the problem, I've solved that already, it's the crypt file password (or passphrase) which is prompted for after the system password and which seems to be only available from the command line in a terminal.
desktop - ASUS M4A79XTD Evo, PhenomII X2-550, 4gigs DDR3, nVidia GTX260.

laptop - Alienware m17x, i7, 6gigs DDR3, single MXM type IIIb ATI 4870.

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #48 on: September 08, 2010, 10:55:18 AM »
perhaps something like this:

(..untested; I'm on windoze at work..  :'()
Code: [Select]

PSWD=$(Xdialog --password --inputbox --stdout "Enter LUKS password:" 10 60) && echo -e "$PSWD\n" | sudo cryptsetup create myhome /dev/loop0


..essentially add a newline character to the user entered password

Offline growbag

  • Full Member
  • ***
  • Posts: 90
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #49 on: September 12, 2010, 07:37:06 AM »
Thanks for the tip travisn000, it didn't work though, but that was because I got the Xdialog command line stuff wrong in the first place :/

I emailed the Xdialog maintainer Thierry Godefroy, and he kindly put me straight.  The correct format is -

Xdialog --stdout --password --inputbox "Enter LUKS password:" 10 60 | sudo cryptsetup create myhome /dev/loop0

That line now works perfectly.

Thanks for the help :)
desktop - ASUS M4A79XTD Evo, PhenomII X2-550, 4gigs DDR3, nVidia GTX260.

laptop - Alienware m17x, i7, 6gigs DDR3, single MXM type IIIb ATI 4870.

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #50 on: September 12, 2010, 09:15:13 AM »
..glad I could be of very little help!  ;D

I will have to look into Xdialog some more..  I usually use zenity for quick GUI dialogs, but Xdialog looks to be just as easy and probably a little more flexible.

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6245
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #51 on: October 19, 2011, 08:50:45 PM »

There is this project i am working on that manage cryptsetup volumes in both files and partitions using a simple Qt based GUI. The project is at http://code.google.com/p/zulucrypt/ and i just sent texstar an srpm so i hope it will be included in the repository shortly.
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6245
Re: Creating custom gui dialogs for shell / bash scripts
« Reply #52 on: October 20, 2011, 09:17:05 PM »

Thanks for the link, will investigate on how to make a kcm module with the program functionality. Those .desktop files and python scripts  will be very helpful i think in knowing what systemsetting expects.
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline tele

  • Full Member
  • ***
  • Posts: 197
---
Sorry, if my language is wrong,
you please write notice where I do mistakes, I will try to learn.