mirror of
https://github.com/frebib/dotfiles.git
synced 2024-06-14 12:57:23 +00:00
Joe Groocock
7f79cca7bc
systemd-run uses the last passed argument for each flag, so specify the default first, and the override afterwards, if set
21 lines
489 B
Bash
Executable File
21 lines
489 B
Bash
Executable File
#!/bin/bash -e
|
|
|
|
rand=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 16)
|
|
|
|
args=()
|
|
while getopts "u:s:e:d:cnw" opt
|
|
do case "$opt" in
|
|
u) args+=("--unit=$OPTARG-$rand");;
|
|
s) args+=("--slice=$OPTARG");;
|
|
e) args+=("--setenv=$OPTARG");;
|
|
d) args+=("--working-directory=$OPTARG");;
|
|
c) args+=("--scope");;
|
|
n) args+=("--no-block");;
|
|
w) args+=("--wait");;
|
|
*) shift;;
|
|
esac
|
|
done
|
|
shift $((OPTIND-1))
|
|
|
|
exec systemd-run --user --collect --unit="$1-$rand" ${args[@]} -- "$@"
|