fr

Create a script for PlayOnMac - Chapter 9: Standardization

Standardization, what is this thing?

To improve scripts readability, maintenability, debugging and translation, scripts are standardized. This means that things are added or modified so that scripts look and behave in a similar way.

We will detail what is affected.

Your script will also be available under GNU/Linux using PlayOnLinux

It may be useful to clarify (for those who would not know) that PlayOnLinux and PlayOnMac are really the same software, sharing the same code. Only the name changes depending on the operating system.

When you submit a script, it will be automatically available to PlayOnLinux, since if your script works with Mac OS X, it will also work under GNU/Linux (the reverse is not always true).

Standardization, let's begin

We will see several items to standardize in scripts.

The $TITLE variable

You should assign the variable $TITLE with the name of the script, and use it every time the name of the script is required.

Example:

#!/bin/bash
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="Mozilla Firefox" # Should be present in all your scripts

POL_SetupWindow_Init
...
POL_SetupWindow_presentation "$TITLE" "Mozilla" "http://www.mozilla.com" "YourNickname" "MozillaFirefox"
...
POL_Shortcut "firefox.exe" "$TITLE"
...

Obviously adapt it to the name of your script (that usually matches the name of the software it installs).

The variable $TITLE is notably required for the use of PlayOnMac's debugging system.

Use the $TITLE variable for window titles

To avoid confusing the user with disparate window titles, it is recommended to use the variable $TITLE as window title.

Example:

POL_SetupWindow_message "Message" "$TITLE"
POL_SetupWindow_browse "Message" "$TITLE"
POL_SetupWindow_wait "Message" "$TITLE"

The $PREFIX variable

You should store the name of the prefix in the variable $PREFIX, to make it easier to spot. This also avoids repeating prefix name in your script.

Example:

#!/bin/bash
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

TITLE="Mozilla Firefox"
PREFIX="MozillaFirefox"

POL_SetupWindow_Init
...
POL_SetupWindow_presentation "$TITLE" "Mozilla" "http://www.mozilla.com" "YourNickname" "$PREFIX"
...
POL_Wine_SelectPrefix "$PREFIX"
...
POL_System_TmpCreate "$PREFIX"
...

Some informations about the script

It is recommended to provide some informations near the beginning of the script, right after the #!/bin/bash line.

Syntax:

# Date : (Year-month-day hour-min)
# Last revision : (Year-month-day hour-min)
# Wine version used : 
# Distribution used to test : Distribution
# Author : Your nickname

Example:

#!/bin/bash
# Date : (2011-11-19 06-39)
# Last revision : (2011-11-19 06-39)
# Wine version used : 1.3.4
# Distribution used to test : Ubuntu 10.04 LTS
# Author : Your nickname

Enable debugging

PlayOnMac features a script debugging mode, that must be enabled thru a command.

It is mandatory to enable it, even if you have no use for it; Because if some user experiences a problem with your script, it will allow him to sent a bug report to the PlayOnMac website.

Syntax:

POL_Debug_Init

This command should be put right after the command POL_SetupWindow_Init.

Some more informations

Some more informations that did not fit in previous chapters, but that you should know nonetheless.

It is forbidden to use sudo

Commands sudo, su, gksudo, kdesu and similar are forbidden for the sake of security.

However, if you really need sudo (for example to display hidden files from hybrid PC/MAC DVDs, using mount command), you can use the following command:

Syntax:

POL_Call POL_Function_RootCommand "sudo command; exit"

Winetricks forbidden in scripts

Winetricks, or a similar script, is forbidden in PlayOnMac scripts.

Instead, you can use the very similar command POL_Call.

Syntax:

POL_Call Script

Example:

POL_Call POL_Install_vcrun6

The list of all the available scripts can be seen on this page.

Scripts translation

We're almost done with scripts standardization, the only item left is scripts translation. This will be the topic of the next chapter.

Previous chapter - Next chapter

Il n'y a rien à voir ici