Layout Flattening Keybindings & Floating Window Placement

- Fix window copy keybindings to use meta
- Add keybindings to flatten floating windows into each layout
- Add keybinding to force kill focused window with xkill
- Automatically place floating windows in the center of the screen
- Force picture in picture windows to float
This commit is contained in:
Sravan Balaji
2021-05-09 21:18:37 -04:00
parent 1bb3509736
commit 6293138f1e
2 changed files with 56 additions and 16 deletions

View File

@@ -229,8 +229,8 @@ These default keybindings are left for reference, but are not actually used in m
++ ++
[ [
-- dwm-like add/remove window to/from all workspaces -- dwm-like add/remove window to/from all workspaces
("S-C-a", windows copyToAll) -- copy window to all workspaces ("M-S-C-a", windows copyToAll) -- copy window to all workspaces
, ("S-C-z", killAllOtherCopies) -- kill copies of window on other workspaces , ("M-S-C-z", killAllOtherCopies) -- kill copies of window on other workspaces
-- modify tiled window size -- modify tiled window size
, ("M-a", sendMessage MirrorShrink) -- decrease vertical window size , ("M-a", sendMessage MirrorShrink) -- decrease vertical window size
@@ -239,10 +239,19 @@ These default keybindings are left for reference, but are not actually used in m
-- toggle struts for xmobar -- toggle struts for xmobar
, ("M-s", sendMessage ToggleStruts) , ("M-s", sendMessage ToggleStruts)
-- switch directly to a layout -- switch directly to a layout with and without flattening floating windows
, ("M-f", sendMessage $ JumpToLayout "Full") , ("M-f", sendMessage $ JumpToLayout "Full")
, ("M-S-f", sequence_
[ withFocused $ windows . W.sink
, sendMessage $ JumpToLayout "Full"])
, ("M-t", sendMessage $ JumpToLayout "Spacing ResizableTall") , ("M-t", sendMessage $ JumpToLayout "Spacing ResizableTall")
, ("M-S-t", sequence_
[ withFocused $ windows . W.sink
, sendMessage $ JumpToLayout "Spacing ResizableTall"])
, ("M-g", sendMessage $ JumpToLayout "Spacing Grid") , ("M-g", sendMessage $ JumpToLayout "Spacing Grid")
, ("M-S-g", sequence_
[ withFocused $ windows . W.sink
, sendMessage $ JumpToLayout "Spacing Grid"])
-- launch rofi -- launch rofi
, ("M-p", spawn "rofi -show combi") , ("M-p", spawn "rofi -show combi")
@@ -271,6 +280,10 @@ These default keybindings are left for reference, but are not actually used in m
, ("M-C-S-l", spawn "light-locker-command --lock") -- lock , ("M-C-S-l", spawn "light-locker-command --lock") -- lock
, ("M-C-S-s", spawn "systemctl suspend") -- suspend , ("M-C-S-s", spawn "systemctl suspend") -- suspend
-- close focused window
, ("M-S-c", kill) -- regular kill
, ("M-C-S-c", spawn "xkill") -- force kill
-- toggle compositor -- toggle compositor
, ("M-<Esc>", spawn "/home/sravan/.config/picom/toggle_picom.sh") , ("M-<Esc>", spawn "/home/sravan/.config/picom/toggle_picom.sh")
@@ -348,10 +361,20 @@ which denotes layout choice.
#+begin_src haskell #+begin_src haskell
myManageHook = composeAll myManageHook = composeAll
[ className =? "MPlayer" --> doFloat [ className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat , className =? "Gimp" --> doFloat
, resource =? "desktop_window" --> doIgnore , resource =? "desktop_window" --> doIgnore
, resource =? "kdesktop" --> doIgnore ] , resource =? "kdesktop" --> doIgnore
, title =? "Picture in picture" --> doFloat
]
#+end_src
Automatically place floating windows using ~myPlacement~.
Smart placement with a preference for putting windows near the center of the screen, and with 16px gaps at the top and bottom of the screen where no window will be placed.
#+begin_src haskell
myPlacement = withGaps (16,0,16,0) (smart (0.5,0.5))
#+end_src #+end_src
* Event Handling * Event Handling
@@ -423,7 +446,7 @@ Run xmonad with the settings you specify. No need to modify this.
xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config" xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config"
-- launches xmobar as a dock -- launches xmobar as a dock
xmonad $ ewmh desktopConfig xmonad $ ewmh desktopConfig
{ manageHook = manageDocks <+> manageHook desktopConfig { manageHook = manageDocks <+> myManageHook <+> placeHook myPlacement <+> manageHook desktopConfig
, startupHook = myStartupHook , startupHook = myStartupHook
, layoutHook = myLayout , layoutHook = myLayout
, borderWidth = myBorderWidth , borderWidth = myBorderWidth

View File

@@ -57,8 +57,8 @@ myKeys =
++ ++
[ [
-- dwm-like add/remove window to/from all workspaces -- dwm-like add/remove window to/from all workspaces
("S-C-a", windows copyToAll) -- copy window to all workspaces ("M-S-C-a", windows copyToAll) -- copy window to all workspaces
, ("S-C-z", killAllOtherCopies) -- kill copies of window on other workspaces , ("M-S-C-z", killAllOtherCopies) -- kill copies of window on other workspaces
-- modify tiled window size -- modify tiled window size
, ("M-a", sendMessage MirrorShrink) -- decrease vertical window size , ("M-a", sendMessage MirrorShrink) -- decrease vertical window size
@@ -67,10 +67,19 @@ myKeys =
-- toggle struts for xmobar -- toggle struts for xmobar
, ("M-s", sendMessage ToggleStruts) , ("M-s", sendMessage ToggleStruts)
-- switch directly to a layout -- switch directly to a layout with and without flattening floating windows
, ("M-f", sendMessage $ JumpToLayout "Full") , ("M-f", sendMessage $ JumpToLayout "Full")
, ("M-S-f", sequence_
[ withFocused $ windows . W.sink
, sendMessage $ JumpToLayout "Full"])
, ("M-t", sendMessage $ JumpToLayout "Spacing ResizableTall") , ("M-t", sendMessage $ JumpToLayout "Spacing ResizableTall")
, ("M-S-t", sequence_
[ withFocused $ windows . W.sink
, sendMessage $ JumpToLayout "Spacing ResizableTall"])
, ("M-g", sendMessage $ JumpToLayout "Spacing Grid") , ("M-g", sendMessage $ JumpToLayout "Spacing Grid")
, ("M-S-g", sequence_
[ withFocused $ windows . W.sink
, sendMessage $ JumpToLayout "Spacing Grid"])
-- launch rofi -- launch rofi
, ("M-p", spawn "rofi -show combi") , ("M-p", spawn "rofi -show combi")
@@ -99,6 +108,10 @@ myKeys =
, ("M-C-S-l", spawn "light-locker-command --lock") -- lock , ("M-C-S-l", spawn "light-locker-command --lock") -- lock
, ("M-C-S-s", spawn "systemctl suspend") -- suspend , ("M-C-S-s", spawn "systemctl suspend") -- suspend
-- close focused window
, ("M-S-c", kill) -- regular kill
, ("M-C-S-c", spawn "xkill") -- force kill
-- toggle compositor -- toggle compositor
, ("M-<Esc>", spawn "/home/sravan/.config/picom/toggle_picom.sh") , ("M-<Esc>", spawn "/home/sravan/.config/picom/toggle_picom.sh")
@@ -142,10 +155,14 @@ myLayout =
monocle = noBorders (Full) monocle = noBorders (Full)
myManageHook = composeAll myManageHook = composeAll
[ className =? "MPlayer" --> doFloat [ className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doFloat , className =? "Gimp" --> doFloat
, resource =? "desktop_window" --> doIgnore , resource =? "desktop_window" --> doIgnore
, resource =? "kdesktop" --> doIgnore ] , resource =? "kdesktop" --> doIgnore
, title =? "Picture in picture" --> doFloat
]
myPlacement = withGaps (16,0,16,0) (smart (0.5,0.5))
myStartupHook = do myStartupHook = do
-- System Restore Processes -- System Restore Processes
@@ -176,7 +193,7 @@ main = do
xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config" xmproc <- spawnPipe "xmobar -x 0 /home/sravan/.xmonad/xmobar.config"
-- launches xmobar as a dock -- launches xmobar as a dock
xmonad $ ewmh desktopConfig xmonad $ ewmh desktopConfig
{ manageHook = manageDocks <+> manageHook desktopConfig { manageHook = manageDocks <+> myManageHook <+> placeHook myPlacement <+> manageHook desktopConfig
, startupHook = myStartupHook , startupHook = myStartupHook
, layoutHook = myLayout , layoutHook = myLayout
, borderWidth = myBorderWidth , borderWidth = myBorderWidth