mirror of
				https://github.com/frebib/dotfiles.git
				synced 2024-06-14 12:57:23 +00:00 
			
		
		
		
	When the graphical-session target exits, this should terminal all units bound to it. Signed-off-by: Joe Groocock <me@frebib.net>
		
			
				
	
	
		
			30 lines
		
	
	
		
			583 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			583 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash -e
 | 
						|
 | 
						|
rand=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 8)
 | 
						|
 | 
						|
args=()
 | 
						|
while getopts "s:e:d:cnw" opt
 | 
						|
do case "$opt" in
 | 
						|
    s) 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))
 | 
						|
 | 
						|
if [ -z "$slice" ]; then
 | 
						|
    slice=app
 | 
						|
fi
 | 
						|
 | 
						|
exec systemd-run \
 | 
						|
    --user \
 | 
						|
    --collect \
 | 
						|
    --slice="$slice" \
 | 
						|
    --unit="$slice-$1-$rand" \
 | 
						|
    --property=BindsTo=graphical-session.target \
 | 
						|
    ${args[@]} -- "$@"
 |