-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Is there a way to merge a newly spawned window into a sublayout/group? Preferably if already focued on the group. #372
Comments
So, to update this issue, the OP of that reddit thread came up with something that almost works: I was wondering if there was a hook module that would help run this. Like there is this module: I'm hoping that running this with a hook solves the issue of the mergeDir occurring before the new window spawns (since obviously we want it to happen afterwards). |
The spawn is run in the background, so it will run at an indeterminate time
relative to anything else.
The closest you will get to what you want is to add a flag to
ExtensibleState and check the flag in the manageHook and run your code
there with liftX.
…On Sat, Sep 5, 2020, 13:15 copper4eva ***@***.***> wrote:
So, to update this issue, the OP of that reddit thread came up with
something that almost works:
, ("M-<Return>", spawn (terminal c) >> withFocused (sendMessage . mergeDir
W.focusUp'))
The issue with this is, for whatever reason, the mergeDir gets run then
the new terminal window spawns. Very strange to me that it works like that.
I was wondering if there was a hook module that would help run this. Like
there is this module:
https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Hooks-InsertPosition.html
for controlling what position a new window starts in. Is there not a
module that can run the mergeDir command for every new window? Maybe this
module:
https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Hooks-ManageHelpers.html
I'm hoping that running this with a hook solves the issue of the mergeDir
occurring before the new window spawns (since obviously we want it to
happen afterwards).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#372 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPRFIAV7DTCVTTCBB5IPFDSEJWZHANCNFSM4QNTCIIA>
.
|
Can you elaborate on this at all? Sorry for extremely late reply, I've been busy with other stuff. But I'm motivated to attempt getting XMonad to automatically tab newly spawned windows together. I don't know how to use liftX. I tried using it in my managehook first and failed. Here's a reddit post I made about it: |
Take a look at `XMonad.Actions.SpawnOn`. In fact the `spawnAndDo` function
in there might already be useful to you.
…On Thu, Oct 15, 2020 at 11:05 PM copper4eva ***@***.***> wrote:
The spawn is run in the background, so it will run at an indeterminate
time relative to anything else. The closest you will get to what you want
is to add a flag to ExtensibleState and check the flag in the manageHook
and run your code there with liftX.
Can you elaborate on this at all? Sorry for extremely late reply, I've
been busy with other stuff. But I'm motivated to attempt getting XMonad to
automatically tab newly spawned windows together.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#372 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPRFICINPFQD3P5VTI6WITSK6Z6LANCNFSM4QNTCIIA>
.
--
brandon s allbery kf8nh
[email protected]
|
`spawnAndDo` takes a `manageHook`, not an action. `liftX` permits an action
to be run in a `manageHook`. So you don't want `liftX` in the commented-out
ones, but need it in the `spawnAndDo`.
As for the `doFloat`, you want to remove it and the preceding `>>`.
(I'm having trouble responding to these on github, all I get is a file
dialog instead of text entry.)
…On Fri, Oct 16, 2020 at 3:25 PM copper4eva ***@***.***> wrote:
Take a look at XMonad.Actions.SpawnOn. In fact the spawnAndDo function in
there might already be useful to you.
<#m_5952601485855953100_>
myManageHook = composeAll
[ resource =? "lxqt" --> doIgnore
--, className =? "XTerm" --> doFloat
--, className =? "XTerm" --> (liftX (withFocused (sendMessage . mergeDir W.focusUp')) >> doFloat)
--, className =? "XTerm" --> (withFocused (sendMessage . mergeDir W.focusUp'))
, spawnAndDo (withFocused (sendMessage . mergeDir W.focusUp')) "XTerm"
, resource =? "lxqt-panel" --> doIgnore ]
So I tried different things and this is what I've gotten. If I uncomment
the one with liftX, that actually compiles and "works". I'm not entirely
sure with liftX is supposed to do lol, but I don't think it's what I want.
I do not want the "doFloat" to run, and that is of course what ultimately
happens to xterm. I only put the doFloat in there while trying to get liftX
to do anything without running an error. I think if I replaced doFloat with
something that does nothing (say for example if there was literally a
doNothing command) then I think that line might work correctly.
spawnAndDo sounds more like what I want. But right now I get an error when
trying to use it:
xmonad.hs:157:7: error:
* Couldn't match expected type `Query (Endo WindowSet)'
with actual type `X ()'
* In the expression:
spawnAndDo
(withFocused (sendMessage . mergeDir W.focusUp')) "XTerm"
In the first argument of `composeAll', namely
`[resource =? "lxqt" --> doIgnore,
spawnAndDo
(withFocused (sendMessage . mergeDir W.focusUp')) "XTerm",
resource =? "lxqt-panel" --> doIgnore]'
In the expression:
composeAll
[resource =? "lxqt" --> doIgnore,
spawnAndDo
(withFocused (sendMessage . mergeDir W.focusUp')) "XTerm",
resource =? "lxqt-panel" --> doIgnore]
|157 | , spawnAndDo (withFocused (sendMessage . mergeDir W.focusUp')) "XTerm"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:157:19: error:
* Couldn't match type `X ()' with `Query (Endo WindowSet)'
Expected type: ManageHook
Actual type: X ()
* In the first argument of `spawnAndDo', namely
`(withFocused (sendMessage . mergeDir W.focusUp'))'
In the expression:
spawnAndDo
(withFocused (sendMessage . mergeDir W.focusUp')) "XTerm"
In the first argument of `composeAll', namely
`[resource =? "lxqt" --> doIgnore,
spawnAndDo
(withFocused (sendMessage . mergeDir W.focusUp')) "XTerm",
resource =? "lxqt-panel" --> doIgnore]'
|157 | , spawnAndDo (withFocused (sendMessage . mergeDir W.focusUp')) "XTerm"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#372 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPRFIBP2ZAZ5UU6G6BKP7LSLCMY3ANCNFSM4QNTCIIA>
.
--
brandon s allbery kf8nh
[email protected]
|
, spawnAndDo (liftX (withFocused (sendMessage . mergeDir W.focusUp')) ) "XTerm" Alright, I tried this. Which I believe is basically what you asked me to put together. Unfortunately still gives the same kind of error: xmonad.hs:158:7: error:
* Couldn't match expected type `Query (Endo WindowSet)'
with actual type `X ()'
* In the expression:
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm"
In the first argument of `composeAll', namely
`[resource =? "lxqt" --> doIgnore,
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm",
resource =? "lxqt-panel" --> doIgnore]'
In the expression:
composeAll
[resource =? "lxqt" --> doIgnore,
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm",
resource =? "lxqt-panel" --> doIgnore]
|
158 | , spawnAndDo (liftX (withFocused (sendMessage . mergeDir W.focusUp')) ) "XTerm"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:158:19: error:
* Couldn't match type `()' with `Endo WindowSet'
Expected type: ManageHook
Actual type: Query ()
* In the first argument of `spawnAndDo', namely
`(liftX (withFocused (sendMessage . mergeDir W.focusUp')))'
In the expression:
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm"
In the first argument of `composeAll', namely
`[resource =? "lxqt" --> doIgnore,
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm",
resource =? "lxqt-panel" --> doIgnore]'
|
158 | , spawnAndDo (liftX (withFocused (sendMessage . mergeDir W.focusUp')) ) "XTerm"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Oh, I see, you're doing this in the wrong place. `spawnAndDo` replaces the
spawn action via keybinding or whatever. If you want to capture any window
in the `manageHook`, you just want the inside of the `spawnAndDo`. But I'm
unclear as to what exactly you're trying to accomplish at this point.
…On Fri, Oct 16, 2020 at 3:44 PM copper4eva ***@***.***> wrote:
spawnAndDo takes a manageHook, not an action. liftX permits an action to
be run in a manageHook. So you don't want liftX in the commented-out
ones, but need it in the spawnAndDo. As for the doFloat, you want to
remove it and the preceding >>. (I'm having trouble responding to these
on github, all I get is a file dialog instead of text entry.)
, spawnAndDo (liftX (withFocused (sendMessage . mergeDir W.focusUp')) ) "XTerm"
Alright, I tried this. Which I believe is basically what you asked me to
put together. Unfortunately still gives the same kind of error:
xmonad.hs:158:7: error:
* Couldn't match expected type `Query (Endo WindowSet)'
with actual type `X ()'
* In the expression:
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm"
In the first argument of `composeAll', namely
`[resource =? "lxqt" --> doIgnore,
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm",
resource =? "lxqt-panel" --> doIgnore]'
In the expression:
composeAll
[resource =? "lxqt" --> doIgnore,
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm",
resource =? "lxqt-panel" --> doIgnore]
|158 | , spawnAndDo (liftX (withFocused (sendMessage . mergeDir W.focusUp')) ) "XTerm"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
xmonad.hs:158:19: error:
* Couldn't match type `()' with `Endo WindowSet'
Expected type: ManageHook
Actual type: Query ()
* In the first argument of `spawnAndDo', namely
`(liftX (withFocused (sendMessage . mergeDir W.focusUp')))'
In the expression:
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm"
In the first argument of `composeAll', namely
`[resource =? "lxqt" --> doIgnore,
spawnAndDo
(liftX (withFocused (sendMessage . mergeDir W.focusUp'))) "XTerm",
resource =? "lxqt-panel" --> doIgnore]'
|158 | , spawnAndDo (liftX (withFocused (sendMessage . mergeDir W.focusUp')) ) "XTerm"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#372 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPRFID4SPW6OYKWKB2OOXLSLCPBFANCNFSM4QNTCIIA>
.
--
brandon s allbery kf8nh
[email protected]
|
@copper4eva any updates; did you figure this out? |
The same problem with manageHooks being run before managing the window was recently encountered in the context of window swallowing: #416 (comment) and a solution that works is to have a handleEventHook that replaces xmonad core handling of the event, calls So what I think we can quite easily do is to add a generic afterManageHook for this. It's totally doable in -contrib, too, just extract https://github.com/xmonad/xmonad/blob/e08ddc9f04c1bd23a5126ef400e9a5b2d6a32541/src/XMonad/Main.hs#L310-L314 into a handleEventHook that invoked the hook afterwards and then returns |
I switched to bspwm. So no, I did not. But it looks like from liskin's comment that XMonad has added a feature that would help with his.
IIRC the only issue with this was the order of the spawn terminal and mergeDir were random. Obviously you want the terminal to spawn, then to run the merge command. It sounds like from liskin's comment that there's a new function or something that can help control this order of events. Which was implemented for the sake of swallowing, which would make sense. I could see how window swallowing would run into the same issue. Random rant below, don't have to read it: I don't have a great understanding of Haskell at all, and now that I've switched off of xmonad I likely never will. But dealing with this issue was quite frustrating. You wouldn't think that something as trivial as the order in which two commands decide to run would be such a problem. This would never be a problem in bspwm. With xmonad, whenever I wanted to do something really out of the box, and there wasn't a convenient contrib for it, it was very difficult to get things done. And sometimes would require more hacky methods, rather than more fundamentally foolproof methods. With bspwm I have never felt limited like this. They just kind of did an amazing job of just giving you the tools you need to do whatever you want in bspwm. Sorry if that last paragraph comes off as overly negative. It was an attempt at being critically constructive. Again, I don't understand haskell very well, so this is probably more of a me issue. I just feel like something like merging subtabs automatically shouldn't have been such a freaking ordeal. With bspwm, you can subscribe to any event that happens in the window manager. And you can easily control the order at which commands are ran. So for this problem, you would just subscribe to a node being added, then you can do whatever you want to it very easily. bspwm does not have groupings or subtabs though. But you could still do this with the suckless program tabbed. Maybe one day bspwm will add the ability for monocle layout as a child node. |
Hi, I've also ran into this, but I have no intention moving away from XMonad. here's the shortcut which does not compile currently: compiler tells me this error:
Could you help me with it? |
Try appending
But this too has a problem: xmonad won't have focused the window until after this runs. And |
Thanks for the quick reply! :) My fellow XMonader friend said that this could be solved with tracking the last focused window/group in a state, and use that state here to be able to determine which group should be the newly spawned window be merged to. Although I don't really know how could I accomplish this. Do you have any suggestion for this? |
Well. I know what they're talking about, but I don't know |
Thanks, will look into it! |
Problem Description
Someone made a reddit post asking something very similar 11 days ago, with no responses (except me and himself):
https://www.reddit.com/r/xmonad/comments/ib0mx7/merge_spawned_window_into_sublayout/
He specifically wanted to make a keybinding that basically does this behavior for his terminal using subtabbed.
Personally, I would want it where if you're already focused on a group of tabs, then any newly spawned windows (whether it be terminals or whatever) would immediately get added to the tabbed group.
Is there any way currently to do either of these ideas?
Configuration File
Here's the parts of my config file that are related to my subtabbed layout, both the keybindings (that are related) and layout hook:
The text was updated successfully, but these errors were encountered: