New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoidStruts not working #79

Closed
tjovanovic opened this Issue Feb 14, 2017 · 9 comments

Comments

Projects
None yet
6 participants
@tjovanovic
Copy link

tjovanovic commented Feb 14, 2017

Problem Description

Hey guys, ever since the update last night to 0.13 (Arch distro) my avoidStruts function seems not to be working for some reason. What used to be solvable with a simple (mod, shift, space) combo doesn't work anymore. I tested it and it covers up both xmobar and xfce4-panel, and doesn't seem to recognize them. Both the xmobar and xfce panel start up correctly and are present if I resize the window.

Any ideas?

import Control.Monad (liftM2)
import System.IO
import System.Exit
import XMonad
import XMonad.Actions.CycleWS
import XMonad.Actions.CopyWindow
import XMonad.Actions.MouseGestures
import XMonad.Actions.SpawnOn
import XMonad.Actions.Warp
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.Script
import XMonad.Hooks.SetWMName
import XMonad.Layout.Fullscreen
import XMonad.Layout.MultiToggle
import XMonad.Layout.NoBorders
import XMonad.Layout.Reflect
import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
import XMonad.Layout.Spacing
import XMonad.Prompt
import XMonad.Prompt.RunOrRaise
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import XMonad.Util.NamedScratchpad
import qualified XMonad.Layout.IndependentScreens as LIS
import qualified XMonad.StackSet as W
import qualified Data.Map        as M

import Data.String.Utils


------------------------------------------------------------------------
-- Terminal
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal = "gnome-terminal --hide-menubar"

scratchpads = [
    NS "term" "gnome-terminal --hide-menubar --role=scratchpad" (role =? "scratchpad") (customFloating $ W.RationalRect (1/12) (1/12) (5/6) (5/6)),
    NS "irc" "gnome-terminal --role=irc" (role =? "irc") (customFloating $ W.RationalRect (1/12) (1/12) (5/6) (5/6)),
    NS "applaunch" "xfce4-appfinder -c" (title =? "Application Finder") defaultFloating ,
    NS "notes" "gvim --role notes ~/Dropbox/notes/notes.otl" (role =? "notes") (customFloating $ W.RationalRect (0) (1/20) (2/4) (9/10))]
        where role = stringProperty "WM_WINDOW_ROLE"

------------------------------------------------------------------------
-- Workspaces
-- The default number of workspaces (virtual screens) and their names.
--
myWorkspaces = map show [1..9]


------------------------------------------------------------------------
-- Window rules
-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
{-myManageHook = composeAll
    [ resource  =? "desktop_window"   --> doIgnore
    , className =? "stalonetray"      --> doIgnore
    , className =? "plank"            --> doIgnore
      -- Below gets chrome_app_list to properly float
    , (stringProperty "WM_WINDOW_ROLE") =? "bubble"  --> doFloat
    , (stringProperty "WM_WINDOW_ROLE") =? "pop-up"  --> doFloat
    , isFullscreen --> (doF W.focusDown <+> doFullFloat)]
-}


myManageHook = composeAll
    ([ 
    -- className =? "Chromium"       --> doShift (browser)
    className =? "Dwb"          --> doShift (browser)
    , resource  =? "desktop_window" --> doIgnore
    -- , className =? "Vlc"             --> doShift (media)
    -- , className =? "Vlc"             --> viewShift (media)
    -- , className =? "MPlayer"        --> doShift (media)
    -- , className =? "mpv"             --> doShift (media)
    -- , className =? "mpv"             --> viewShift (media)
    -- , className =? "MPlayer"        --> viewShift (media)
    -- , className =? "MPlayer"        --> doFloat
    , className =? "Deluge"        --> doShift (myWorkspaces!!4)
    -- , resource  =? "gpicview"       --> doFloat
    , className =? "Vlc"            --> doFloat
    , className =? "mpv"            --> doFloat
    , className =? "Xfce4-appfinder"--> doFloat
    , className =? "VirtualBox"     --> doShift (myWorkspaces!!7)
    , className =? "Thunderbird"     --> doShift (myWorkspaces!!6)
    , className =? "Gnucash"     --> doShift (myWorkspaces!!5)
    , className =? "Thunar"     --> doShift (files)
    , className =? "ROX-Filer"     --> doShift (files)
    , className =? "ROX-Filer"     --> viewShift (files)
    , className =? "MuPDF"     --> doShift (pdfview)
    , className =? "MuPDF"     --> viewShift (pdfview)
    , className =? "Xchat"          --> doShift "5:media"
    , className =? "stalonetray"    --> doIgnore
    , className =? "Orage"    --> doFloat
    , className =? "Xfce4-notifyd" --> doF W.focusDown <+> doF copyToAll
    , stringProperty "WM_NAME" =? "File Operation Progress" --> doFloat
    , stringProperty "WM_NAME" =? "LastPass Site Search" --> doFloat
    , isFullscreen --> (doF W.focusDown <+> doFullFloat)]) 
    where
      viewShift = doF . liftM2 (.) W.greedyView W.shift
      browser = myWorkspaces!!1
      pdfview = myWorkspaces!!2
      media = myWorkspaces!!12
      files = myWorkspaces!!9

------------------------------------------------------------------------
-- Layouts
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts.  Note that each layout is separated by |||,
-- which denotes layout choice.
--
myLayout = avoidStruts (
    Tall 1 (3/100) (1/2) |||
    Mirror (Tall 1 (3/100) (1/2)) |||
    tabbedBottom shrinkText myTabConfig |||
    -- simpleTabbedBottom |||
    Full |||
    spiral (6/7)) |||
    tabbedBottom shrinkText myTabConfig |||
    noBorders (fullscreenFull Full)


------------------------------------------------------------------------
-- Colors and borders
-- Currently based on the ir_black theme.
--
myNormalBorderColor  = "#181818"
myFocusedBorderColor = "#C0C0C0"

-- Colors for text and backgrounds of each tab when in "Tabbed" layout.
myTabConfig = defaultTheme {
    activeBorderColor = "#181818",
    activeTextColor = "#FF8500",
    activeColor = "#181818",
    inactiveBorderColor = "#000000",
    inactiveTextColor = "#DDDDDD",
    inactiveColor = "#000000"
}

-- Color of current window title in xmobar.
xmobarTitleColor = "#DDD"

-- Color of current workspace in xmobar.
xmobarCurrentWorkspaceColor = "#FF8500"

-- Width of the window border in pixels.
myBorderWidth = 1


------------------------------------------------------------------------
-- Key bindings
--
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt").  You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "super key" is usually mod4Mask.
--
myModMask = mod5Mask

myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  ----------------------------------------------------------------------
  -- Custom key bindings
  --

  -- Start a terminal.  Terminal to start is specified by myTerminal variable.
  [ ((modMask .|. shiftMask, xK_Return),
     spawn $ XMonad.terminal conf)

  -- Start EMACS
  , ((modMask, xK_e),
     spawn "emacsclient -c")

  -- Start Blender
  , ((modMask, xK_b),
     spawn "blender")

  -- Start GIMP
  , ((modMask, xK_g),
     spawn "gimp")
    
  -- Start Chrome Browser
  , ((modMask, xK_w),
     spawn "firefox")
    
  -- Start Vivaldi Browser
  , ((modMask, xK_v),
     spawn "vivaldi")
    
  -- Lock the screen using xscreensaver.
  , ((modMask .|. controlMask, xK_l),
  --   spawn "gnome-screensaver-command -l")
     spawn "xscreensaver-command -lock")

--  , ((0, xK_grave), namedScratchpadAction scratchpads "term")

  , ((0, xK_F1), namedScratchpadAction scratchpads "term")

  -- Launch dmenu.
  -- Use this to launch programs without a key binding.
  , ((modMask, xK_s),
     spawn "dmenu_run")

  -- Take a screenshot in select mode.
  -- After pressing this key binding, click a window, or draw a rectangle with
  -- the mouse.
  --, ((modMask .|. shiftMask, xK_p),
  --   spawn "select-screenshot")

  -- Take full screenshot in multi-head mode.
  -- That is, take a screenshot of everything you see.
  --, ((modMask .|. controlMask .|. shiftMask, xK_p),
  --   spawn "screenshot")

  , ((mod1Mask, xK_space),
     spawn "google-chrome --show-app-list")

  -- MonBrightnessUp
  , ((0, 0x1008FF02),
     spawn "xbacklight -inc 10")

  -- MonBrightnessDown 0x1008FF02
  , ((0, 0x1008FF03),
     spawn "xbacklight -dec 5")

  -- Audio mute toggle
  , ((0, xK_F8 ),
     spawn "amixer -q set Master toggle")

  -- Audio Vol+
  , ((modMask, xK_bracketright ),
     spawn "amixer -q set Master 5%+")
    
  -- Audio Vol-
  , ((modMask, xK_bracketleft ),
     spawn "amixer -q set Master 5%-")

  -- Audio mute toggle (media key)
  , ((0, 0x1008FF12),
     spawn "amixer -q set Master toggle")

  -- Audio Vol+ (media key)
  , ((0, 0x1008FF13),
     spawn "amixer -q set Master 5%+")
    
  -- Audio Vol- (media key)
  , ((0, 0x1008FF11),
     spawn "amixer -q set Master 5%-")
    
  -- Audio previous.
  --, ((0, 0x1008FF16),
  --   spawn "")

  -- Play/pause.
  --, ((0, 0x1008FF14),
  --   spawn "")

  -- Audio next.
  --, ((0, 0x1008FF17),
  --   spawn "")

  -- Eject CD tray.
  --, ((0, 0x1008FF2C),
  --   spawn "eject")

  -- Cycle workspaces left and right
  , ((controlMask .|. mod1Mask, xK_Right),
     nextWS)

  , ((controlMask .|. mod1Mask, xK_Left),
     prevWS)

  -- Move focus to the next window with workspace-like keys
  , ((controlMask .|. mod1Mask, xK_Down),
     windows W.focusDown)

  -- Move focus to the previous window with workspace-like keys
  , ((controlMask .|. mod1Mask, xK_Up),
     windows W.focusUp  )
    
  , ((controlMask .|. mod1Mask .|. shiftMask, xK_Right),
     shiftToNext >> nextWS)

  , ((controlMask .|. mod1Mask .|. shiftMask, xK_Left),
     shiftToPrev >> prevWS)

  , ((modMask, xK_d ),
     windows copyToAll)

  , ((modMask .|. shiftMask, xK_d ),
     killAllOtherCopies)

  --------------------------------------------------------------------
  -- "Standard" xmonad key bindings
  --

  -- Close focused window.
  , ((modMask .|. shiftMask, xK_c),
     kill)

  -- Cycle through the available layout algorithms.
  , ((modMask, xK_space),
     sendMessage NextLayout)

  --  Reset the layouts on the current workspace to default.
  , ((modMask .|. shiftMask, xK_space),
     setLayout $ XMonad.layoutHook conf)

  , ((0, xK_F2),
     setLayout $ XMonad.layoutHook conf)

  -- Resize viewed windows to the correct size.
  , ((modMask, xK_n),
     refresh)

  -- Move focus to the next window.
  , ((modMask, xK_Tab),
     windows W.focusDown)

  -- Move focus to the next window.
  , ((modMask, xK_j),
     windows W.focusDown)

  -- Move focus to the previous window.
  , ((modMask, xK_k),
     windows W.focusUp  )

  -- Move focus to the master window.
  , ((modMask, xK_m),
     windows W.focusMaster  )

  -- Swap the focused window and the master window.
  , ((modMask, xK_Return),
     windows W.swapMaster)

  -- Swap the focused window with the next window.
  , ((modMask .|. shiftMask, xK_j),
     windows W.swapDown  )

  -- Swap the focused window with the previous window.
  , ((modMask .|. shiftMask, xK_k),
     windows W.swapUp    )

  -- Shrink the master area.
  , ((modMask, xK_h),
     sendMessage Shrink)

  -- Expand the master area.
  , ((modMask, xK_l),
     sendMessage Expand)

  -- Push window back into tiling.
  , ((modMask, xK_t),
     withFocused $ windows . W.sink)

  -- Increment the number of windows in the master area.
  , ((modMask, xK_comma),
     sendMessage (IncMasterN 1))

  -- Decrement the number of windows in the master area.
  , ((modMask, xK_period),
     sendMessage (IncMasterN (-1)))

  -- Toggle the status bar gap.
  -- TODO: update this binding with avoidStruts, ((modMask, xK_b),

  -- Quit xmonad.
  , ((modMask .|. shiftMask, xK_q),
     io (exitWith ExitSuccess))

  -- Restart xmonad.
  , ((modMask, xK_q),
     restart "xmonad" True)


  , ((0, xK_F9),
     spawn "xrandr --output eDP1 --primary --auto")

  , ((0, xK_F10),
     spawn "xrandr --output HDMI1 --primary --auto --right-of eDP1")
  ]
  ++

  -- mod-[1..9], Switch to workspace N
  -- mod-shift-[1..9], Move client to workspace N
  [((m .|. modMask, k), windows $ f i)
      | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
      , (f, m) <- [(W.view, 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 .|. modMask, 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
--
-- Focus rules
-- True if your focus should follow your mouse cursor.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True

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
    , ((modMask, button2),
       (\w -> focus w >> windows W.swapMaster))

    -- mod-button3, Set the window to floating mode and resize by dragging
    , ((modMask, button3),
       (\w -> focus w >> mouseResizeWindow w))

    -- you may also bind events to the mouse scroll wheel (button4 and button5)
  ]


------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'DynamicLog' extension for examples.
--
-- To emulate dwm's status bar
--
-- > logHook = dynamicLogDzen
--


------------------------------------------------------------------------
-- Startup hook
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
myStartupHook :: X ()
myStartupHook = do
  spawn "xscreensaver -no-splash &"
  spawn "feh --bg-scale $HOME/.wall.jpg&"
  spawn "xsetroot -cursor_name left_ptr"
--  spawn "killall nautilus"
--  spawn "rm ~/.config/google-chrome/SingletonLock"
  spawn "setxkbmap us -variant altgr-intl -option caps:escape"
  spawn "killall stalonetray nm-applet pasystray; stalonetray --icon-size=16 --kludges=force_icons_size --geometry 2x1+3250 -bg \"#1E1E1E\"& nm-applet& pasystray&"
--  spawn "~/.dropbox-dist/dropboxd"
--  setWMName "LG3D"


------------------------------------------------------------------------
-- Run xmonad with all the defaults we set up.
--
main = do
  xmproc <- spawnPipe "xmobar ~/.xmonad/xmobar.hs"
  xmonad $ defaults {
      logHook = dynamicLogWithPP $ xmobarPP {
            ppOutput = hPutStrLn xmproc . replace " NSP " " "
          , ppTitle = xmobarColor xmobarTitleColor "" . shorten 100
          , ppCurrent = xmobarColor xmobarCurrentWorkspaceColor ""
          , ppSep = "   "
      }
      , manageHook = manageDocks <+> myManageHook <+> namedScratchpadManageHook scratchpads
      , startupHook = myStartupHook

  }


------------------------------------------------------------------------
-- Combine it all together
-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will
-- use the defaults defined in xmonad/XMonad/Config.hs
--
-- No need to modify this.
--
defaults = defaultConfig {
    -- simple stuff
    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         = myManageHook,
startupHook        = myStartupHook
}
@liskin

This comment has been minimized.

Copy link
Contributor

liskin commented Feb 14, 2017

We forgot to add a release notes/changelog entry for (among others) xmonad/xmonad-contrib@e38fb3b. You need to use either docksStartupHook or (preferably) docks in your config.

@tjovanovic

This comment has been minimized.

Copy link
Author

tjovanovic commented Feb 14, 2017

That works, thanks!

@tjovanovic tjovanovic closed this Feb 14, 2017

@geekosaur

This comment has been minimized.

Copy link
Contributor

geekosaur commented Feb 15, 2017

@dj-foxxy

This comment has been minimized.

Copy link

dj-foxxy commented Feb 15, 2017

This caught me out. I wish there was a way of showing closed issues 'cos I guess a lot people will be looking for this. :)

@geekosaur

This comment has been minimized.

Copy link
Contributor

geekosaur commented Feb 15, 2017

More than that; it's becoming clear that we still only handle dzen2 right if it is started with -dock. Reopening, because this used to work and it clearly doesn't now. (Another instance on IRC last night.)

@geekosaur geekosaur reopened this Feb 15, 2017

@geekosaur

This comment has been minimized.

Copy link
Contributor

geekosaur commented Feb 15, 2017

@geekosaur

This comment has been minimized.

Copy link
Contributor

geekosaur commented Feb 15, 2017

...actually this needs to be moved to -contrib

@Tracerneo

This comment has been minimized.

Copy link

Tracerneo commented Feb 15, 2017

In the topic of dzen2, it worked correctly without -dock option before, on xmonad 0.11 and 0.12.

If dzen2 is used with -dock and slave feature, xmonad will try to manage the slave window and cause weird graphical glitches.

The easiest way to test that, is to run dzen2 -dock -l 1 and hover over the bar, right click on the bar to close it.

Slave window in dzen2 -l 1 is being handled correctly and xmonad lets it float over windows, but avoidStruts no longer takes effect, so the bar just appears under or over the windows.

womfoo added a commit to womfoo/dotfiles that referenced this issue Mar 1, 2017

@pjones

This comment has been minimized.

Copy link
Contributor

pjones commented Apr 10, 2017

Let's move discussion over to #83. Closing this as a duplicate.

@pjones pjones closed this Apr 10, 2017

cstrahan added a commit to cstrahan/dotfiles that referenced this issue May 23, 2017

xmonad: fix dock support
Account for recent changes in XMonad:

xmonad/xmonad#79

nmaupu added a commit to nmaupu/auto-home that referenced this issue Nov 13, 2017

Fixing xmonad avoidStructs
avoidStrust was not working anymore.
Fixing it adding `-dock` option to dzen along with
`docksStartupHook` to `startupHook`
See: xmonad/xmonad#79

Lance0312 added a commit to Lance0312/myConf that referenced this issue Jan 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment