about summary refs log tree commit diff
path: root/dotfiles/xmonad.hs
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-07-06 12:26:50 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-07-06 12:26:50 +0200
commit0f878efc1515012aeba548432bf02d81a7f59fd8 (patch)
tree453ae0c8f941be236c38c60cc798ebc7de1345e7 /dotfiles/xmonad.hs
parentfmt (diff)
downloadnixos-config-0f878efc1515012aeba548432bf02d81a7f59fd8.tar.gz
nixos-config-0f878efc1515012aeba548432bf02d81a7f59fd8.tar.bz2
nixos-config-0f878efc1515012aeba548432bf02d81a7f59fd8.zip
Xmonad+sxhkd: Add toggle floating functionality
Diffstat (limited to 'dotfiles/xmonad.hs')
-rw-r--r--dotfiles/xmonad.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/dotfiles/xmonad.hs b/dotfiles/xmonad.hs
index bf32d9f..0cd3eba 100644
--- a/dotfiles/xmonad.hs
+++ b/dotfiles/xmonad.hs
@@ -133,6 +133,7 @@ myCommands =
         , ("swap-with-next"            , windows W.swapDown                               )
         , ("swap-with-master"          , windows W.swapMaster                             )
         , ("togglefullscreen"          , sendMessage $ Toggle FULL                        )
+        , ("togglefloating"            , withFocused toggleFloat                          )
         , ("next-layout"               , sendMessage NextLayout                           )
         , ("cycle-workspace"           , toggleWS                                         )
         , ("kill-window"               , kill                                             )
@@ -164,15 +165,19 @@ listMyServerCmds = spawn ("echo '" ++ asmc ++ "' | xmessage -file -")
 myFocusFollowsMouse :: Bool
 myFocusFollowsMouse = False
 
+toggleFloat w = windows (\s -> if M.member w (W.floating s)
+                            then W.sink w s
+                            else (W.float w (W.RationalRect 0.125 0.125 0.75 0.75) s))
+
 myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
   [
     -- mod-button1, Set the window to floating mode and move by dragging
     ((modMask, button1),
      (\w -> focus w >> mouseMoveWindow w))
 
-    -- mod-button2, Raise the window to the top of the stack
+    -- mod-button2, Toggle float on the window
     , ((modMask, button2),
-       (\w -> focus w >> windows W.swapMaster))
+       (\w -> focus w >> toggleFloat w))
 
     -- mod-button3, Set the window to floating mode and resize by dragging
     , ((modMask, button3),