You are not logged in.

#1 2014-12-28 12:54:19

Dun
Member
Registered: 2014-12-28
Posts: 98

Problem with XMonad.Layout.NoBorders (smartBorders)

Hi there! I would like to use smartBorders but I don't know if I'm using it right. Yesterday somehow it worked but after a restart Xmonad still draws borders around every window.
To be clear about that, I just want Xmonad to have no border if a window is single and "maximized" (e.g. Chromium) or in fullscreen (e.g. MPlayer in fullscreen).
That's how I tried to implement it:

layoutHook         = smartBorders $ myLayout,

or

myLayout = smartBorders $ tiled ||| Mirror tiled ||| Full

That's how I saw it in other configuration files at least, but nothing happens after recompiling and restarting. I would like to read the documentation XMonad.Layout.NoBorders, but I don't know how to read it neither I'm getting smarter reading the source-file.

Could someone help me there?



xmonad.hs

import XMonad
import Data.Monoid
import System.Exit 
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks 
import XMonad.Config.Xfce
import XMonad.Util.Run(spawnPipe)  
import XMonad.Util.EZConfig  
import Graphics.X11.ExtraTypes.XF86  
import XMonad.Layout.Spacing  
import XMonad.Layout.NoBorders   ( noBorders, smartBorders)
import XMonad.Layout.PerWorkspace  
import XMonad.Layout.IM  
import XMonad.Layout.Grid  
import XMonad.Actions.GridSelect  
import Data.Ratio ((%))  
import XMonad.Actions.CycleWS  
import System.IO  

main = do
	xmproc <- spawnPipe "/usr/bin/xmobar /home/dun/.xmobarrc"
	xmonad $ xfceConfig
 		{
   		terminal           = myTerminal,
   		focusFollowsMouse  = myFocusFollowsMouse,
   		borderWidth        = myBorderWidth,
  	 	modMask            = myModMask,
  	 	workspaces         = myWorkspaces,
 	  	normalBorderColor  = myNormalBorderColor,
 	  	focusedBorderColor = myFocusedBorderColor,
   		-- key bindings
		keys               = myKeys,
		mouseBindings      = myMouseBindings,
   		-- hooks, layouts
		layoutHook         = smartBorders $ myLayout,
		manageHook         = manageDocks <+> myManageHook
								<+> manageHook defaultConfig,
		handleEventHook    = myEventHook,
		logHook            =	dynamicLogWithPP xmobarPP  
								{ ppOutput = hPutStrLn xmproc  
								, ppTitle = xmobarColor "#2CE3FF" "" . shorten 50  
								, ppLayout = const "" -- to disable the layout info onxmobar  
								},
		startupHook        = myStartupHook
 		}

--
--Things
--

myTerminal    = "urxvt"
myModMask     = mod1Mask
myBorderWidth = 1
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
myWorkspaces    = ["1:web","2:media","3:work","4:programming","5","6","7","8","9"]
myNormalBorderColor  = "#545454"
myFocusedBorderColor = "#AEDC79"

--
--Layout, Hooks
--

myLayout = tiled ||| Mirror tiled ||| Full
  where
-- default tiling algorithm partitions the screen into two panes
    tiled   = Tall nmaster delta ratio
 
-- The default number of windows in the master pane
    nmaster = 1
 
-- Default proportion of screen occupied by master pane
    ratio   = 1/2
 
-- Percent of screen to increment by when resizing panes
    delta   = 3/100


myManageHook = composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat
    , className =? "Chromium"       --> doFloat
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "kdesktop"       --> doIgnore 
	]
myEventHook = mempty
myStartupHook = return ()

--
--Keys
--

myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
 
    -- launch a terminal
    [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
 
    -- launch dmenu
    , ((modm,               xK_p     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
 
    -- launch gmrun
    , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
 
    -- close focused window
    , ((modm .|. shiftMask, xK_c     ), kill)
 
     -- Rotate through the available layout algorithms
    , ((modm,               xK_space ), sendMessage NextLayout)
 
    --  Reset the layouts on the current workspace to default
    , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
 
    -- Resize viewed windows to the correct size
    , ((modm,               xK_n     ), refresh)
 
    -- Move focus to the next window
    , ((modm,               xK_Tab   ), windows W.focusDown)
 
    -- Move focus to the next window
    , ((modm,               xK_j     ), windows W.focusDown)
 
    -- Move focus to the previous window
    , ((modm,               xK_k     ), windows W.focusUp  )
 
    -- Move focus to the master window
    , ((modm,               xK_m     ), windows W.focusMaster  )
 
    -- Swap the focused window and the master window
    , ((modm,               xK_Return), windows W.swapMaster)
 
    -- Swap the focused window with the next window
    , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )
 
    -- Swap the focused window with the previous window
    , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )
 
    -- Shrink the master area
    , ((modm,               xK_h     ), sendMessage Shrink)
 
    -- Expand the master area
    , ((modm,               xK_l     ), sendMessage Expand)
 
    -- Push window back into tiling
    , ((modm,               xK_t     ), withFocused $ windows . W.sink)
 
    -- Increment the number of windows in the master area
    , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
 
    -- Deincrement the number of windows in the master area
    , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
 
    -- Toggle the status bar gap
    -- Use this binding with avoidStruts from Hooks.ManageDocks.
    -- See also the statusBar function from Hooks.DynamicLog.
    --
    -- , ((modm              , xK_b     ), sendMessage ToggleStruts)
 
    -- Quit xmonad
    , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
 
    -- Restart xmonad
    , ((modm              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
    ]
    ++
 
    --
    -- mod-[1..9], Switch to workspace N
    --
    -- mod-[1..9], Switch to workspace N
    -- mod-shift-[1..9], Move client to workspace N
    --
    [((m .|. modm, k), windows $ f i)
        | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
    ++
 
    --
    -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
    -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
    --
    [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
 
 
------------------------------------------------------------------------
-- Mouse bindings: default actions bound to mouse events
--
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
 
    -- mod-button1, Set the window to floating mode and move by dragging
    [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
                                       >> windows W.shiftMaster))
 
    -- mod-button2, Raise the window to the top of the stack
    , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
 
    -- mod-button3, Set the window to floating mode and resize by dragging
    , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
                                       >> windows W.shiftMaster))
 
    -- you may also bind events to the mouse scroll wheel (button4 and button5)
    ]

Last edited by Dun (2014-12-28 12:54:46)

Offline

#2 2014-12-28 13:30:16

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Problem with XMonad.Layout.NoBorders (smartBorders)

You can use toggleLayouts for that. I have both smartBorders and toggleLayouts, and I'm not sure why anymore (I do now. See the comment below).

import XMonad.Layout.ToggleLayouts

My layout hook begins with:

, layoutHook         = avoidStruts
                     $ toggleLayouts (noBorders Full)
                     $ smartBorders
                     ...

*** EDIT ***

I just removed smartBorders and everything still works the way that I expect.

Nevermind that; It works for stuff like fullscreen mpv.

Your handleEventHook is strange to me. I'm not sure what the logic of setting it to mempty (an empty data structure) is and if it's going to have negative consequences. Someone with more knowledge than I can answer that question.

Last edited by skottish (2014-12-28 13:39:45)

Offline

#3 2014-12-28 13:51:22

Dun
Member
Registered: 2014-12-28
Posts: 98

Re: Problem with XMonad.Layout.NoBorders (smartBorders)

skottish wrote:

Your handleEventHook is strange to me. I'm not sure what the logic of setting it to mempty (an empty data structure) is and if it's going to have negative consequences. Someone with more knowledge than I can answer that question.

I just used the template file as a base, the value mempty comes from there.
Could maybe that be a source of problems? I thought the values were default.


I now imported the ToggleLayouts and implemented it. Now it looks like this:

layoutHook         = avoidStruts $ toggleLayouts(noBorders Full) $ smartBorders $ myLayout,
myLayout = tiled ||| Mirror tiled ||| Full
  where
-- default tiling algorithm partitions the screen into two panes
    tiled   = Tall nmaster delta ratio
 
-- The default number of windows in the master pane
    nmaster = 1
 
-- Default proportion of screen occupied by master pane
    ratio   = 1/2
 
-- Percent of screen to increment by when resizing panes
    delta   = 3/100

But still nothing changed.

Offline

#4 2014-12-28 14:12:56

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Problem with XMonad.Layout.NoBorders (smartBorders)

Dun wrote:

I just used the template file as a base, the value mempty comes from there.
Could maybe that be a source of problems? I thought the values were default.

It's probably not the source of your problems. It just looked strange to me, but I really don't know one way or another. I actually removed my own handleEventHook line and let it go with the defaults and it didn't seem to change anything. I put it back because, well, I have no idea why I put it there in the first place.

This is the import section of my xmonad.hs:

import XMonad
import Control.Monad
import Data.Monoid
import Data.List
import Data.Maybe

import XMonad.ManageHook
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.InsertPosition
import XMonad.Hooks.EwmhDesktops

import XMonad.Layout.NoBorders
import XMonad.Layout.ResizableTile
import XMonad.Layout.LayoutHints
import XMonad.Layout.Cross
import XMonad.Layout.ToggleLayouts
import XMonad.Layout.WindowNavigation

import XMonad.Actions.CycleWS
import XMonad.Actions.CycleWindows 
import XMonad.Actions.Promote

import XMonad.Util.Loggers 
import XMonad.Util.Run
import XMonad.Util.WindowProperties

import qualified Data.Map as M
import qualified XMonad.StackSet as W

import System.Exit
import Graphics.X11.Xlib
import System.IO

And main:

main = do
  h <- spawnPipe "xmobar -x 0 ~/.config/xmobar/xmobarrc"
   
  xmonad $ ewmh defaultConfig
     { terminal           = "termite"
     , modMask            = mod4Mask
     , borderWidth        = 2
     , focusedBorderColor = "blue" 
     , normalBorderColor  = "black" 
     , keys               = keys'
     , handleEventHook    = handleEventHook defaultConfig <+> fullscreenEventHook
     , manageHook         = manageHook' 
     , layoutHook         = layoutHook'
     , logHook            = dynamicLogWithPP $ xmobarHook h
     }

And layoutHook':

layoutHook' = avoidStruts
            $ toggleLayouts (noBorders Full)
            $ smartBorders 
            $ windowNavigation ( Cross (3/5) (1/20) ||| ResizableTall 1 (3/100) (1/2) [])

Maybe there's something there that can help?

Offline

#5 2014-12-28 15:35:35

Dun
Member
Registered: 2014-12-28
Posts: 98

Re: Problem with XMonad.Layout.NoBorders (smartBorders)

Hm I can't find the problem there. The only thing you have additional is that "fullscreenEventHook", but I don't know how it could be connected to smartBorders.
Do you not have any border in single and fullscreen with your current config?

Maybe I just think that smartBorders remove completely borders from single and fullscreen windows but it actually doesn't do that or whatever. My problem here is that I've never saw a live running Xmonad. There are some videos but they are old or bad and they all aren't very well documented. And the documentation of Haskell in the internet is pretty bad as well and not only because the website needs at least 10s for every site it loads. I just can't get valuable information from them without learning some Haskell first, what I currently don't want/can.

Looks like I have to put this problem beside for now :>

Offline

#6 2014-12-28 17:08:23

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Problem with XMonad.Layout.NoBorders (smartBorders)

I misunderstood part of your question, in part because of how I do things. If a tile is 'maximized' or toggled full on my system, then the border goes away. Full screen floating windows also have no border. If I'm using a single tile in a full screen layout, then there is a border. I don't typically work with one full screen tile unless it's maximized, so that's where I got confused.

Finding information on Haskell can be tricky, particularly for the more advanced stuff. Like other functional languages, it's a bunch of the same idioms recurring. But until one understands those idioms, it can be frustrating. I'm about to go into a whole new layer of stuff that I've never dealt with before, so I'm preplanning where I'm going to bang my head for the next few weeks/months.

Offline

#7 2014-12-28 21:12:19

Dun
Member
Registered: 2014-12-28
Posts: 98

Re: Problem with XMonad.Layout.NoBorders (smartBorders)

skottish wrote:

I misunderstood part of your question, in part because of how I do things. If a tile is 'maximized' or toggled full on my system, then the border goes away. Full screen floating windows also have no border. If I'm using a single tile in a full screen layout, then there is a border. I don't typically work with one full screen tile unless it's maximized, so that's where I got confused.

Well yeah, I would like to have no borders at all. With my current config just nothing happens, the borders still remain like nothing ever change.

I will now just deactivate borders until I figured out how to use this function correctly, after all I'm using Xmonad just few days :>

Offline

Board footer

Powered by FluxBB