import-env: fail if no matching process is found

This commit is contained in:
crater2150 2023-09-04 09:59:24 +02:00
parent d5fa2e99de
commit 9b6c44cce0
7 changed files with 8 additions and 7 deletions

View file

@ -7,5 +7,5 @@ if [[ ! -e ${0:a:h}/server ]] then
exit 1 exit 1
fi fi
source ${0:a:h:h}/import-env.zsh source ${0:a:h:h}/import-env.zsh
import-env awesome import-env awesome | exit 1
exec barrierc --no-daemon $(<${0:a:h}/server) exec barrierc --no-daemon $(<${0:a:h}/server)

View file

@ -1,4 +1,4 @@
#!/bin/zsh #!/bin/zsh
source ${0:a:h:h}/import-env.zsh source ${0:a:h:h}/import-env.zsh
import-env awesome import-env awesome | exit 1
exec barriers --no-daemon -c ${XDG_CONFIG_HOME:-$HOME/.config}/Debauchee/home.conf exec barriers --no-daemon -c ${XDG_CONFIG_HOME:-$HOME/.config}/Debauchee/home.conf

View file

@ -1,6 +1,7 @@
import-env() { import-env() {
SOURCE_PROCESS=$1 SOURCE_PROCESS=$1
SOURCE_PID=$(pgrep $SOURCE_PROCESS | head -n 1) SOURCE_PID=$(pgrep $SOURCE_PROCESS | head -n 1)
if [[ -z $SOURCE_PID ]]; then return 1; fi
SOURCE_ENV=("${(@ps:\000:)$(</proc/${SOURCE_PID}/environ)}") SOURCE_ENV=("${(@ps:\000:)$(</proc/${SOURCE_PID}/environ)}")
export ${SOURCE_ENV[@]:#} export ${SOURCE_ENV[@]:#}
} }

View file

@ -8,7 +8,7 @@ ln -s ${XDG_RUNTIME_DIR:-/run/user/$UID}/supervise.$1 $1/supervise
echo '#!/bin/zsh' echo '#!/bin/zsh'
if [[ $importenv ]]; then if [[ $importenv ]]; then
echo 'source ${0:a:h:h}/import-env.zsh' echo 'source ${0:a:h:h}/import-env.zsh'
echo "import-env ${importenv[2]}" echo "import-env ${importenv[2]} || exit 1"
fi fi
echo "exec $*" echo "exec $*"
} > $1/run } > $1/run

View file

@ -1,8 +1,8 @@
#!/bin/zsh #!/bin/zsh
exec 2>&1 exec 2>&1
source common.zsh source ${0:a:h:h}/import-env.zsh
import-env awesome import-env awesome || exit 1
. $HOME/.local/share/pyenv/versions/3.10.0/envs/pass_secret_service/bin/activate . $HOME/.local/share/pyenv/versions/3.10.0/envs/pass_secret_service/bin/activate
pass_secret_service pass_secret_service

View file

@ -1,4 +1,4 @@
#!/bin/zsh #!/bin/zsh
source ${0:a:h:h}/import-env.zsh source ${0:a:h:h}/import-env.zsh
import-env awesome import-env awesome | exit 1
exec picom exec picom

View file

@ -1,4 +1,4 @@
#!/bin/zsh #!/bin/zsh
source ${0:a:h:h}/import-env.zsh source ${0:a:h:h}/import-env.zsh
import-env awesome import-env awesome | exit 1
exec xss-lock -l -- xsecurelock-wrapper 2>&1 exec xss-lock -l -- xsecurelock-wrapper 2>&1