6.8 KiB
6.8 KiB
Application file
- privacy.sexy is a data-driven application where it reads the necessary OS-specific logic from
application.yaml - 💡 Best practices
- If you repeat yourself, try to utilize YAML-defined functions
- Always try to add documentation and a way to revert a tweak in scripts
- 📖 Types in code:
application.d.ts
Objects
Application
- Application file simply defines:
- different categories and their scripts in a tree structure
- OS specific details
- Application file also allows defining common functions to be used throughout the application if you'd like different scripts to share same code.
Application syntax
os:string(required)- Operating system that the application file is written for.
- 📖 See OperatingSystem.ts enumeration for allowed values.
actions: [Category, ... ](required)- Each category is rendered as different cards in card presentation.
- ❗ Application must consist of at least one category.
functions: [Function, ... ]- Functions are optionally defined to re-use the same code throughout different scripts.
scripting:ScriptingDefinition(required)- Defines the scripting language that the code of other action uses.
Category
- Category has a parent that has tree-like structure where it can have subcategories or subscripts.
- It's a logical grouping of different scripts and other categories.
Category syntax
category:string(required)- Name of the category
- ❗ Must be unique throughout the application
children: [Category|Script, ... ](required)- ❗ Category must consist of at least one subcategory or script.
- Children can be combination of scripts and subcategories.
Script
- Script represents a single tweak.
- A script must include either:
- A
codeandrevertCode - Or
callto call YAML-defined functions
- A
- 🙏 For any new script, please add
revertCodeanddocsvalues if possible.
Script syntax
name:string(required)- Name of the script
- ❗ Must be unique throughout the application
- E.g.
Disable targeted ads
code:string(may be required)- Batch file commands that will be executed
- 💡 If defined, best practice to also define
revertCode - ❗ If not defined
callmust be defined, do not define ifcallis defined.
revertCode:string- Code that'll undo the change done by
codeproperty. - E.g. let's say
codesets an environment variable assetx POWERSHELL_TELEMETRY_OPTOUT 1- then
revertCodeshould be doingsetx POWERSHELL_TELEMETRY_OPTOUT 0
- then
- ❗ Do not define if
callis defined.
- Code that'll undo the change done by
call:FunctionCall|[FunctionCall, ... ](may be required)- A shared function or sequence of functions to call (called in order)
- ❗ If not defined
codemust be defined
docs:string|[string, ... ]- Single documentation URL or list of URLs for those who wants to learn more about the script
- E.g.
https://docs.microsoft.com/en-us/windows-server/
recommend:"standard"|"strict"|undefined(default)- If not defined then the script will not be recommended
- If defined it can be either
standard: Only non-breaking scripts without limiting OS functionalitystrict: Scripts that can break certain functionality in favor of privacy and security
FunctionCall
- Describes a single call to a function by optionally providing values to its parameters.
- 👀 See parameter substitution for an example usage
FunctionCall syntax
function:string(required)- Name of the function to call.
- ❗ Function with same name must defined in
functionsproperty of Application
parameters:[ parameterName:parameterValue, ... ]-
Defines key value dictionary for each parameter and its value
-
E.g.
parameters: userDefinedParameterName: parameterValue # ... appName: Microsoft.WindowsFeedbackHub
-
Function
- Functions allow re-usable code throughout the defined scripts.
- Functions are templates compiled by privacy.sexy and uses special expressions.
- Expressions are defined inside mustaches (double brackets,
{{and}}) - 👀 See parameter substitution for an example usage
Parameter substitution
A simple function example
function: EchoArgument
parameters: [ 'argument' ]
code: Hello {{ $argument }} !
It would print "Hello world" if it's called in a script as following:
script: Echo script
call:
function: EchoArgument
parameters:
argument: World
Function syntax
name:string(required)- Name of the function that scripts will use.
- Convention is to use camelCase, and be verbs.
- E.g.
uninstallStoreApp - ❗ Function names must be unique
parameters:[string, ... ]- Name of the parameters that the function has.
- Parameter values are provided by a Script through a FunctionCall
- Parameter names must be defined to be used in expressions such as parameter substitution
- ❗ Parameter names must be unique
code:string(required) - Batch file commands that will be executed
- 💡 If defined, best practice to also define
revertCode
revertCode:string- Code that'll undo the change done by
codeproperty. - E.g. let's say
codesets an environment variable assetx POWERSHELL_TELEMETRY_OPTOUT 1- then
revertCodeshould be doingsetx POWERSHELL_TELEMETRY_OPTOUT 0
- then
- Code that'll undo the change done by
ScriptingDefinition
- Defines global properties for scripting that's used throughout the application file.
ScriptingDefinition syntax
language:string(required)- 📖 See ScriptingLanguage.ts enumeration for allowed values.
startCode:string(required)- Code that'll be inserted on top of user created script.
- Global variables such as
$homepage,$version,$datecan be used using parameter substitution code syntax such asWelcome to {{ $homepage }}!
endCode:string(required)- Code that'll be inserted at the end of user created script.
- Global variables such as
$homepage,$version,$datecan be used using parameter substitution code syntax such asWelcome to {{ $homepage }}!