Changed lots of things, too lazy to comment it all.

This commit is contained in:
2014-04-22 22:15:26 +02:00
parent 54686eef5a
commit 95f5781a21
15 changed files with 181 additions and 538 deletions

View File

@@ -9,6 +9,14 @@ CONF_DIR="$HOME/.i3/config.d"
# file that should be used when no host specific configuration present
DEFAULT_CONF="$CONF_DIR/default"
LOGFILE="$LOGDIR/i3/genconfig.log"
mkdir -p "$(dirname $LOGFILE)"
log() {
echo "[$(date +%FT%T)] $*" >> "$LOGFILE"
}
host="$(hostname)"
host_specific_conf="$CONF_DIR/$host.config"
@@ -19,15 +27,19 @@ host_specific_conf="$CONF_DIR/$host.config"
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
log "neither config for host $host nor default config at $DEFAULT_CONF found, using main only"
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
log "found config for host $host at $host_specific_conf"
conf_to_use="$host_specific_conf"
else
log "no config for host $host found, using default one"
conf_to_use="$DEFAULT_CONF"
fi
cat "$MAIN_CONF" <(echo -e "\n###\n### host-specific configuration for host \"$host\"\n###\n") "$conf_to_use" > "$SESSION_CONF"
log "created session config at $SESSION_CONF"
fi
echo "$SESSION_CONF"
@@ -35,4 +47,7 @@ echo "$SESSION_CONF"
# if we got any parameters, tell i3 to reload the config
# so the script can be used both on startup without reload (as i3 is not even
# running yet) and later when reloading
[[ -n "$1" ]] && i3-msg reload
if [[ -n "$1" ]] ; then
log "telling i3 to reload the config file"
i3-msg reload
fi