Creating a Script for PlayOnLinux - Chapitre 7 : The Power of PlayOnLinux version 3

Introduction

Since PlayOnLinux v3 (Arietis), you have the possibility to create windows like this one :

These windows are more ergonomic for the user and the scriptwriter as well. If you want to learn how to do this then keep on reading!


POL_SetupWindow, wassat ?

POL_SetupWindow is the name of the new interface. Thus, all commands controling this interface will start by POL_SetupWindow

Here is a brief list of POL_SetupWindow functions :
POL_SetupWindow_Init
POL_SetupWindow_Close
POL_SetupWindow_textbox
POL_SetupWindow_message
POL_SetupWindow_download
POL_SetupWindow_menu
POL_SetupWindow_browse
POL_SetupWindow_prefixcreate
POL_SetupWindow_reboot
POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom
POL_SetupWindow_presentation
POL_SetupWindow_free_presentation
POL_SetupWindow_wait_next_signal
...

Preparing PlayOnLinux to use POL_SetupWindow

You remember this code:

if [ "$PLAYONLINUX" = "" ]
then
exit 0
fi

source "$PLAYONLINUX/lib/sources"

We will add the line "POL_SetupWindow_Init" to instruct PlayOnLinux to : "Use the interface of the 3rd version". Which will give us:

if [ "$PLAYONLINUX" = "" ]
then
exit 0
fi

source "$PLAYONLINUX/lib/sources"
POL_SetupWindow_Init

You will also have to instruct PlayOnLinux to : "Stop using the interface of the 3rd version". Which will look like this :

# Code at the end of the script
POL_SetupWindow_Close
exit

Commanding POL_SetupWindow

You can add various functions to your scripts. Here is their syntax

This command allows you to introduce your application. It works just like the command "presentation".

POL_SetupWindow_presentation "Name of the Game" "Editor of the Game" "Game's web site" " "Game's prefix (Cf Chapter 5)"

Freer presentation :

POL_SetupWindow_free_presentation "Title" "Message"

Message

POL_SetupWindow_message "message" "Title"

A menu (~ is the separator, you can choose it)

POL_SetupWindow_menu "message" "Title" "Carrot~Potatoe~Scallion" "~"

Downloading a file

POL_SetupWindow_download "message" "Title" "URL"

Managing of the CDROM, the mount point is $CDROM

POL_SetupWindow_cdrom "CD number" POL_SetupWindow_check_cdrom path/to/the/setup.exe

Text zone

POL_SetupWindow_textbox "message" "Title" "default value"

Text zone with a browse button

POL_SetupWindow_browse "message" "Title" "default value"

Create Shortcuts

POL_SetupWindow_make_shorcut # Uses the same parameters as creer_lanceur

Asking a question :

POL_SetupWindow_question "question" "title"

Wait during a process

This is new. There is a way to instruct Playonlinux to wait while a process is executing.

You're basically instructing Playonlinux to : "Display a "Wait" window with a waiting bar until I instruct you otherwise"

Here's the syntax :

POL_SetupWindow_wait_next_signal "message" "title"
commande1...
commande2...
POL_SetupWindow_detect_exit
POL_SetupWindow_...

Exemple :

POL_SetupWindow_wait_next_signal "Installation of Steam" "Steam"
wine "steam.exe"
POL_SetupWindow_detect_exit
POL_SetupWindow_message "Steam installed"

Retrieving the commands' results

All you have to do is retrieve the data of the variable $APP_ANSWER after executing the command. Here's an exemple :-)

POL_SetupWindow_textbox "message" "Title" "default value"
MESSAGE="$APP_ANSWER"
POL_SetupWindow_message "you entered $MESSAGE"

Pour POL_SetupWindow_question, $APP_ANSWER is TRUE or FALSE depending on the answer.

Il n'y a rien à voir ici