Reply
Thread Tools
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#1
Hello,

is it possible to show user a dialog window asking yes / no question when he install a package via HAM?

I would like to make a theme package that will include some optional stuff and I'd like to ask user if he wants to install those extras or not. And if user presses "yes" then some shell commands are ran in the background, and if he answers no then other actions are taken.

Can someone provide some help? Thanks in advance!
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#2
Or as an plan b; is it possible to run shell script after contents of deb have been extracted (postinst)? It would be easy to make a script that asks user to make the choise. If it's possible, then what will happen if the package is installed via HAM? Will the terminal window pop up and execute that script?
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
Posts: 724 | Thanked: 1,255 times | Joined on Nov 2007 @ Cambridge, UK
#3
postinst is what you're looking for, you can run xterm from there, but popping up a dialog is much more user friendly. You can do that by writing a program to handle the dialog and executing it from the postinst script.
 

The Following User Says Thank You to tswindell For This Useful Post:
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#4
Originally Posted by tswindell View Post
postinst is what you're looking for, you can run xterm from there, but popping up a dialog is much more user friendly. You can do that by writing a program to handle the dialog and executing it from the postinst script.
Yep, it would be more user friendly indeed. But I think it's a bit overkill to code an application just to show a dialog

I found that HAM supports displaying licence agreement pop-up with custom text + title which has OK and CANCELL -buttons, could I use that? I know how to lauch the agreement window but I don't know how to read the return value in postinst and so on.

I'm pretty n00b when coming down to debian packaging or Unix in general so detailed help would be highly appreciated!
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#5
okay.. I got it working when installing package @ Xterm with dpkg -command. I simply wrote simple script to postinst -file which asks y / n and then simple if / else to do the action (in my case rename two files). But it won't work when installing via HAM, it just does not open the xterm so that user could give his input :/

What should I do?
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
MohammadAG's Avatar
Posts: 2,473 | Thanked: 12,265 times | Joined on Oct 2009 @ Jerusalem, PS/IL
#6
Talked about this with tswindell but since he's offline I guess I'll post this.
Use zenity (I already had it installed, not sure if it comes preinstalled, if not just Depend on it) to display a dialog, see what the exit code is (if the user accepts it's 0, otherwise it's 1).
http://maemo.org/packages/view/zenity/
Code:
zenity --question --text="Install custom transitions?" --ok-label=Yes
should do.
To see the exit code (again, thanks to tswindell) add ;echo $? to the end.

If that works, thank his post above
 

The Following User Says Thank You to MohammadAG For This Useful Post:
Posts: 94 | Thanked: 253 times | Joined on Jan 2010 @ Virginia
#7
Originally Posted by D-Iivil View Post
Hello,

is it possible to show user a dialog window asking yes / no question when he install a package via HAM?

I would like to make a theme package that will include some optional stuff and I'd like to ask user if he wants to install those extras or not. And if user presses "yes" then some shell commands are ran in the background, and if he answers no then other actions are taken.

Can someone provide some help? Thanks in advance!
I would like to warn you that many people do not like interactive installs but this could be less of an issue for the n900
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#8
Originally Posted by MohammadAG View Post
Talked about this with tswindell but since he's offline I guess I'll post this.
Use zenity (I already had it installed, not sure if it comes preinstalled, if not just Depend on it) to display a dialog, see what the exit code is (if the user accepts it's 0, otherwise it's 1).
http://maemo.org/packages/view/zenity/
Code:
zenity --question --text="Install custom transitions?" --ok-label=Yes
should do.
To see the exit code (again, thanks to tswindell) add ;echo $? to the end.

If that works, thank his post above
Cool! So I can get the user's answer just by using $? ?

To be more clear, would this be workable (the postinst -file):
Code:
#! /bin/sh -e

zenity --question --text="Install custom transitions?" --ok-label=Yes

if [ "$?" == "0" ]; then

      # install the custom things
      exit 0

else

      # do not install the custom things
      exit 0

fi
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#9
Originally Posted by D-Iivil View Post
Cool! So I can get the user's answer just by using $? ?

To be more clear, would this be workable (the postinst -file):
Code:
#! /bin/sh -e

zenity --question --text="Install custom transitions?" --ok-label=Yes

if [ "$?" == "0" ]; then

      # install the custom things
      exit 0

else

      # do not install the custom things
      exit 0

fi
Holy smoke! It's working Kudos to you guys!

Edit: only "downside" is that zenity window is ugly when it's ran by root (uses GTK default graphics instead of Hildon), but I guess there's nothing that can be done?
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE

Last edited by d-iivil; 2010-06-26 at 15:19.
 
d-iivil's Avatar
Posts: 2,154 | Thanked: 2,186 times | Joined on Dec 2009 @ Hellsinki, Finland
#10
Or then not... the "yes" answer is working and correct action is taken, but "no" answer is not working. It always runs the "yes" option even if user clicks "No" (tapping outside the dialog window). I checked the output by echoing the $? and it shows "1" when use has tapped "No" but my script still runs the option #1 and HAM says that package cannot be installed because postinst exitted with code 1.

Any ideas?
__________________
If you're rich and you think I deserve a cold beer, you may donate one or two :-P

80's style stadium rock is back - FIRENOTE
Hi-Octane heavy metal - FORCE MAJEURE
 
Reply


 
Forum Jump


All times are GMT. The time now is 04:22.