This is a small Linux utility program that creates wrappers for arbitrary executables to launch them with a predefined set of arguments and/or environment variables, without modifying the original executable.
This is primarily designed for Arch Linux. By default, the program will generate pacman hooks for the wrapped executable so that the wrapper is automatically recreated whenever the package associated with the wrapper is updated, reinstalled, or removed. This behavior can be disabled via a --nohooks flag so executables not managed by pacman (such as a script in /home) can be wrapped without requiring root.
- Rust 1.93 or later.
cargo install --path wrapperizeThe binary will be installed to
~/.cargo/bin/wrapperize.
~/.cargo/binmust be added to your$PATHif it isn't already.
$ wrapperize --help
Wrap an executable to always execute with additional arguments or environment variables.
Usage: wrapperize <executable_path> [options]
Arguments:
<executable_path> Absolute path to the executable to wrap
Options:
-a, --arg <ARG> An additional argument to launch the executable with. Can be used multiple times.
-e, --env <ENV> An environment variable in the format of `ENV=value`. Can be used multiple times.
--nohooks Do not generate pacman hooks.
--passthrough-args-first
Place the wrapper arguments after the passthrough arguments, so they are seen last by the wrapped executable.
-h, --help Print help information
Wrap /usr/bin/vim so it always launches with --servername=MYVIM:
sudo wrapperize /usr/bin/vim -a --servername=MYVIMAdd several arguments:
sudo wrapperize /usr/bin/gcc \
-a -O3 \
-a -march=nativeSet environment variables when launching the executable:
sudo wrapperize /usr/bin/ssh \
-e SSH_AUTH_SOCK=/run/user/1000/keyring/ssh \
-e SSH_ASKPASS=/usr/bin/ssh-askpassBy default the wrapper’s predefined arguments are placed before any additional arguments that may be passed to the wrapper.
If you need them after, specify the --passthrough-args-first flag during wrapper creation:
sudo wrapperize /usr/bin/python3 \
-a -O \
--passthrough-args-firstIf the binary isn’t managed by pacman (e.g., a script in /home), skip the hook generation:
wrapperize /home/user/myscript.sh -e MY_VAR=foo --nohooksThe original executable is renamed to a hidden file, and the generated wrapper script is created with the executable's original name:
/usr/bin/.vim-unwrapped ← original executable
/usr/bin/vim ← wrapper (generated by wrapperize)
The wrapper script will generally look like this (assuming both environment variables and arguments were defined during wrapper creation):
#!/usr/bin/env bash
export ENV1="value1"
export ENV2="value2"
exec "/usr/bin/.vim-unwrapped" --arg1 --arg2 "$@"Unless skipped via the --nohooks flag, the following pacman hooks will be created in /etc/pacman.d/hooks:
- Install/Update hook – runs after the executable's associated package is installed or upgraded to recreate the wrapper.
- A shell script is also generated next to this hook that is called by it to actually install the wrapper.
- Removal hook – runs after the executable's associated package is removed to delete the wrapper, pacman hooks, and the shell script created for the install/update hook.