Skip to content
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

minimize window if already focused #41

Merged
merged 3 commits into from
Apr 7, 2019
Merged

Conversation

matklad
Copy link
Contributor

@matklad matklad commented Mar 19, 2019

closes #12

tested on plasma, seems to work

EDIT:

closes #27
based on #12

I won't use this personally but if you find it useful for others, you may grant this. If a single window is already open and in focus - minimize it instead if m flag is present.
@matklad
Copy link
Contributor Author

matklad commented Mar 19, 2019

FYI, I've packaged jumpapp for NixOS: NixOS/nixpkgs#57893

jumpapp Outdated Show resolved Hide resolved
Copy link
Owner

@mkropat mkropat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! (I'm slow to respond to these things, sorry, but I still check in from time-to-time)

I like the behavior that everyone decided on, which is to minimize if it's the only matching open window.

I haven't manually tested the change, but the new code makes sense to me.

In order to make sure this feature doesn't break as a result of future changes, can we add unit tests for the new functionality? The test file is here. I added some pointers below, but if you have any questions feel free to ask. Also if you get stuck, I can write the tests myself, but it'll probably be a few weeks before I find an opportunity to do it.

jumpapp Outdated
@@ -85,6 +87,9 @@ jumpapp() {
if [[ -n "$list" ]]; then
printf 'Matched Windows [%d]\n' ${#windowids[@]}
list_matching_windows "$classid" "${pids[@]}" | print_windows
elif [[ -n "$focusOrMinimize" ]] && [[ ${#windowids[@]} -eq "1" ]] \
&& [[ "$(get_active_windowid)" -eq "${windowids[0]}" ]]; then
xdotool getactivewindow windowminimize
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be able to unit test this, instead of directly calling:

xdotool getactivewindow windowminimize

You could declare a new function near the bottom of the file:

minimize_active_window() {
  xdotool getactivewindow windowminimize
}

Then call it from here. That would make it easy to unit test this.

@@ -10,6 +10,7 @@ Otherwise, launch COMMAND (with opitonal ARGs) to start the application.
Options:
-r -- cycle through windows in reverse order
-f -- force COMMAND to launch if process found but no windows found
-m -- if a single window is already open and in focus - minimize it
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

@matklad
Copy link
Contributor Author

matklad commented Mar 27, 2019

Added a test!

The testing setup is awesome: it was very easy to figure out how to add tests, despite the fact that I've never tested bash scripts before :)

@matklad
Copy link
Contributor Author

matklad commented Mar 27, 2019

btw, #27 (comment) suggest making -m the default behavior. This makes sense, because currently, if there's only a single window and it is active, jumpapp does nothing. But, because jumpapp is usually called from xbindkeysrc, I think requiring a flag is not a big deal here, and it helps to preserve existing behavior.

@mkropat
Copy link
Owner

mkropat commented Apr 7, 2019

Tests look good. Change looks good 👍

I thought I'd find the time to test the change but I never seem to find the free time.

I've merged it without testing it myself, but I figure on the low chance there's some issue, someone can report it.

Thanks again for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pls ass option to minimize if application is focused already on run
4 participants