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

NamedScratchpads somewhat broken. #728

Closed
3 tasks done
exorcist365 opened this issue Jun 28, 2022 · 14 comments · Fixed by #730
Closed
3 tasks done

NamedScratchpads somewhat broken. #728

exorcist365 opened this issue Jun 28, 2022 · 14 comments · Fixed by #730

Comments

@exorcist365
Copy link
Contributor

Problem Description

After commit 3fc830a my scratchpads suddenly stopped working after I restarted the window manager, it does however fix itself after opening a new window but having to do that after every time I restart the wm and want to bring my scratchpad is kinda... annoying, don't you think?

Steps to Reproduce

Run a version of xmonad-contrib pushed after the 1st of April, restart the window manager and then press your scratchpad keybind.

Configuration File

Quite difficult to post here since my setup is split into multiple files, so you better take a look at my dotfiles

Checklist

  • I've read CONTRIBUTING.md

  • I tested my configuration

    • With xmonad version 0.17 (commit master)
    • With xmonad-contrib version 0.17 (commit master and the one mentioned above)
@geekosaur
Copy link
Contributor

Are you using NamedScratchpad or standard Scratchpad? I suspected the new scratchpad implementation would break the latter, and I'm surprised it's taken this long for a report to come in.

@geekosaur
Copy link
Contributor

Sorry, I missed the title. I've been using several NamedScratchpads without issue since that commit, so I'm not sure what could be wrong.

@slotThe
Copy link
Member

slotThe commented Jun 29, 2022

Configuration File

Quite difficult to post here since my setup is split into multiple files, so you better take a look at my dotfiles

Could you perhaps try to produce a (minimal) example with which you can reproduce this? Much like @geekosaur, I've been using scratchpads extensively since this commit and I've never noticed this

@exorcist365
Copy link
Contributor Author

ok, so:

fmSP, ghciSP, ocamlSP, musicSP, terminalSP :: String
fmSP = "FFF"
ghciSP = "GHCI"
ocamlSP = "OCaml"
musicSP = "Music"
terminalSP = "Terminal"

scratchpads :: [NamedScratchpad]
scratchpads = [ NS { name = ghciSP
                   , query = isGHCI
                   , cmd = spawnGHCI
                   , hook = centerFloat
                   }
              , NS { name = ocamlSP
                   , query = isOcaml
                   , cmd = spawnOcaml
                   , hook = centerFloat
                   }
              , NS { name = musicSP
                   , query = isMusic
                   , cmd = spawnMusic
                   , hook = centerFloat
                   }
              , NS { hook = topFloat
                   , name = terminalSP
                   , query = isTerminal
                   , cmd = spawnTerminal
                   }
              , NS { name = fmSP
                   , query = isFM
                   , cmd = spawnFM
                   , hook = centerFloat
                   }
              ] where
                  spawnFM, spawnGHCI, spawnOcaml, spawnMusic, spawnTerminal :: String
                  spawnFM = unwords [term, "-c", fmSP, "-e", files]
                  spawnGHCI = unwords [term, "-c", ghciSP, "-e", "stack exec -- ghci", "-v0", "-ghci-script", configHome </> "ghci/ghci.conf"]
                  spawnOcaml = unwords [term, "-c", ocamlSP, "-e", "myutop"]
                  spawnMusic = unwords [term, "-c", musicSP, "-e", music]
                  spawnTerminal = unwords [term, "-c", terminalSP]

                  isFM, isGHCI, isOcaml, isMusic, isTerminal :: Query Bool
                  isFM = className =? fmSP
                  isGHCI = className =? ghciSP
                  isOcaml = className =? ocamlSP
                  isMusic = className =? musicSP
                  isTerminal = className =? terminalSP

                  topFloat, centerFloat :: ManageHook
                  topFloat = customFloating $ RationalRect 0 0 1 0.45
                  centerFloat = customFloating $ RationalRect (1/6) (1/6) (2/3) (2/3)

thats the scratchpad part and the calling i do with the function namedScratchpadAction

@geekosaur
Copy link
Contributor

This isn't quite enough information. You might want to compare to how I use them in my config; note in particular lines 56–74 (definition), 122 (manageHook), 155–158 (keybindings). It does sound like you might be missing the manageHook, although in that case I'd expect it not to work at all.

@exorcist365
Copy link
Contributor Author

exorcist365 commented Jun 29, 2022

windowManager = mconcat [ tileBelow
                        , transience'
                        , manageSpawn
                        , manageHook def
                        , isRole =? "About" --> doCenterFloat
                        , namedScratchpadManageHook scratchpads
                        , isRole =? "pop-up" --> forceCenterFloat
                        , className =? "Sxiv" --> hasBorder False
                        , className =? "Picker" --> doCenterFloat
                        , isName =? "Library" --> forceCenterFloat
                        , className =? "Places" --> forceCenterFloat
                        , className =? "New VM" --> forceCenterFloat
                        , className =? "Ripcord" --> shiftFocus (at 5)
                        , className =? "discord" --> shiftFocus (at 5)
                        , className =? "Filezilla" --> shiftFocus (at 6)
                        , className =? "qutebrowser" --> shiftFocus (at 2)
                        , className =? "Signal Beta" --> shiftFocus (at 5)
                        , isDialog --> mconcat [doF siftUp, doCenterFloat]
                        , isName =? "Picture-in-Picture" --> forceCenterFloat
                        , className =? "TelegramDesktop" --> shiftFocus (at 5)
                        , className =? "mpv" --> mconcat [doF siftUp, unFloat]
                        , isRole =? "GtkFileChooserDialog" --> forceCenterFloat
                        , className =? "st-float" --> mconcat [doFocus, doFloat]
                        , className =? "Ripcord" <&&> isName =? "Preferences" --> forceCenterFloat
                        , className =? "help" --> mconcat [forceCenterFloat, doF siftUp, hasBorder False]
                        , isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_SPLASH" --> doCenterFloat
                        ]

this is my managehook

@slotThe
Copy link
Member

slotThe commented Jun 29, 2022 via email

@exorcist365
Copy link
Contributor Author

import XMonad
import XMonad.Util.NamedScratchpad

musicSP :: String
musicSP = "Music"

music :: String
music = "ncmpcpp"

term :: String
term = "st"

scratchpads :: [NamedScratchpad]
scratchpads = [ NS { name = musicSP
                   , query = isMusic
                   , cmd = spawnMusic
                   , hook = centerFloat
                   }
              ] where
                  spawnMusic :: String
                  spawnMusic = unwords [term, "-c", musicSP, "-e", music]
                  isMusic:: Query Bool
                  isMusic = className =? musicSP
                  centerFloat :: ManageHook
                  centerFloat = customFloating $ RationalRect (1/6) (1/6) (2/3) (2/3)

keymap :: XConfig l -> Map (KeyMask, KeySym) (X ())
keymap _ = fromList [ ((mod4Mask, xK_w), withFocused killWindow)
                    , ((mod4Mask, xK_m), namedScratchpadAction scratchpads musicSP)
                    ]

managehook :: ManageHook
managehook = composeAll [ manageHook def
                        , namedScratchpadManageHook scratchpads
                        ]

main :: IO ()
main = xmonad $ def { manageHook = managehook
                    , keys = keymap
                    }

@exorcist365
Copy link
Contributor Author

is that good?

@slotThe
Copy link
Member

slotThe commented Jun 29, 2022

Yes, thank you!

Since the scratchpads are now added in namedScratchpadManageHook, we need some kind of MapRequestEvent to happen before processing scratchpads, otherwise our extensible state is being left empty. That would explain why it works after opening a window. I thought I tested this and got some MapRequestEvents by just opening up xmonad, which I assumed were the root windows, but then again this wouldn't cause the manageHook to fire... I suppose the (awkward, but easy) fix would be to check that condition again in someNamedScratchpadAction and fill the state in case it's empty.

@geekosaur
Copy link
Contributor

geekosaur commented Jun 29, 2022

The root window (singular) is always mapped and behaves as if it were OverrideRedirect. You may have had some other windows waiting to be mapped.

@exorcist365
Copy link
Contributor Author

Are you using NamedScratchpad or standard Scratchpad? I suspected the new scratchpad implementation would break the latter, and I'm surprised it's taken this long for a report to come in.

Yeah I was expecting that someone would have reported it already too.

@exorcist365
Copy link
Contributor Author

exorcist365 commented Jun 29, 2022

Tho it might be just my setup thats breaking.

slotThe added a commit to slotThe/xmonad-contrib that referenced this issue Jun 29, 2022
Since 3fc830a, scratchpads are now
added in namedScratchpadManageHook.  This, however, means that we need
some kind of MapRequestEvent to happen before processing scratchpads,
otherwise the manageHook didn't run yet and our extensible state is
being left empty.  When trying to open a scratchpad right after starting
xmonad—i.e., before having opened a window—this may not be the case.

Fixes: xmonad#728
slotThe added a commit to slotThe/xmonad-contrib that referenced this issue Jun 29, 2022
Since 3fc830a, scratchpads are now
added in namedScratchpadManageHook.  This, however, means that we need
some kind of MapRequestEvent to happen before processing scratchpads,
otherwise the manageHook didn't run yet and our extensible state is
being left empty.  When trying to open a scratchpad right after starting
xmonad—i.e., before having opened a window—this may not be the case.

Fixes: xmonad#728
@exorcist365
Copy link
Contributor Author

Fixed by #730.

slotThe added a commit to slotThe/xmonad-contrib that referenced this issue Jul 2, 2022
Since 3fc830a, scratchpads are now
added in namedScratchpadManageHook.  This, however, means that we need
some kind of MapRequestEvent to happen before processing scratchpads,
otherwise the manageHook didn't run yet and our extensible state is
being left empty.  When trying to open a scratchpad right after starting
xmonad—i.e., before having opened a window—this may not be the case.

Fixes: xmonad#728
slotThe added a commit to slotThe/xmonad-contrib that referenced this issue Jul 3, 2022
Since 3fc830a, scratchpads are now
added in namedScratchpadManageHook.  This, however, means that we need
some kind of MapRequestEvent to happen before processing scratchpads,
otherwise the manageHook didn't run yet and our extensible state is
being left empty.  When trying to open a scratchpad right after starting
xmonad—i.e., before having opened a window—this may not be the case.

Fixes: xmonad#728
slotThe added a commit to slotThe/xmonad-contrib that referenced this issue Jul 3, 2022
Since 3fc830a, scratchpads are now
added in namedScratchpadManageHook.  This, however, means that we need
some kind of MapRequestEvent to happen before processing scratchpads,
otherwise the manageHook didn't run yet and our extensible state is
being left empty.  When trying to open a scratchpad right after starting
xmonad—i.e., before having opened a window—this may not be the case.

Fixes: xmonad#728
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 a pull request may close this issue.

3 participants