1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

i3: launch i3 programs with systemd

This parents each program within it's own service/scope to the systemd user session, independent of i3
This commit is contained in:
2020-03-22 12:33:26 +00:00
parent 8e86599372
commit 9aeeee58d0
2 changed files with 39 additions and 18 deletions

20
scripts/systemd-run-i3 Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash -e
args=()
while getopts "u:s:e:d:cnw" opt
do case "$opt" in
u) args+=("--unit=$OPTARG");;
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))
rand=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 16)
exec systemd-run --user --collect ${args[@]} --unit="$1-$rand" -- "$@"