Support shared, device-specific i3 configurations

Separated i3/configuration since some of my devices support XFree86 keysyms
while others do not. This introduced some cascading changes.

- Removed ~/.config/i3/config from this repo. Since I will be switching between
  devices semi-regularly and that file will be generated each time I switch to a
  different device running an X session, I don't want the i3/config to spam my
  `gst` and `gd` when I haven't changed configuration in either config.shared or
  config.device.
- Update aliases, variables, etc. to point to config.shared instead of the
  generated file.
- Ensure that X sessions generate the i3/config file.
- Ensure that i3 reload and restart command generate the i3/config file.
This commit is contained in:
William Carroll 2019-03-23 16:31:59 +00:00
parent ef8621e7da
commit 7bcfa26f51
9 changed files with 54 additions and 34 deletions

View file

@ -0,0 +1,14 @@
# Desktop-specific configuration
# Since the keyboard for my desktop doesn't support XFree86 keysyms, prefer
# alternative KBDs.
# volume controls
bindsym F1 exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # same Fn keys as laptop
bindsym F2 exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% # same Fn keys as laptop
bindsym F3 exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% # same Fn keys as laptop
# playback controls
bindsym F4 exec --no-startup-id playerctl previous # same Fn keys as laptop
bindsym F5 exec --no-startup-id playerctl play-pause # same Fn keys as laptop
bindsym F6 exec --no-startup-id playerctl next # same Fn keys as laptop

View file

@ -0,0 +1,18 @@
# Laptop-specific configuration
# My laptop has keys for XFree86 signals that my desktop keyboard currently
# doesn't have.
# volume controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% # MBP Volume Up
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% # MBP Volume Down
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # MBP Mute
# playback controls
bindsym XF86AudioPrev exec --no-startup-id playerctl previous
bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause
bindsym XF86AudioNext exec --no-startup-id playerctl next
# screen brightness controls
bindsym XF86MonBrightnessUp exec light -A 10
bindsym XF86MonBrightnessDown exec light -U 10

View file

@ -70,7 +70,7 @@
"ef" (lambda () (interactive) (wpc/find-file-split "~/functions.zsh"))
"el" (lambda () (interactive) (wpc/find-file-split "~/variables.zsh"))
"ex" (lambda () (interactive) (wpc/find-file-split "~/.Xresources"))
"ei" (lambda () (interactive) (wpc/find-file-split "~/.config/i3/config"))
"ei" (lambda () (interactive) (wpc/find-file-split "~/.config/i3/config.shared"))
"em" (lambda () (interactive) (wpc/find-file-split "~/.tmux.conf"))
"B" #'magit-blame

View file

@ -59,7 +59,7 @@
(set-register ?f '(file . "~/functions.zsh"))
(set-register ?l '(file . "~/variables.zsh"))
(set-register ?x '(file . "~/.Xresources"))
(set-register ?i '(file . "~/.config/i3/config"))
(set-register ?i '(file . "~/.config/i3/config.shared"))
(set-register ?m '(file . "~/.tmux.conf"))
(set-register ?p `(file . ,wpc/current-project))

View file

@ -1,6 +1,3 @@
set $mod Mod1
set $super Mod4
# Keymapping philosophy:
# When I feel it's appropriate, I try to borrow existing KBDs from OSX or
# Windows. For example, I use Ctrl+Alt+Del to start the screen lock, since this
@ -15,6 +12,9 @@ set $super Mod4
# than it is in Linux, I prefer to support the OSX KBDs to reduce the number of
# KBDs my feeble memory needs to store.
set $mod Mod1
set $super Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8
@ -51,21 +51,9 @@ bindsym $mod+Ctrl+Shift+e split h; exec emacsclient --create-frame ~/progra
bindsym $mod+Ctrl+Shift+c split h; exec google-chrome
bindsym $mod+Ctrl+Shift+s split h; exec spotify
# audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% # MBP Volume Up
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% # MBP Volume Down
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # MBP Mute
bindsym F12 exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% # same Fn keys as MBP
bindsym F11 exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% # same Fn keys as MBP
bindsym F10 exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # same Fn keys as MBP
# pass integration
bindsym $mod+Ctrl+backslash exec ~/.config/i3/passmenu # mirroring the 1password KBD
# screen brightness controls
bindsym XF86MonBrightnessUp exec light -A 10
bindsym XF86MonBrightnessDown exec light -U 10
# integrate with Emacs's org-mode
bindsym $mod+o exec zsh -i -c org_capture
for_window [class="GoogleEmacs" instance="org-protocol-capture"] floating enable
@ -84,21 +72,16 @@ bindsym $mod+space exec --no-startup-id dmenu_run
bindsym $mod+t exec --no-startup-id ~/.config/i3/dmenu_timer.sh ~/.local/share/sounds/gong.mp3
# file manager
bindsym $mod+x exec st -e lf
# music player kbds
bindsym F9 exec --no-startup-id playerctl next # same Fn keys as MBP
bindsym F8 exec --no-startup-id playerctl play-pause # same Fn keys as MBP
bindsym F7 exec --no-startup-id playerctl previous # same Fn keys as MBP
bindsym $mod+n exec st -e lf
# Screenshot
bindsym $mod+s exec zsh -i -c snipit
bindsym Ctrl+Print exec scrot ~/Pictures/screenshots/%b-%d-%Y_%T.png # Windows style
bindsym $mod+Shift+4 exec zsh -i -c snipit
bindsym Ctrl+Print exec scrot ~/Pictures/screenshots/%b-%d-%Y_%T.png # Windows style
bindsym $mod+Shift+3 exec scrot ~/Pictures/screenshots/%b-%d-%Y_%T.png # OSX style
# TODO: debug
bindsym $mod+Print exec scrot --focused ~/Pictures/screenshots/%b-%d-%Y_%T.png # Windows style
bindsym $mod+Shift+3 exec scrot ~/Pictures/screenshots/%b-%d-%Y_%T.png # OSX style
# bindsym $mod+Print exec scrot --focused ~/Pictures/screenshots/%b-%d-%Y_%T.png # Windows style
# TODO: debug
bindsym $mod+Shift+4 exec scrot --select ~/Pictures/screenshots/%b-%d-%Y_%T.png # OSX style
# bindsym $mod+Shift+4 exec scrot --select ~/Pictures/screenshots/%b-%d-%Y_%T.png # OSX style
# Integration with Google's screenshot hosting server
# online documentation
@ -212,8 +195,8 @@ bindsym $mod+Ctrl+9 move container to workspace $ws9
bindsym $mod+Ctrl+0 move container to workspace $ws10
# reload, restart i3
bindsym $super+r reload
bindsym $super+Shift+r restart
bindsym $super+r exec cat ~/.config/i3/config.shared ~/.config/i3/config.device >~/.config/i3/config; reload
bindsym $super+Shift+r exec cat ~/.config/i3/config.shared ~/.config/i3/config.device >~/.config/i3/config; restart
# resize window (you can also use the mouse for that)
@ -268,6 +251,6 @@ bar {
focused_workspace $black $black $bright_cyan
active_workspace $red $bright_blue $blue
inactive_workspace $black $black $bright_black
urgent_workspace $bright_black $black $magenta
urgent_workspace $magenta $black $magenta
}
}

View file

@ -267,7 +267,7 @@ nnoremap <leader>ea :vsplit ~/aliases.zsh<CR>
nnoremap <leader>ef :vsplit ~/functions.zsh<CR>
nnoremap <leader>el :vsplit ~/variables.zsh<CR>
nnoremap <leader>ex :vsplit ~/.Xresources<CR>
nnoremap <leader>ei :vsplit ~/.config/i3/config<CR>
nnoremap <leader>ei :vsplit ~/.config/i3/config.shared<CR>
" quickly source your vimrc
nnoremap <leader>sv :source $MYVIMRC<CR>

View file

@ -23,5 +23,10 @@ emacs --daemon
xmodmap -e 'remove Lock = Caps_Lock'
xmodmap -e 'keysym Caps_Lock = Escape'
# since we separated our i3 configurations between a shared and device-specific
# setup, we need to make sure that when we start an X session, our i3
# configuration is up-to-date.
cat ~/.config/i3/config.{shared,device} >~/.config/i3/config
# set key repeat preferences
xset r rate 250 60

View file

@ -142,7 +142,7 @@ alias ea='e ~/aliases.zsh'
alias ef='e ~/functions.zsh'
alias el='e ~/variables.zsh'
alias ex='e ~/.Xresources'
alias ei='e ~/.config/i3/config'
alias ei='e ~/.config/i3/config.shared'
alias em='e ~/.tmux.conf'
# couple the s* aliases to the <leader>s* kbds in vim

View file

@ -48,4 +48,4 @@ a="$HOME/aliases.zsh"
f="$HOME/functions.zsh"
l="$HOME/variables.zsh" # v is taken by vim
x="$HOME/.Xresources"
i="$HOME/.config/i3/config"
i="$HOME/.config/i3/config.shared"