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

Add option to limit to outputs #42

Merged
merged 2 commits into from Nov 8, 2022
Merged

Conversation

Syphdias
Copy link
Contributor

@Syphdias Syphdias commented Nov 1, 2022

To enable different limits on different outputs, you can start two processes and limit them to the outputs you want.

Like suggested in #41.
I did not implement anything for nwg-panel to not break anything.

To enable different limits on different outputs, you can start two
processes and limit them to the outputs you want.
@nwg-piotr
Copy link
Owner

Thanks! I'll test as soon as I'm at my own desk.

@nwg-piotr
Copy link
Owner

nwg-piotr commented Nov 3, 2022

At least on sway

output = e.ipc_data.get("container", {}).get("output", "")

returns nothing. No "output" in ipc_data.

@Syphdias
Copy link
Contributor Author

Syphdias commented Nov 6, 2022

I couldn't take a look into in yet. Hm, maybe there is a more reliable way to get the focused output.

@nwg-piotr
Copy link
Owner

I used some recursion in nwg-autotiling.

@Syphdias
Copy link
Contributor Author

Syphdias commented Nov 7, 2022

It's so easy with the workspace... i3.get_tree().find_focused().workspace()

With this, I think I found another way. Iterate over outputs and check if the current workspace is active on it.

def output_name(i3):
    focused_container = i3.get_tree().find_focused()
    for output in i3.get_outputs():
        if focused_container.workspace().name == output.current_workspace:
            return output.name
    return None

I measured both approaches and scanning the parents is a lot faster than collectin information about the outputs.

Apparently there are differences in the returned ipc_data for sway and
we cannot use the ipc_data of the event that triggered the handler.
To accommodate this, we look at the currently focused container and
check its parents recursively until we find the output.
@Syphdias
Copy link
Contributor Author

Syphdias commented Nov 7, 2022

I changed how the output is being detected. Could you give it another try?

@nwg-piotr
Copy link
Owner

nwg-piotr commented Nov 8, 2022

It seems to work well. Some minor suggestions:

parser.add_argument("-o",
                        "--outputs",
                        help="restricts autotiling to certain output; "
                        "example: autotiling --output  DP-1 HDMI-0",
                        nargs="*",
                        type=str,
                        default=[], )

This only affects a single output. Shouldn't it be --output?

help='limit how often autotiling will split a container;

"How often" sounds misleading to me. Maybe just "how deep"?

@Syphdias
Copy link
Contributor Author

Syphdias commented Nov 8, 2022

This only affects a single output. Shouldn't it be --output?

No, outputs is correct. It works very similar to --workspaces. It can takes multiple values.

"How often" sounds misleading to me. Maybe just "how deep"?

I am a bit confused the patch does not contain this. I think you are referring to the --limit option.

@nwg-piotr
Copy link
Owner

I must've made a mistake, sorry.

@Syphdias
Copy link
Contributor Author

Syphdias commented Nov 8, 2022

Feel free to rephrase the help though! I was struggling with finding a good way to describe it.

@nwg-piotr
Copy link
Owner

So was I. I wouldn't be easy to a native English speaker, I bet.

@nwg-piotr nwg-piotr merged commit 2c36a6e into nwg-piotr:master Nov 8, 2022
@Syphdias Syphdias deleted the limit-output branch November 8, 2022 18:38
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.

None yet

2 participants