Xmonad: Combine dwm-style workspaces per physical screen with cycling function - haskell

my question should be a piece of cake for anyone a bit learned in Haskell:
I would like to use the dwm-like multihead-setup: each physical screen gets it's own set of workspaces. No automatic swapping of windows or focus or whatsoever.
This is provided by the extension XMonad.Layout.IndependentScreens (http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-IndependentScreens.html) which works fine.
But I would equally like to use the cycling function provided by XMonad.Actions.CycleWS (http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Actions-CycleWS.html) which works equally fine (by itself).
As it is, when I cycle through the workspaces, it goes: Screen1 WS1 <--> Screen2 WS1 <--> Screen1 WS2 <--> Screen2 WS2 etc.
The cycling function would have to be wrapped in a independent-layout-function i guess. As I said, this is probably extremely simple, but I know little of Haskell and couldn't figure it out.
Both of the extensions are well documented, so this should be a simple one for some of you guys.
Thanks for helping!

I guess the main trick is to build a WSType which informs CycleWS that you're only interested in physical workspaces that appear on the same screen as the current physical workspace. Here's how you would do that.
isOnScreen :: ScreenId -> WindowSpace -> Bool
isOnScreen s ws = s == unmarshallS (tag ws)
currentScreen :: X ScreenId
currentScreen = gets (screen . current . windowset)
spacesOnCurrentScreen :: WSType
spacesOnCurrentScreen = WSIs (isOnScreen <$> currentScreen)
Then you can use spacesOnCurrentScreen in keybindings something like this:
, ((modM, xK_whatever ), moveTo Next spacesOnCurrentScreen)
, ((modM, xK_whatever2), shiftTo Next spacesOnCurrentScreen)
I haven't tested it, but it typechecks at least. ;-)

Related

Xmonad: key binding to bring a window from a another workspace to your current workspace

I am hoping that you folks can help me as I am new to Haskell and Haskell-fu is rather weak.
I am trying to create a quake-like terminal that drops down when called upon. For the most part I figured that storing a named urxvt terminal in layout managed by a simpleDrawer (XMonad.Layout.Drawer) works well for this. What I am having a problem with is binding a key to it so that it will pop up on whatever workspace I happen to be in.
The bringSelected option doesn't work for me as I do not want to have to deal with the grid menu. What I have tried that has gotten me the closest is:
raiseMaybe (spawnHere "urxvt -name drawer") (resource =? "drawer")
And:
ifWindows (resource =? "drawer") (mapM_ focus) (spawn "urxvt -name drawer")
The problem is that both essentially do the same thing in that instead of bringing said window (with resource =? "drawer") to my current workspace, it shifts me away from my current workspace to wherever it was last invoked.
Ideally I am looking for something along the lines of:
ifWindows (resource =? "drawer") ({- bring window to current workspace -})
(spawnHere "urxvt -name drawer")
Going over the contrib docs it seems that I am trying to reinvent the wheel as I can just easily use scratchpad. That should do the trick.
But...if anyone has any ideas regarding the question above, i.e. using ifWindows to pull another window from one workspace to another I would love to know how you went about it.
Added the following myKeys:
, ("M-`", scratchpadSpawnActionTerminal myScratchTerm)
Defined the ManageHook:
myScratchPadHook :: ManageHook
myScratchPadHook =
scratchpadManageHook (W.RationalRect fLeft fTop tRight fBottom)
where
fLeft = 0.0
fTop = 0.75
tRight = 1.0
fBottom = 0.25
and added
<+> myScratchPadHook

Xmonad - How do I move mouse pointer as part of ManageHook?

Given this sample myManageHook. How can I call UpdatePointer after doIgnore? All my tries resulted in type incompatibilities.
myManageHook = composeAll . concat $
[
-- IntelliJ idea Tweaks
-- Manage idea completion window
, [ appName =? "sun-awt-X11-XWindowPeer" <&&> className =? "jetbrains-idea" --> doIgnore ]
, [ (className ~=? "jetbrains-") <&&> (title ~=? "Changes in") --> unfloat ]
]
where
unfloat = ask >>= doF . W.sink
My problem is that IntelliJ Idea popup window loses focus during typing if my mouse pointer is located over suggestions dropbox. That's why I'm trying to move the mouse to an upper part of the screen when this window appears.
UPD Found related thread with workarounds for Idea https://youtrack.jetbrains.com/issue/IDEA-112015#comment=27-2362253
You can use liftX to turn an X action into a Query action. You probably want to use XMonad.Actions.Warp instead of X.A.UpdatePointer instead, though; the latter looks like it might do a bit too much magic to sensibly fire during a manage hook. Anyway you should be able to try that out yourself once you see how to lift X actions.
So, for banish, you could use liftX like this:
... --> (liftX (banish UpperLeft) >> doIgnore)
Other X actions can be lifted and sequenced with doIgnore similarly.

How to select random .wav/.mp3 file from folder with Garry's mod?

I've recently started Coding a program that will replace sound effects from a default directory, in the Source-Engine Game, Garry's Mod.
This is the current code:
function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
ply:EmitSound("gear1")
return true
end
I want to emit multiple .wav Sound effects, without them overlapping, and being selected at random.
I have not found any Source helpful enough on the Internet to assist, so i resorted to Stack Overflow.
I would appreciate assistance with the topic.
You'll want to look at the file.Find function for this.
I'd recommend having a custom folder such as sound/customsteps/ where you can put all your custom sounds. I would also recommend using the .wav format for the sound files, but some others do work (.mp3 and .ogg if I recall correctly).
In your code, simply call local snds=file.Find( "sound/customsteps/*", "GAME" ) which gives you a table, then you can simply choose a random one from the list using local snd=snds[math.random(1,#snds)] and play it as you do in your above code - ply:EmitSound(snd).
Make sure you create the table of sounds outside of the GM:PlayerFootstep function, so that it only runs once. I would also recommend precaching all the sounds. You can do this by looping through the table and calling util.PrecacheSound(path) on them, like so:
for k,v in pairs(snds) do
util.PrecacheSound(v)
end
So, with all that in mind - your final code should look something like this:
local snds=file.Find( "sound/customsteps/*", "GAME" )
for k,v in pairs(snds) do
util.PrecacheSound(v)
end
function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
ply:EmitSound(snds[math.random(1,#snds)])
return true
end
Source: personal experience

Sound plays for half a second then stops?

When I play the sound file by itself (in interface) it works fine and plays all the way through. However, when I play it as part of the code (followed by an action) it only plays the first half second. I'm using sound:play-sound-and-wait, so I'm not sure why it isn't working.
extensions [sound] ; I have them in the same folder
to-report mouse-up?
ifelse mouse-down?
[report "false"]
[report "true"]
end
to twirl
if mouse-up?
[ask turtles with [shape = ballerina]
[set shape ballerina-2
twirl]
ask turtles with [shape = ballerina-2]
[set shape ballerina
twirl] ]
end
These are 2 different ballerina's facing different directions. When you switch between them, they look like they're twirling. She keeps doing that until you make her stop
to ballet-box
ask patches [set plabel-color 105] ;gives the background this color
sound:play-sound-and-wait "love.aif" ;this works perfectly fine in interface
twirl ;and then I want the ballerina to twirl until you make her stop
end
Any help would be super appreciated!
Sounds like http://github.com/NetLogo/Sound-Extension/issues/2 or http://github.com/NetLogo/Sound-Extension/issues/3 . I don't think anyone has yet investigated or attempted to fix these issues. I don't think we even know under exactly what circumstances they do or don't occur.

Height of tab (JTabbedPane) does not change

As the title says, the height of my tabs is not increasing as it should, my code looks like this:
JTabbedPane jtp = new JTabbedPane();
JLabel iconInTab = new JLabel(new ImageIcon("myImage.png"));
iconInTab.setPreferredSize(new Dimension(100,80)); // is the size of my Image, I've also try to do this using getSize
jtp.addTab(null,new JPanel());
jtp.setTabComponentAt(0,iconInTab);
I've also try this using html but it did not work either:
jtp.addTab("<html><p><p><p></html>",new ImageIcon("myImage.png"),new JPanel());
with the first code the problem is not the change of the size horizontally (the width change correctly), the problem is only on the height, with the second code, if I add multiple lines inside the html code, the text appear incomplete (just show the middle line) (also the width behaves as expected, the problem is the height). . .
why is this happening? or how could I get this done?
Note: S.O.: Mac OS X 10.8.1
Solved!!! The problem was that the default UI over MAC OS X (com.apple.laf.AquaTabbedPaneContrastUI), you only need to change it to the basicTabbedPaneUI (or the one of your preference), in my particular case I need to extend this class (it was a pain in the *, because what I wanted was really complex) to get the look & feel that I was expecting, if you have the same trouble just do this before adding your tabs:
myTabbedPane.setUI(new BasicTabbedPaneUI());
Note: Checking the default UI of your TabbedPane, may solve many different problems.

Resources