From 5caefa1b2bf4979a77aac842d1672e21927c3b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Wed, 18 Sep 2013 19:27:36 +0200 Subject: [PATCH] Added dynamic config generation for i3. The script genconfig.bash concatenates the main configuration file with a host specific one to create a session-specific configration file that is then passed to i3. It therefore has to be called in .xinitrc or something comparable before starting i3. If no host specific configuration is found, a default file will be used instead. This is useful for providing default that should not go into the main configuration file, maybe because they are incompatible with some host specific settings. For example a default bar{} block goes there, as if this was in the main config, two i3bar instances would be started when a host specific config specifies its own. --- i3/i3/.gitignore | 1 + i3/i3/config | 39 ----------------------------------- i3/i3/config.d/default.config | 3 +++ i3/i3/config.d/netbook.config | 38 ++++++++++++++++++++++++++++++++++ i3/i3/i3status.conf | 2 +- i3/i3/scripts/genconfig.bash | 31 ++++++++++++++++++++++++++++ vim/vimrc | 2 +- x/xinitrc | 24 ++++++++++++++------- 8 files changed, 91 insertions(+), 49 deletions(-) create mode 100644 i3/i3/.gitignore create mode 100644 i3/i3/config.d/default.config create mode 100644 i3/i3/config.d/netbook.config create mode 100644 i3/i3/scripts/genconfig.bash diff --git a/i3/i3/.gitignore b/i3/i3/.gitignore new file mode 100644 index 0000000..6e74f38 --- /dev/null +++ b/i3/i3/.gitignore @@ -0,0 +1 @@ +session.config diff --git a/i3/i3/config b/i3/i3/config index e5cbfd1..6cb223e 100644 --- a/i3/i3/config +++ b/i3/i3/config @@ -214,38 +214,6 @@ for_window [class="^Xfce4-notifyd$"] floating enable for_window [class="^Conky$" ] floating enable -# Start i3bar to display a workspace bar (plus the system information i3status -# finds out, if available) -bar -{ - # always show at the bottom of the screen - mode dock - position bottom - - # show a tray area - tray_output primary - - # show workspace buttons - workspace_buttons yes - - id bar-1 - - font pango:DejaVu Sans Mono 8 - - colors { - background #000000 - statusline #ffffff - separator #666666 - - focused_workspace #4c7899 #285577 #ffffff - active_workspace #333333 #5f676a #ffffff - inactive_workspace #333333 #222222 #888888 - urgent_workspace #2f343a #900000 #ffffff - } - - i3bar_command i3bar - status_command i3status --config $path_i3status_config -} @@ -274,10 +242,3 @@ mode "$mode_system" { } bindsym $mod+Pause mode "$mode_system" bindsym $mod+Shift+Pause exec --no-startup-id $path_i3exit lock - - -bindsym XF86Sleep exec --no-startup-id $path_i3exit suspend - -bindsym XF86AudioMute exec --no-startup-id amixer set Master toggle -bindsym XF86AudioRaiseVolume exec --no-startup-id amixer set Master %5+ -bindsym XF86AudioLowerVolume exec --no-startup-id amixer set Master %5- diff --git a/i3/i3/config.d/default.config b/i3/i3/config.d/default.config new file mode 100644 index 0000000..b3c19a2 --- /dev/null +++ b/i3/i3/config.d/default.config @@ -0,0 +1,3 @@ +bar { + status_command i3status +} diff --git a/i3/i3/config.d/netbook.config b/i3/i3/config.d/netbook.config new file mode 100644 index 0000000..5197a9f --- /dev/null +++ b/i3/i3/config.d/netbook.config @@ -0,0 +1,38 @@ + +# bind some keys +bindsym XF86Sleep exec --no-startup-id $path_i3exit suspend +bindsym XF86AudioMute exec --no-startup-id amixer set Master toggle +bindsym XF86AudioRaiseVolume exec --no-startup-id amixer set Master %5+ +bindsym XF86AudioLowerVolume exec --no-startup-id amixer set Master %5- + +# start i3bar to display a workspace bar (plus the system information i3status +# finds out, if available) +bar { + # always show at the bottom of the screen + mode dock + position bottom + + # show a tray area + tray_output primary + + # show workspace buttons + workspace_buttons yes + + id bar-1 + + font pango:DejaVu Sans Mono 8 + + colors { + background #000000 + statusline #ffffff + separator #666666 + + focused_workspace #4c7899 #285577 #ffffff + active_workspace #333333 #5f676a #ffffff + inactive_workspace #333333 #222222 #888888 + urgent_workspace #2f343a #900000 #ffffff + } + + i3bar_command i3bar + status_command i3status --config $path_i3status_config +} diff --git a/i3/i3/i3status.conf b/i3/i3/i3status.conf index 6021e11..cda31b7 100644 --- a/i3/i3/i3status.conf +++ b/i3/i3/i3status.conf @@ -54,7 +54,7 @@ run_watch VPN { } tztime local { - format = "%Y-%m-%d %H:%M:%S" + format = "%a %Y-%m-%d %H:%M:%S" } load { diff --git a/i3/i3/scripts/genconfig.bash b/i3/i3/scripts/genconfig.bash new file mode 100644 index 0000000..332d5d7 --- /dev/null +++ b/i3/i3/scripts/genconfig.bash @@ -0,0 +1,31 @@ +#!/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.config" + +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" diff --git a/vim/vimrc b/vim/vimrc index 4f5d884..0d8a4e6 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -126,7 +126,7 @@ set foldmethod=indent " fold according to indet set foldnestmax=2 " fold a maximum of 2 levels set nofoldenable " unfold everything by default -set scrolloff=5 " show context at the screen edges +set scrolloff=4 " show context at the screen edges set showcmd " show (partial) command in the command line diff --git a/x/xinitrc b/x/xinitrc index cc654e1..3e0a07b 100755 --- a/x/xinitrc +++ b/x/xinitrc @@ -10,19 +10,27 @@ fi [ -f /etc/xprofile ] && source /etc/xprofile [ -f ~/.xprofile ] && source ~/.xprofile + +# keyboard options +keyboard_layout=de +keyboard_options= nodeadkeys +keyboard_repeat_delay=150 +keyboard_repeat_speed=30 + # execute the host-specific .xinitrc-addition hostfile="$HOME/.xinitrc.d/$(hostname).xinitrc" [[ -f "$hostfile" ]] && bash "$hostfile" & +# set keyboard layout +setxkbmap $keyboard_layout $keyboard_options + +# set key repeat delay +xset r rate $keyboard_repeat_delay $keyboard_repeat_speed + + case $1 in -e17) - exec enlightenment_start - ;; -i3) - exec i3 - ;; -xfce4) ;; *) - exec i3 + SESSION_CONF=$(bash "$HOME/.i3/scripts/genconfig.bash") + exec i3 -c "$SESSION_CONF" ;; esac