Do silly things to allow terminals and thunar to open in cwd in emacs
This commit is contained in:
parent
65773a57b8
commit
a0c2954b51
@ -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 }
|
||||
|
@ -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"
|
||||
}
|
||||
|
13
.config/i3/passthrough
Executable file
13
.config/i3/passthrough
Executable file
@ -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
|
@ -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
|
Loading…
Reference in New Issue
Block a user