-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: focus last window #26
Comments
Why would you use it? I'm pretty curious. I've been thinking of adding a config key for focusing the previously focused window after the currently focused window is closed. |
Well, most of the windows managers and even terminal multiplexers allows you to quick switch between the current and previously focused window. It's really efficiently in my opinion.
Yes! This is also what I wanted to ask. Because when you close some window and don't use sloppy focus you need to do extra move to set focus. It's annoying sometimes. |
what should happen if the previously focused window is destroyed? should the previously focused window be set to the second previously focused window? |
Yes, and if second previously focused window is destroyed it should focus third and so on. |
well, because that would be pretty complicated because windowchef stores the focused window in a variable and that would be replaced by a stack, it would be simpler to write a script using |
Just an idea: maybe this can use the functions introduced by the cardinal focus feature. |
So here is script. Maybe it will be useful for someone. It stores focused windows in file and focus previously focused window after currently focused window is closed or unmapped (and it will be ignore to focus unmapped windows so it will be work with groups) #! /bin/sh
wlist="/tmp/.wlist"
[ -e $wlist ] && rm $wlist
wew -m 2097152 | while IFS=: read ev wid; do
case $ev in
# Focus in event. Write wid to the window list
9)
echo $wid >> $wlist
;;
# Destroy event. Delete wid from the window list
17)
grep -v $wid $wlist > $wlist.tmp
mv $wlist.tmp $wlist
;;
# Unmap event. Focus last wid from the window list. Ignore unmapped windows.
18)
for id in $(tac $wlist); do
wattr m $id && [ "$wid" != "$id" ] && waitron window_focus $id && break
done
;;
esac
done In additional to focus last focused window, you should bind following script to some hotkey. For example #! /bin/sh
wlist="/tmp/.wlist"
for id in $(tac $wlist); do
[ "$(pfw)" != "$id" ] && mapw -m $id && waitron window_focus $id && break
done
|
Kinda off-topic: should I make a directory inside the repo with example scripts? |
It makes sense |
Here you go. It seems to work pretty well so far, I haven't had any glaring issues in the ten minutes or so that I've been using it. I would've used bash but I'm not great at it. Edit: I just saw @dialuplama's solution. I'd probably use that over this, but we'll see where it takes me. Edit2: There are a few edge cases that I didn't consider. Definitely go with the shell script, my version needs some work... |
Just put in a PR for this #29 EDIT: Also this change would allow a "toggle last focused" to work. I didn't expose it in the PR, but I don't see it being much work to add. Additionally, it would also be possible to wrap the "toggle last focused on unmapped or window destroy/close" in a config var. I am just lazy and didn't... :P |
@n1kolas Its certainly possible for some of the distance checks used by the cardinal focuser to pick the nearest window to the closed one.. Not sure if that's really useful. |
@allora Could you please also add something like |
@dialuplama I'll do this in a different PR. |
@dialuplama @allora no need for a PR, I implemented the command by myself. Thank you guys for this quality issue. |
How about to add waitron command to focus previously focused window.
The text was updated successfully, but these errors were encountered: