xmonad / xmonad-contrib

Contributed modules for xmonad

Home Page:https://xmonad.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NamedScratchpads somewhat broken.

exorcist365 opened this issue · comments

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)

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.

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.

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

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

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.

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

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
                    }

is that good?

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.

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.

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.

Tho it might be just my setup thats breaking.

Fixed by #730.