sx: create XAUTHORITY directory components

We need to do this in sx as neither xauth(1) or touch(1) will create the
path.  Requiring the user to do this would lead to additional code on
their side to account for a detail that sx already controls.  There
is no obvious benefit for omitting this functionality.
This commit is contained in:
Earnestly 2017-12-04 11:58:32 +00:00
parent 60762a5487
commit 64038adef2
1 changed files with 2 additions and 5 deletions

7
sx
View File

@ -4,10 +4,7 @@
# requires fgconsole stty timeout xauth Xorg # requires fgconsole stty timeout xauth Xorg
# I'm willing to take advantage of errexit for this script as roughly 85% of # I'm willing to take advantage of errexit for this script as roughly 85% of
# the error checking would take the form of: # the error checking would just be exiting on command failure.
# if ! command; then
# exit
# fi
set -o errexit set -o errexit
cleanup() { cleanup() {
@ -46,7 +43,7 @@ esac
cfgdir=${XDG_CONFIG_HOME:-$HOME/.config}/sx cfgdir=${XDG_CONFIG_HOME:-$HOME/.config}/sx
export XAUTHORITY=${XAUTHORITY:-$cfgdir/xauthority} export XAUTHORITY=${XAUTHORITY:-$cfgdir/xauthority}
mkdir -p "$cfgdir" mkdir -p "$cfgdir" "${XAUTHORITY%/*}"
touch "$XAUTHORITY" touch "$XAUTHORITY"
trap 'cleanup "$pid"' EXIT trap 'cleanup "$pid"' EXIT