Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    How to create dialog to pop up on package install?

    Reply
    Page 1 of 2 | 1   2   | Next
    d-iivil | # 1 | 2010-06-26, 07:57 | Report

    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!

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 2 | 2010-06-26, 08:36 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    tswindell | # 3 | 2010-06-26, 08:40 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to tswindell For This Useful Post:
    d-iivil

     
    d-iivil | # 4 | 2010-06-26, 08:52 | Report

    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!

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 5 | 2010-06-26, 13:54 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    MohammadAG | # 6 | 2010-06-26, 14:03 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to MohammadAG For This Useful Post:
    d-iivil

     
    Dotblank | # 7 | 2010-06-26, 14:20 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 8 | 2010-06-26, 14:50 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    d-iivil | # 9 | 2010-06-26, 15:07 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by d-iivil; 2010-06-26 at 15:19.

     
    d-iivil | # 10 | 2010-06-26, 15:58 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Page 1 of 2 | 1   2   | Next
vBulletin® Version 3.8.8
Normal Logout