Moved .i3/genconfig.bash into appropriate location.

This commit is contained in:
2013-09-20 23:28:19 +02:00
parent d0c26f52ee
commit d5fdd8f7b5
2 changed files with 5 additions and 34 deletions

View File

@@ -1,31 +0,0 @@
#!/bin/bash
# main configuration file that is always used
MAIN_CONF="$HOME/.i3/config"
# temporary configuration file used for this session
SESSION_CONF="$HOME/.i3/session.config"
# directory that contains host specific configuration
CONF_DIR="$HOME/.i3/config.d"
# file that should be used when no host specific configuration present
DEFAULT_CONF="$CONF_DIR/default"
host_specific_conf="$CONF_DIR/$(hostname).config"
# if it's a symlink to $MAIN_CONF, cat will fail
[[ -f "$SESSION_CONF" ]] && rm "$SESSION_CONF"
if [[ ! -f "$host_specific_conf" ]] && [[ ! -f "$DEFAULT_CONF" ]]; then
# if there is no host-specific configuration and no default one, just use
# the main config
ln -sf "$MAIN_CONF" "$SESSION_CONF"
else
# either use the host specific config if present, or the default if not
if [[ -f "$host_specific_conf" ]]; then
conf_to_use="$host_specific_conf"
else
conf_to_use="$DEFAULT_CONF"
fi
cat "$MAIN_CONF" "$conf_to_use" > "$SESSION_CONF"
fi
echo "$SESSION_CONF"

View File

@@ -7,9 +7,11 @@ SESSION_CONF="$HOME/.i3/session.config"
# directory that contains host specific configuration # directory that contains host specific configuration
CONF_DIR="$HOME/.i3/config.d" CONF_DIR="$HOME/.i3/config.d"
# file that should be used when no host specific configuration present # file that should be used when no host specific configuration present
DEFAULT_CONF="$CONF_DIR/default.config" DEFAULT_CONF="$CONF_DIR/default"
host_specific_conf="$CONF_DIR/$(hostname).config" host="$(hostname)"
host_specific_conf="$CONF_DIR/$host.config"
# if it's a symlink to $MAIN_CONF, cat will fail # if it's a symlink to $MAIN_CONF, cat will fail
[[ -f "$SESSION_CONF" ]] && rm "$SESSION_CONF" [[ -f "$SESSION_CONF" ]] && rm "$SESSION_CONF"
@@ -25,7 +27,7 @@ else
else else
conf_to_use="$DEFAULT_CONF" conf_to_use="$DEFAULT_CONF"
fi fi
cat "$MAIN_CONF" "$conf_to_use" > "$SESSION_CONF" cat "$MAIN_CONF" <(echo -e "\n###\n### host-specific configuration for host \"$host\"\n###\n") "$conf_to_use" > "$SESSION_CONF"
fi fi
echo "$SESSION_CONF" echo "$SESSION_CONF"