Prefer $XDG_RUNTIME_DIR for storage

Closes #51.
This commit is contained in:
Chris Down 2017-10-24 19:14:09 +02:00
parent 4a0bd8f1f4
commit 6855d24e3a
4 changed files with 12 additions and 8 deletions

View file

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
: "${CM_LAUNCHER=dmenu}" : "${CM_LAUNCHER=dmenu}"
: "${TMPDIR=/tmp}" : "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}"
major_version=3 major_version=3
shopt -s nullglob shopt -s nullglob
cache_dir=$TMPDIR/clipmenu.$major_version.$USER cache_dir=$CM_DIR/clipmenu.$major_version.$USER
cache_file=$cache_dir/line_cache cache_file=$cache_dir/line_cache
if [[ $1 == --help ]] || [[ $1 == -h ]]; then if [[ $1 == --help ]] || [[ $1 == -h ]]; then
@ -20,7 +20,7 @@ All arguments are passed through to dmenu itself.
Environment variables: Environment variables:
- $CM_LAUNCHER: specify a dmenu-compatible launcher (default: dmenu) - $CM_LAUNCHER: specify a dmenu-compatible launcher (default: dmenu)
- $TMPDIR: specify the base directory to store the cache dir in (default: /tmp) - $CM_DIR: specify the base directory to store the cache dir in (default: $XDG_RUNTIME_DIR, $TMPDIR, or /tmp)
EOF EOF
exit 0 exit 0
fi fi

View file

@ -3,11 +3,11 @@
: "${CM_ONESHOT=0}" : "${CM_ONESHOT=0}"
: "${CM_OWN_CLIPBOARD=1}" : "${CM_OWN_CLIPBOARD=1}"
: "${CM_DEBUG=0}" : "${CM_DEBUG=0}"
: "${TMPDIR=/tmp}" : "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}"
: "${CM_MAX_CLIPS=1000}" : "${CM_MAX_CLIPS=1000}"
major_version=3 major_version=3
cache_dir=$TMPDIR/clipmenu.$major_version.$USER/ cache_dir=$CM_DIR/clipmenu.$major_version.$USER/
cache_file=$cache_dir/line_cache cache_file=$cache_dir/line_cache
lock_file=$cache_dir/lock lock_file=$cache_dir/lock
lock_timeout=2 lock_timeout=2
@ -64,7 +64,7 @@ Environment variables:
- $CM_DEBUG: turn on debugging output (default: 0) - $CM_DEBUG: turn on debugging output (default: 0)
- $CM_OWN_CLIPBOARD: take ownership of the clipboard (default: 1) - $CM_OWN_CLIPBOARD: take ownership of the clipboard (default: 1)
- $CM_MAX_CLIPS: maximum number of clips to store, 0 for inf (default: 1000) - $CM_MAX_CLIPS: maximum number of clips to store, 0 for inf (default: 1000)
- $TMPDIR: specify the base directory to store the cache dir in (default: /tmp) - $CM_DIR: specify the base directory to store the cache dir in (default: $XDG_RUNTIME_DIR, $TMPDIR, or /tmp)
EOF EOF
exit 0 exit 0
fi fi

View file

@ -4,8 +4,10 @@ set -x
set -e set -e
set -o pipefail set -o pipefail
: "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}"
major_version=3 major_version=3
dir=/tmp/clipmenu.$major_version.$USER dir=$CM_DIR/clipmenu.$major_version.$USER
cache_file=$dir/line_cache cache_file=$dir/line_cache
if [[ $0 == /* ]]; then if [[ $0 == /* ]]; then

View file

@ -6,7 +6,9 @@ msg() {
printf '>>> %s\n' "$@" >&2 printf '>>> %s\n' "$@" >&2
} }
dir=/tmp/clipmenu.$major_version.$USER : "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}"
dir=$CM_DIR/clipmenu.$major_version.$USER
cache_file=$dir/line_cache cache_file=$dir/line_cache
log=$(mktemp) log=$(mktemp)