xmonad:设置屏幕和工作区
我无法让这个功能按我的预期工作。
setScreenAndWorkspace i =
windows (viewOnScreen screenId workspaceId)
where
screenId = ((i-1) `mod` numberOfScreens)
-- workspaceId = show i -- doesn't work for some reason
workspaceId =
case i of
1 -> "1"
2 -> "2"
3 -> "3"
4 -> "4"
5 -> "5"
6 -> "6"
7 -> "7"
8 -> "8"
9 -> "9"
我这样调用该函数:
myKeys =
[
("M-1" , setScreenAndWorkspace 1),
("M-2" , setScreenAndWorkspace 2),
("M-3" , setScreenAndWorkspace 3),
("M-4" , setScreenAndWorkspace 4),
("M-5" , setScreenAndWorkspace 5),
("M-6" , setScreenAndWorkspace 6),
("M-7" , setScreenAndWorkspace 7),
("M-8" , setScreenAndWorkspace 8),
("M-9" , setScreenAndWorkspace 9)
]
首先,显示 i 似乎没有执行与 case i 相同的操作。我一定是误解了一些基本的 Haskell 东西;如果我使用 show i 似乎 xmonad 找不到任何工作区。
第二个问题是该功能可以工作,但并不总是转移焦点。我必须按两次按键序列才能设置屏幕、设置工作区并将焦点设置在该工作区上。
I'm having trouble getting this function to work as I expect.
setScreenAndWorkspace i =
windows (viewOnScreen screenId workspaceId)
where
screenId = ((i-1) `mod` numberOfScreens)
-- workspaceId = show i -- doesn't work for some reason
workspaceId =
case i of
1 -> "1"
2 -> "2"
3 -> "3"
4 -> "4"
5 -> "5"
6 -> "6"
7 -> "7"
8 -> "8"
9 -> "9"
I'm calling the function like so:
myKeys =
[
("M-1" , setScreenAndWorkspace 1),
("M-2" , setScreenAndWorkspace 2),
("M-3" , setScreenAndWorkspace 3),
("M-4" , setScreenAndWorkspace 4),
("M-5" , setScreenAndWorkspace 5),
("M-6" , setScreenAndWorkspace 6),
("M-7" , setScreenAndWorkspace 7),
("M-8" , setScreenAndWorkspace 8),
("M-9" , setScreenAndWorkspace 9)
]
Firstly, show i doesn't seem to do the same as the case i of. I must be misunderstanding some basic Haskell thing; if I use the show i it seems that xmonad can't find any workspace.
The second problem is that the function works, but doesn't always transfer focus. I have to hit the key sequence twice to set the screen, set the workspace, AND set the focus on that workspace.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于
show i
问题,很容易在提示中看出为什么它没有按您期望的方式工作:您可以使用类似
drop 2 的内容。显示
如果您感觉特别老套,或者如果您不感觉老套。
至于为什么
viewOnScreen
不聚焦屏幕,嗯......这只是因为它不是这样设计的。从文档中:“切换到屏幕 sc 上的工作区 i。如果 i 可见,请使用视图将焦点切换到工作区 i。”。因此,只有当i
已经可见时,它才会改变焦点。为什么不直接调用两次呢?像这样的事情应该做:For the
show i
question, it's easy to see at the prompt why it's not working the way you expect:You could use something like
drop 2 . show
if you feel particularly hacky, or something likeif you're not feeling hacky.
As for why
viewOnScreen
doesn't focus the screen, well... it's just because it wasn't designed to. From the documentation: "Switch to workspace i on screen sc. If i is visible use view to switch focus to the workspace i.". So it only changes focus wheni
is already visible. Why not just call it twice? Something like this should do: