AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1653651

Raymond's questions

Martin Hope
Raymond
Asked: 2022-08-19 08:18:45 +0800 CST

将窗口移动到工作区并将该工作区(shiftAndView)聚焦在 XMonad WM 上

  • 5

我有 XMonad 有一段时间了,过去几天我一直在研究这个问题,但仍然没有解决方案。

让我给你一个我正在尝试做的例子:VLC 是打开的,在它仍然集中的时候将它移动到工作区 2,所以我不必走很长的路,首先将 VLC 移动到工作区 2,然后切换到那个工作区。

我搜索了很多论坛和网站,人们提供了很好的答案,但我的情况有所不同:

我将namedActions用于我的键绑定,而这些答案对我不起作用。

我不确定它是否会有所帮助,但这是我的配置文件: https ://pastebin.com/UuWt9qji

import XMonad
import Data.Char
import Data.Monoid
import System.Exit
import System.IO
import XMonad.Layout.Tabbed
import XMonad.Layout.Spacing
import XMonad.Layout.NoBorders
import XMonad.Layout.Fullscreen
import XMonad.Layout.Spiral
import XMonad.Layout.ResizableTile
import XMonad.Layout.Renamed
import XMonad.Layout.BinarySpacePartition
import XMonad.Layout.ToggleLayouts
import XMonad.Layout.Reflect
import XMonad.Layout.SubLayouts
import XMonad.Layout.WindowNavigation
import XMonad.Layout.Simplest
import XMonad.Util.Run
import XMonad.Util.SpawnOnce
import XMonad.Util.NamedScratchpad
import XMonad.Util.NamedActions
import XMonad.Util.EZConfig
import XMonad.ManageHook
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
import XMonad.Actions.CycleWS
import XMonad.Util.WorkspaceCompare

-----------------------------------------------------------------------------------
myModMask       = mod4Mask
myTerminal      = "alacritty"
myBrowser       = "qutebrowser"
myBorderWidth   = 2

myLauncher      = "rofi -show drun"
myStatusBar     = "xmobar .config/xmobar/xmobarrc"
myFont          = "xft:Hack Nerd Font:regular:size=12:antialias=true:hinting=true"

myNormalColor   = "#4e5173"
myFocusColor    = "#46d9ff"

myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True

myClickJustFocuses :: Bool
myClickJustFocuses = False

-----------------------------------------------------------------------------------
myScratchPads :: [NamedScratchpad]
myScratchPads  = [ NS "terminal" spawnTerm findTerm manageTerm
                 , NS "htop"     spawnHtop findHtop manageHtop
                 ]
  where
    spawnTerm  = myTerminal ++ " -t scratchpad"
    findTerm   = title =?      "scratchpad"
    manageTerm = customFloating $ W.RationalRect l t w h
              where
                h  = 0.9
                w  = 0.9
                t  = 0.95 -h
                l  = 0.95 -w
    spawnHtop  = myTerminal ++ " -t htop -e htop"
    findHtop   = title =?      "htop"
    manageHtop = customFloating $ W.RationalRect l t w h
               where
                h  = 0.9
                w  = 0.9
                t  = 0.95 -h
                l  = 0.95 -w

-----------------------------------------------------------------------------------
wsDo   = "AV"
wsBo   = "BSA"
wsCo   = "COM"
wsMo   = "DOM"
wsGo   = "DMO"
wsFo   = "FLT"

-- myWorkspaces = map show [1..9]
myWorkspaces = [wsDo, wsBo, wsCo, wsGo, wsMo, wsFo]

-----------------------------------------------------------------------------------
showKeybindings :: [((KeyMask, KeySym), NamedAction)] -> NamedAction
showKeybindings x = addName "Show Keybindings" $ io $ do
  h <- spawnPipe $ "yad --text-info --fontname=\"SauceCodePro Nerd Font Mono 12\" --fore=#46d9ff --back=#282c36 --center --geometry=1200x800 --title \"XMonad keybindings\""
  hPutStr h (unlines $ showKm x)
  hClose h
  return ()

wsKeys = map show $ [1..9] ++ [0]
notSP = (return $ ("SP" /=) . W.tag) :: X (WindowSpace -> Bool)
shiftAndView dir = findWorkspace getSortByIndex dir (WSIs notSP) 1
  >>= \t -> (windows . W.shift $ t) >> (windows . W.greedyView $ t)

myKeys confkey =let subKeys str ks = subtitle str : mkNamedKeymap confkey ks in

  subKeys "System"
  [ ("M-t"    , addName "Push window back into tiling"  $ withFocused $ windows . W.sink)
  , ("M-S-q"  , addName "Quit xmonad"                   $ io (exitWith ExitSuccess))
  , ("M-q"    , addName "Rebuild & restart XMonad"      $ spawn "xmonad --recompile; xmonad --restart")]

  ^++^ subKeys "Launchers"
  [ ("M-S-<Return>"  , addName "Launch Terminal"  $ spawn myTerminal)
  , ("M-p"           , addName "Launch Rofi"      $ spawn myLauncher)
  , ("M-b"           , addName "Launch Browser"   $ spawn myBrowser)]

  ^++^ subKeys "Layout Management"
  [ ("M-<Space>"    , addName "Switch to next layout"            $ sendMessage NextLayout)
  , ("M-S-<Space>"  , addName "Reset layouts"                    $ setLayout $ XMonad.layoutHook confkey)
  , ("M-f"          , addName "Toggle to Fullscreen"             $ sendMessage (Toggle "Full"))
  , ("M-S-b"        , addName "Toggle Struts"                    $ sendMessage ToggleStruts)
  ]

  ^++^ subKeys "Workspaces"
  [ ("M-1", addName "Switch to workspace 1"    $ (windows $ W.greedyView $ myWorkspaces !! 0))
  , ("M-2", addName "Switch to workspace 2"    $ (windows $ W.greedyView $ myWorkspaces !! 1))
  , ("M-3", addName "Switch to workspace 3"    $ (windows $ W.greedyView $ myWorkspaces !! 2))
  , ("M-4", addName "Switch to workspace 4"    $ (windows $ W.greedyView $ myWorkspaces !! 3))
  , ("M-5", addName "Switch to workspace 5"    $ (windows $ W.greedyView $ myWorkspaces !! 4))
  , ("M-6", addName "Switch to workspace 6"    $ (windows $ W.greedyView $ myWorkspaces !! 5))
  , ("M-S-1", addName "Send to workspace 1"    $ (windows $ W.shift $ myWorkspaces !! 0))
  , ("M-S-2", addName "Send to workspace 2"    $ (windows $ W.shift $ myWorkspaces !! 1))
  , ("M-S-3", addName "Send to workspace 3"    $ (windows $ W.shift $ myWorkspaces !! 2))
  , ("M-S-4", addName "Send to workspace 4"    $ (windows $ W.shift $ myWorkspaces !! 3))
  , ("M-S-5", addName "Send to workspace 5"    $ (windows $ W.shift $ myWorkspaces !! 4))
  , ("M-S-6", addName "Send to workspace 6"    $ (windows $ W.shift $ myWorkspaces !! 5))]
  
  ^++^ subKeys "Window Management"
  [ ("M-<Tab>"     , addName "Move focus to the next window"        $ windows W.focusDown)
  , ("M-j"         , addName "Move focus to the next window"        $ windows W.focusDown)
  , ("M-k"         , addName "Move focus to the previous window"    $ windows W.focusUp)
  , ("M-m"         , addName "Move focus to the master window"      $ windows W.focusMaster)
  , ("M-<Return>"  , addName "Swap focused to the master window"    $ windows W.swapMaster)
  , ("M-S-j"       , addName "Swap focused to the next window"      $ windows W.swapDown)
  , ("M-S-k"       , addName "Swap focused to the previous window"  $ windows W.swapUp)
  , ("M-t"         , addName "Push window back into tiling"         $ withFocused $ windows . W.sink)
  , ("M-,"         , addName "Increase windows in master area"      $ sendMessage (IncMasterN 1))
  , ("M-."         , addName "Decrease windows in master area"      $ sendMessage (IncMasterN (-1)))
  , ("M-c"         , addName "Close focused window"                 $ kill)]

  ^++^ subKeys "Scratchpads"
  [ ("M-s t"  , addName "Toggle scratchpad terminal"  $ namedScratchpadAction myScratchPads "terminal")
  , ("M-s h"  , addName "Toggle scratchpad htop"      $ namedScratchpadAction myScratchPads "htop")]

  ^++^ subKeys "Sublayouts"
  [ ("M-C-h",  addName "pullGroup Left"        $ sendMessage $ pullGroup L)
  , ("M-C-l",  addName "pullGroup Right"       $ sendMessage $ pullGroup R)
  , ("M-C-k",  addName "pullGroup Up"          $ sendMessage $ pullGroup U)
  , ("M-C-j",  addName "pullGroup Down"        $ sendMessage $ pullGroup D)
  , ("M-C-m",  addName "MergeAll"              $ withFocused (sendMessage . MergeAll))
  , ("M-C-u",  addName "UnMerge"               $ withFocused (sendMessage . UnMerge))
  , ("M-C-/", addName "UnMergeAll"             $  withFocused (sendMessage . UnMergeAll))
  , ("M-C-.", addName "Switch focus next tab"  $  onGroup W.focusUp')
  , ("M-C-,", addName "Switch focus prev tab"  $  onGroup W.focusDown')]

  ^++^ subKeys "Window resizing"
  [ ("M-h"  , addName "Shrink the master area"  $ sendMessage Shrink)
  , ("M-l"  , addName "Expand the master area"  $ sendMessage Expand)]

  ^++^ subKeys "Window spacing"
  [ ("C-M1-j",  addName "Decrease window spacing"  $ decWindowSpacing 5)
  , ("C-M1-k",  addName "Increase window spacing"  $ incWindowSpacing 5)]

-----Workspaces

-----------------------------------------------------------------------------------
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $

    [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
                                       >> windows W.shiftMaster))

    , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))

    , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
                                       >> windows W.shiftMaster)) ]

-----------------------------------------------------------------------------------
myTabConfig = def { fontName            = myFont
                  , activeColor         = "#46d9ff"
                  , inactiveColor       = "#202328"
                  , activeBorderColor   = "#46d9ff"
                  , inactiveBorderColor = "#282c34"
                  , activeTextColor     = "#282c34"
                  , inactiveTextColor   = "#dfdfdf" }

tall         = renamed [Replace "tall"]
             $ windowNavigation
             $ addTabs shrinkText myTabConfig
             $ subLayout [] Simplest
             $ smartSpacing 5
             $ ResizableTall 1 (3/100) (1/2) []

binary       = renamed [Replace "binary"]
             $ reflectHoriz
             $ reflectVert
             $ smartSpacing 5
             $ emptyBSP

spirals      = renamed [Replace "spirals"]
             $ smartSpacing 5
             $ spiral (6/7)

myLayoutHook = avoidStruts
             $ smartBorders
             $ toggleLayouts Full
             $ myLayouts
  where
   myLayouts = tall
           ||| binary
           ||| spirals

-----------------------------------------------------------------------------------
myManageHook = composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat
    , className =? "confirm"        --> doFloat
    , className =? "file_progress"  --> doFloat
    , className =? "dialog"         --> doFloat
    , className =? "download"       --> doFloat
    , className =? "error"          --> doFloat
    , className =? "notification"   --> doFloat
    , className =? "Yad"            --> doCenterFloat
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "kdesktop"       --> doIgnore
    , isFullscreen --> doFullFloat
    ] <+> namedScratchpadManageHook myScratchPads

-----------------------------------------------------------------------------------
myEventHook = mempty

-----------------------------------------------------------------------------------
myLogHook = return ()


-----------------------------------------------------------------------------------
myStartupHook :: X ()
myStartupHook = do
    spawnOnce "xsetroot -cursor_name left_ptr"
    spawnOnce "nitrogen --restore &"
    spawnOnce "picom -f"

-----------------------------------------------------------------------------------
main :: IO ()
main = do
    xmproc <- spawnPipe myStatusBar
    xmonad 
        $ addDescrKeys' ((mod4Mask, xK_F1), showKeybindings) myKeys 
        $ docks defaults

defaults = def 
     {
        terminal           = myTerminal,
        focusFollowsMouse  = myFocusFollowsMouse,
        clickJustFocuses   = myClickJustFocuses,
        borderWidth        = myBorderWidth,
        modMask            = myModMask,
        workspaces         = myWorkspaces,
        normalBorderColor  = myNormalColor,
        focusedBorderColor = myFocusColor,
        mouseBindings      = myMouseBindings,
        layoutHook         = myLayoutHook,
        manageHook         = myManageHook,
        handleEventHook    = myEventHook,
        logHook            = myLogHook,
        startupHook        = myStartupHook
    }
linux window-manager
  • 1 个回答
  • 37 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve