summaryrefslogtreecommitdiff
path: root/.xmonad/xmonad.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-18 06:49:01 +0300
committerdefanor <defanor@uberspace.net>2017-12-18 07:16:26 +0300
commit378b02d139002e1e5b9263fc2802c98c28fa66ab (patch)
treed44ec287926473368c9ed358837d7641d3d17c49 /.xmonad/xmonad.hs
parent4bcbee7ee1fd9da5b29aca7e249ab284e02e1c91 (diff)
Add xmonad+xmobar config
Diffstat (limited to '.xmonad/xmonad.hs')
-rw-r--r--.xmonad/xmonad.hs96
1 files changed, 96 insertions, 0 deletions
diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs
new file mode 100644
index 0000000..cec291c
--- /dev/null
+++ b/.xmonad/xmonad.hs
@@ -0,0 +1,96 @@
+-- TODO: remove `killall xmobar` once xmobar will use stdin reader.
+
+import XMonad
+import XMonad.Hooks.DynamicLog
+import XMonad.Hooks.ManageDocks
+import XMonad.Hooks.EwmhDesktops
+import XMonad.Actions.Submap
+import XMonad.Config
+import qualified Data.Map as M
+import XMonad.Util.SpawnOnce
+import XMonad.Util.EZConfig
+
+
+-- | Prefixes everything with mod+t instead of a mod key, so that
+-- mod+1 becomes mod+t 1 (e.g., C-1 -> C-t 1), for instance.
+myKeys :: (XConfig Layout -> M.Map (KeyMask, KeySym) (X ()))
+ -> XConfig Layout
+ -> M.Map (KeyMask, KeySym) (X ())
+myKeys oldKeys conf@(XConfig {XMonad.modMask = modMask}) =
+ M.fromList [((modMask, xK_t), submap (oldKeys conf { modMask = noModMask }))]
+
+
+{- | On CentOS 7, with GeForce GTX 660 and a proprietary NVIDIA driver,
+with vsync enabled in nvidia-settings:
+
+- default: white flash when switching to FF, and screen tearing on
+ smooth scrolling there
+- compton --backend glx: screen tearing in emacs on scroll/text
+ movement, apparently happens just after some time (may be a bug)
+- compton --backend glx --vsync opengl-swc: same
+- compton --backend glx --paint-on-overlay: same
+- compton --backend glx --vsync opengl --paint-on-overlay: same
+- compton --backend glx --vsync opengl-swc --sw-opti: same, probably
+ FF scrolling gets less smooth
+- compton with
+ <https://bbs.archlinux.org/viewtopic.php?pid=1541023#p1541023>
+ configuration: same, probably FF scrolling got worse
+- compton with that and `glx-swap-method = "buffer-age"`, as suggested
+ further in that thread: some text bits in emacs begin changing back
+ and forth even without scrolling (apparently that's what is
+ described even further there).
+- compton --backend xrender: same as with no compton
+- compton --dbe: same
+- compton --backend xrender --vsync opengl-oml: same
+- compton --backend xrender --vsync opengl: same, but reduces the
+ flashing
+- compton --backend xrender --vsync opengl --paint-on-overlay: same
+- compton --backend xrender --vsync opengl --dbe: same
+- compton --backend xrender -cf: eliminates the white flash, though a
+ bit slower; same as without -cf otherwise
+- with --vsync drm: "VBlank ioctl did not work, unimplemented in this
+ drmver?"
+
+Apparently these and similar issues are not uncommon (and not specific
+to xmonad), and there's a bunch of different solutions -- some of them
+probably working for some users, but they tend to have side effects as
+well. Pretty much as described on
+<https://github.com/chjj/compton/wiki/vsync-guide>.
+
+Using 'spawnOnce' here, so that it wouldn't run multiple compton
+processes on xmonad restart: that would load CPU and make the display
+unusable. A drawback is that restarting xmonad doesn't suffice to
+restart a killed compton. This actually shouldn't be an issue, since
+compton is supposed to handle it:
+
+- https://specifications.freedesktop.org/wm-spec/latest/ar01s08.html#idm139870829889072
+- https://github.com/chjj/compton/issues/301
+
+But I've got an old version from repositories (apparently they don't
+do much of versioning or releases, or of other conventional things,
+but the package update date is 2014-10-16). I still don't see why this
+happens (would probably have to debug, or at least to try a newer
+version), but it does.
+-}
+runCompton = spawnOnce "compton --backend xrender -cf"
+
+
+main = do
+ -- This is awkward, but apparently there's no better standard way to
+ -- avoid multiple xmobar instances.
+ c <- statusBar "killall --quiet --exact xmobar; xmobar" xmobarPP
+ (\(XConfig {XMonad.modMask = modMask}) -> (modMask, xK_b))
+ def
+ -- EWMH (extended window manager hints) are used to control xmonad
+ -- with xdotool from xmobar.
+ xmonad $ ewmh c
+ { layoutHook = avoidStruts $ layoutHook c
+ , manageHook = manageHook c <+> manageDocks
+ , keys = myKeys $ keys $ c `additionalKeys`
+ -- C-t C-t would send C-t to a focused window.
+ [((controlMask, xK_t), spawn "xdotool key ctrl+t")]
+ , modMask = controlMask
+ , focusedBorderColor = "#444"
+ , normalBorderColor = "#000"
+ , startupHook = runCompton
+ }