3
# dirs: some dirs needed by all library status scripts
5
# Copyright (C) 2011 Dustin Kirkland
7
# Authors: Dustin Kirkland <kirkland@ubuntu.com>
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, version 3 of the License.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
23
# Some users build and install byobu themselves, rather than from a distro
24
[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc"
25
[ -n "$BYOBU_PREFIX" ] || BYOBU_PREFIX="/usr"
27
# Create and export the user configuration directory
28
if [ -d "$BYOBU_CONFIG_DIR" ]; then
29
export BYOBU_CONFIG_DIR="$BYOBU_CONFIG_DIR"
30
elif [ -d "$XDG_CONFIG_HOME" ]; then
31
# Use XDG, as some users insist on such nonsense :-)
32
export BYOBU_CONFIG_DIR="$XDG_CONFIG_HOME/$PKG"
33
elif [ -d "$HOME/.local/share/$PKG" ]; then
34
# Use XDG common directory, if it exists
35
export BYOBU_CONFIG_DIR="$HOME/.local/share/$PKG"
37
# And to default to good old classic config dir location!
38
export BYOBU_CONFIG_DIR="$HOME/.$PKG"
40
[ -d "$BYOBU_CONFIG_DIR" ] || mkdir -p "$BYOBU_CONFIG_DIR"
42
# Grab the global, then local socket directory
43
[ -r "/etc/$PKG/socketdir" ] && . "/etc/$PKG/socketdir"
44
[ -r "$BYOBU_CONFIG_DIR/socketdir" ] && . "$BYOBU_CONFIG_DIR/socketdir"
46
# Create and export the runtime cache directory
47
if [ -w /dev/shm ]; then
48
# Use shm for performance, if possible
49
for i in /dev/shm/$PKG-$USER-*; do
50
if [ -d "$i" ] && [ -O "$i" ]; then
51
export BYOBU_RUN_DIR="$i"
55
# Still empty, make a new one
56
if [ ! -d "$BYOBU_RUN_DIR" ] || [ ! -O "$BYOBU_RUN_DIR" ]; then
57
export BYOBU_RUN_DIR=$(mktemp -d /dev/shm/$PKG-$USER-XXXXXXXX)
60
# For distros that don't have a /dev/shm, use local disk
61
if [ -d "$XDG_CACHE_HOME" ]; then
62
# Use XDG, as some users insist on such nonsense :-)
63
export BYOBU_RUN_DIR="$XDG_CACHE_HOME/$PKG"
65
# But if not, we'll use a cache directory
66
export BYOBU_RUN_DIR="$HOME/.cache/$PKG"