diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml index 1b1813a..0523c41 100644 --- a/.config/alacritty/alacritty.yml +++ b/.config/alacritty/alacritty.yml @@ -101,7 +101,7 @@ key_bindings: - { key: Key0, mods: Control, action: ResetFontSize } - { key: Equals, mods: Control, action: IncreaseFontSize } - { key: Subtract, mods: Control, action: DecreaseFontSize } - - { key: N, mods: Control|Shift, action: SpawnNewInstance } + - { key: Return, mods: Super, action: SpawnNewInstance } - { key: Backslash, mods: Command, command: "/home/adam/.config/alacritty/swapColors.sh" } - { key: Home, chars: "\x1bOH", mode: AppCursor } - { key: Home, chars: "\x1b[H", mode: ~AppCursor } diff --git a/.config/i3/config b/.config/i3/config index ec28162..54e37de 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -29,7 +29,11 @@ set $mon2 LVDS-0 set $config_dir /home/adam/.config/i3 ## Keybindings! ## -bindsym $mod+Return exec ~/.config/i3/spawn-alacritty-cwd # start a terminal +mode "bypass" { + bindsym $mod+Escape mode "default" +} + +bindsym --release $mod+Return exec $config_dir/passthrough "Emacs|Alacritty" "super+Return" alacritty # start a terminal bindsym $mod+e exec emacsclient -c -n # start emacs bindsym $mod+Shift+e exec emacsclient -ce '(nm)' # start NeverMore @@ -42,7 +46,7 @@ bindsym $mod+Print exec scrot '/home/adam/scratch/%Y-%m-%d_%H:%M:%S.png' mode "launch" { bindsym e exec emacsclient -c -n; mode "default" bindsym f exec firefox; mode "default" - bindsym t exec thunar; mode "default" + bindsym --release t exec $config_dir/passthrough "Emacs" "super+t" thunar; mode "default" bindsym Escape mode "default" bindsym Return mode "default" } diff --git a/.config/i3/passthrough b/.config/i3/passthrough new file mode 100755 index 0000000..3c5c54a --- /dev/null +++ b/.config/i3/passthrough @@ -0,0 +1,13 @@ +#!/bin/bash + +ACTIVE_WINDOW=$(xdotool getactivewindow) +ACTIVE_WM_CLASS=$(xprop -id $ACTIVE_WINDOW | grep WM_CLASS) + +if [[ $ACTIVE_WM_CLASS =~ $1 ]] +then + i3 mode bypass + xdotool key --clearmodifiers --window $ACTIVE_WINDOW "$2" + i3 mode default +else + $3 +fi diff --git a/.config/i3/spawn-alacritty-cwd b/.config/i3/spawn-alacritty-cwd deleted file mode 100755 index 0b38aa1..0000000 --- a/.config/i3/spawn-alacritty-cwd +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# Spawn a new instance of Alacritty using the CWD of the currently focused -# Alacritty process. -# -# This is useful in environment like i3 where terminals are opened using a -# key-combination while another terminal is already focused. -# -# If the script is run with a non-Alacritty window in focus or a non-compliant -# version of Alacritty, the script will exit with code 1. This makes it possible -# to use the script like -# -# spawn-alacritty-cwd || alacritty -# - -ACTIVE_WINDOW=$(xdotool getactivewindow) -ACTIVE_WM_CLASS=$(xprop -id $ACTIVE_WINDOW | grep WM_CLASS) - -if [[ $ACTIVE_WM_CLASS == *"Alacritty"* ]] -then - # Get PID. If _NET_WM_PID isn't set, bail. - PID=$(xprop -id $ACTIVE_WINDOW | grep _NET_WM_PID | grep -oP "\d+") - if [[ "$PID" == "" ]] - then - exit 1 - fi - - # Get first child of terminal - CHILD_PID=$(pgrep -P $PID) - if [[ "$PID" == "" ]] - then - exit 1 - fi - - # Get current directory of child. The first child should be the shell. - pushd "/proc/${CHILD_PID}/cwd" - SHELL_CWD=$(pwd -P) - popd - - # Start alacritty with the working directory - alacritty --working-directory $SHELL_CWD -else - alacritty -fi