home:natto:xmonad: fix fullscreen

This commit is contained in:
2021-06-16 09:29:52 +05:30
parent ba8dbff511
commit d32d386248
13 changed files with 214 additions and 37 deletions

View File

@@ -1,8 +1,7 @@
import System.IO
import System.Exit
import XMonad
import XMonad.Config.Desktop
import XMonad.Layout.Fullscreen
import XMonad.Hooks.SetWMName
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.DynamicLog
import XMonad.Layout.NoBorders
@@ -11,7 +10,6 @@ import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
import XMonad.Layout.ResizableTile
import XMonad.Layout.ToggleLayouts (ToggleLayout(..), toggleLayouts)
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run (spawnPipe)
import qualified XMonad.StackSet as W
@@ -24,10 +22,18 @@ myNormalBorderColor = "#1d2021"
myModMask = mod4Mask
myFocusedBorderColor = "#d5c4a1"
myManageHook = composeAll
[ className =? "mpv" --> doFloat
, className =? "Discord" --> doFloat ]
[ className =? "Discord" --> doFloat ]
myWorkspaces = clickable $ ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" ]
tabConfig = defaultTheme {
activeTextColor = "#1d2021",
activeColor = "#d5c4a1",
inactiveTextColor = "#d5c4a1",
inactiveColor = "#1d2021"
}
myXmobarrc = "~/.xmonad/lib/xmobar.hs"
myWorkspaces = clickable $ ["\xf269", "\xf120", "\xf121", "\xf392", "\xf008", "\xf07b", "\xf11b", "\xf086", "\xf074" ]
where clickable l = ["<action=`xdotool key super+" ++ show (n) ++ "`>" ++ ws ++ "</action>" | (i,ws) <- zip [1..9] l, let n = i ]
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
@@ -74,7 +80,7 @@ myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
sendMessage NextLayout)
, ((modMask, xK_f),
sendMessage (Toggle "Full"))
toggleFullscreen)
, ((modMask .|. shiftMask, xK_space),
setLayout $ XMonad.layoutHook conf)
@@ -131,27 +137,58 @@ myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
myLayoutHook = toggleLayouts (noBorders Full) ( smartSpacing 8 $ smartBorders $ avoidStruts (
myLayoutHook = smartSpacing 8 $ smartBorders $ avoidStruts (
spiral (1/1) |||
tabbed shrinkText tabConfig |||
ThreeCol 1 (3/100) (1/2) |||
Tall 1 (3/100) (1/2) |||
Mirror (Tall 1 (3/100) (1/2)) |||
Full))
Full)
tabConfig = defaultTheme {
activeTextColor = "#1d2021",
activeColor = "#d5c4a1",
inactiveTextColor = "#d5c4a1",
inactiveColor = "#1d2021"
}
-- {{{source: https://github.com/liskin/dotfiles/commit/659af2ec68c26044f9e6ddf11655856613285685#diff-f3bd9f70ef878f30362ff11bbea7fd1d0d6abde1b4befa44b18cce5a27456204R190
toggleFullscreen =
withWindowSet $ \ws ->
withFocused $ \w -> do
let fullRect = W.RationalRect 0 0 1 1
let isFullFloat = w `M.lookup` W.floating ws == Just fullRect
windows $ if isFullFloat then W.sink w else W.float w fullRect
--}}}
--{{{
--couldnt get fullScreenEventHook to work normally so using this for now
--source code: https://github.com/xmonad/xmonad-contrib/blob/v0.16/XMonad/Hooks/EwmhDesktops.hs
myXmobarrc = "~/.xmonad/lib/xmobar.hs"
fullscreenFix :: XConfig a -> XConfig a
fullscreenFix c = c {
startupHook = startupHook c +++ setSupportedWithFullscreen
}
where x +++ y = mappend x y
setSupportedWithFullscreen :: X ()
setSupportedWithFullscreen = withDisplay $ \dpy -> do
r <- asks theRoot
a <- getAtom "_NET_SUPPORTED"
c <- getAtom "ATOM"
supp <- mapM getAtom ["_NET_WM_STATE_HIDDEN"
,"_NET_WM_STATE_FULLSCREEN"
,"_NET_NUMBER_OF_DESKTOPS"
,"_NET_CLIENT_LIST"
,"_NET_CLIENT_LIST_STACKING"
,"_NET_CURRENT_DESKTOP"
,"_NET_DESKTOP_NAMES"
,"_NET_ACTIVE_WINDOW"
,"_NET_WM_DESKTOP"
,"_NET_WM_STRUT"
]
io $ changeProperty32 dpy r a c propModeReplace (fmap fromIntegral supp)
setWMName "xmonad"
--}}}
main = do xmproc <- spawnPipe ("xmobar " ++ myXmobarrc)
xmonad $ ewmh desktopConfig
xmonad $ docks $ fullscreenFix $ ewmh def
{ borderWidth = myBorderWidth
, manageHook = manageDocks <+> myManageHook
, manageHook = manageDocks <+> myManageHook
, handleEventHook = handleEventHook def <+> fullscreenEventHook
, terminal = myTerminal
, focusFollowsMouse = myFocusFollowsMouse
, normalBorderColor = myNormalBorderColor
@@ -162,7 +199,7 @@ main = do xmproc <- spawnPipe ("xmobar " ++ myXmobarrc)
, workspaces = myWorkspaces
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppCurrent = xmobarColor "#b8bb26" "" . wrap "[" "]"
, ppCurrent = xmobarColor "#b8bb26" "" . wrap "+" ""
, ppVisible = xmobarColor "#b8bb26" ""
, ppHidden = xmobarColor "#d3869b" ""
, ppTitle = xmobarColor "#ebdbb2" "" . shorten 60