about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cabal.project.freeze35
-rw-r--r--flake.lock6
-rw-r--r--flake.nix8
-rw-r--r--package.yaml11
-rw-r--r--src/exe/Main.hs61
-rw-r--r--src/lib/XMonad/Custom/Bindings.hs2
-rw-r--r--src/lib/XMonad/Custom/Config.hs54
-rw-r--r--src/lib/XMonad/Custom/Misc.hs2
-rw-r--r--src/lib/XMonad/Custom/Navigation.hs6
-rw-r--r--src/lib/XMonad/Custom/Startup.hs4
-rw-r--r--src/lib/XMonad/Custom/Workspaces.hs9
-rw-r--r--stack.yaml3
-rw-r--r--stack.yaml.lock16
-rwxr-xr-xtest.sh103
-rw-r--r--xmonad-ng.cabal19
15 files changed, 219 insertions, 120 deletions
diff --git a/cabal.project.freeze b/cabal.project.freeze
deleted file mode 100644
index 83b5cb0..0000000
--- a/cabal.project.freeze
+++ /dev/null
@@ -1,35 +0,0 @@
-active-repositories: hackage.haskell.org:merge
-constraints: any.X11 ==1.10.2,
-             any.X11-xft ==0.3.1,
-             any.array ==0.5.4.0,
-             any.base ==4.14.3.0,
-             any.bytestring ==0.10.12.0,
-             any.containers ==0.6.5.1,
-             any.data-default ==0.7.1.1,
-             any.data-default-class ==0.1.2.0,
-             any.data-default-instances-containers ==0.0.1,
-             any.data-default-instances-dlist ==0.0.1,
-             any.data-default-instances-old-locale ==0.0.1,
-             any.deepseq ==1.4.4.0,
-             any.directory ==1.3.6.0,
-             any.dlist ==1.0,
-             any.extensible-exceptions ==0.1.1.4,
-             any.filepath ==1.4.2.1,
-             any.ghc-prim ==0.6.1,
-             any.integer-gmp ==1.0.3.0,
-             any.mtl ==2.2.2,
-             any.old-locale ==1.0.0.7,
-             any.old-time ==1.1.0.3,
-             any.process ==1.6.13.2,
-             any.random ==1.2.0,
-             any.rts ==1.0.1,
-             any.semigroups ==0.19.2,
-             any.setlocale ==1.0.0.10,
-             any.splitmix ==0.1.0.4,
-             any.time ==1.9.3,
-             any.transformers ==0.5.6.2,
-             any.unix ==2.7.2.2,
-             any.utf8-string ==1.0.2,
-             any.xmonad ==0.15,
-             any.xmonad-contrib ==0.16
-index-state: hackage.haskell.org 2021-11-22T20:41:46Z
diff --git a/flake.lock b/flake.lock
index ae20847..e28436d 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,11 +2,11 @@
   "nodes": {
     "nixpkgs": {
       "locked": {
-        "lastModified": 1637593665,
-        "narHash": "sha256-R7jKS7A+0tZS8qD5pBr1UFcMiTdsw5bfoxgXbYsoWhM=",
+        "lastModified": 1638366923,
+        "narHash": "sha256-Sh6+Pm0ShdtqW+BGynIJX+F12Lqs0xJq6qWmDkZN2uA=",
         "owner": "NixOS",
         "repo": "nixpkgs",
-        "rev": "98747f27ecfee70c8c97b195cbb94df80a074dda",
+        "rev": "1fbcb733eb9daf23ab9e70e58e76fa0b767dc033",
         "type": "github"
       },
       "original": {
diff --git a/flake.nix b/flake.nix
index 7234537..c53b5c2 100644
--- a/flake.nix
+++ b/flake.nix
@@ -19,6 +19,14 @@
           inherit returnShellEnv;
           name = "xmonad-ng";
           root = ./.;
+          overrides = self: _:
+            with pkgs.haskell.lib;
+            let version = "0.17.0";
+            in {
+              xmonad = dontCheck (self.callHackage "xmonad" version { });
+              xmonad-contrib =
+                dontCheck (self.callHackage "xmonad-contrib" version { });
+            };
           modifier = drv:
             pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages; [
               brittany
diff --git a/package.yaml b/package.yaml
index 4bd1a71..e197d7b 100644
--- a/package.yaml
+++ b/package.yaml
@@ -18,15 +18,16 @@ ghc-options:
   - -Wredundant-constraints
 
 dependencies:
-  - base >= 4.14 && < 5
-  - xmonad >= 0.15 && < 0.16
-  - xmonad-contrib >= 0.16 && < 0.17
+  - base == 4.*
+  - flow == 1.0.*
+  - xmonad == 0.17.*
+  - xmonad-contrib == 0.17.*
 
 library:
   source-dirs: src/lib
   dependencies:
-    - containers >= 0.6.5 && < 0.7
-    - X11 >= 1.10.2 && < 1.11
+    - containers == 0.6.*
+    - X11 == 1.10.*
   when:
     - condition: false
       other-modules: Paths_xmonad_ng
diff --git a/src/exe/Main.hs b/src/exe/Main.hs
index 3a57650..7b08f2a 100644
--- a/src/exe/Main.hs
+++ b/src/exe/Main.hs
@@ -1,6 +1,6 @@
 -- |
 -- Module                  : Main
--- Description             : Entrypoint
+-- Description             : Application entrypoint
 -- Copyright               : (c) Azat Bahawi 2018-2021
 -- SPDX-License-Identifier : GPL-3.0-or-later
 -- Maintainer              : azahi@teknik.io
@@ -10,61 +10,8 @@
 
 module Main where
 
-import           XMonad                         ( Default(def)
-                                                , XConfig
-                                                  ( borderWidth
-                                                  , clickJustFocuses
-                                                  , focusFollowsMouse
-                                                  , focusedBorderColor
-                                                  , handleEventHook
-                                                  , keys
-                                                  , layoutHook
-                                                  , manageHook
-                                                  , modMask
-                                                  , mouseBindings
-                                                  , normalBorderColor
-                                                  , startupHook
-                                                  , terminal
-                                                  , workspaces
-                                                  )
-                                                , xmonad
-                                                )
-import           XMonad.Actions.DynamicProjects ( dynamicProjects )
-import           XMonad.Actions.Navigation2D    ( withNavigation2DConfig )
-import qualified XMonad.Custom.Bindings        as C
-import qualified XMonad.Custom.Event           as C
-import qualified XMonad.Custom.Layout          as C
-import qualified XMonad.Custom.Manage          as C
-import qualified XMonad.Custom.Misc            as C
-import qualified XMonad.Custom.Navigation      as C
-import qualified XMonad.Custom.Projects        as C
-import qualified XMonad.Custom.Startup         as C
-import qualified XMonad.Custom.Theme           as C
-import qualified XMonad.Custom.Workspaces      as C
-import           XMonad.Hooks.EwmhDesktops      ( ewmh )
-import           XMonad.Hooks.ManageDocks       ( docks )
-import           XMonad.Layout.Fullscreen       ( fullscreenSupport )
+import           XMonad
+import           XMonad.Custom.Config
 
 main :: IO ()
-main =
-  xmonad
-    $ ewmh
-    $ fullscreenSupport
-    $ docks
-    $ withNavigation2DConfig C.navigation
-    $ dynamicProjects C.projects
-    $ def { borderWidth        = C.border
-          , workspaces         = C.workspaces
-          , layoutHook         = C.layoutHook
-          , terminal           = C.term C.applications
-          , normalBorderColor  = C.colorN
-          , focusedBorderColor = C.colorF
-          , modMask            = C.modMask
-          , keys               = C.keys
-          , startupHook        = C.startupHook
-          , mouseBindings      = C.mouseBindings
-          , manageHook         = C.manageHook
-          , handleEventHook    = C.handleEventHook
-          , focusFollowsMouse  = False
-          , clickJustFocuses   = False
-          }
+main = myConfig >>= xmonad
diff --git a/src/lib/XMonad/Custom/Bindings.hs b/src/lib/XMonad/Custom/Bindings.hs
index 208ccdf..807be4f 100644
--- a/src/lib/XMonad/Custom/Bindings.hs
+++ b/src/lib/XMonad/Custom/Bindings.hs
@@ -57,7 +57,7 @@ import           XMonad.Util.NamedScratchpad
 import           XMonad.Util.WorkspaceCompare
 
 modMask :: KeyMask
-modMask = mod4Mask
+modMask = controlMask
 
 directions :: [Direction2D]
 directions = [D, U, L, R]
diff --git a/src/lib/XMonad/Custom/Config.hs b/src/lib/XMonad/Custom/Config.hs
new file mode 100644
index 0000000..84f4069
--- /dev/null
+++ b/src/lib/XMonad/Custom/Config.hs
@@ -0,0 +1,54 @@
+{-# OPTIONS_GHC -Wno-missing-signatures #-}
+
+-- |
+-- Module                  : XMonad.Custom.Config
+-- Description             : Configuration entrypoint to be passed to executable
+-- Copyright               : (c) Azat Bahawi 2018-2021
+-- SPDX-License-Identifier : GPL-3.0-or-later
+-- Maintainer              : azahi@teknik.io
+-- Stability               : experimental
+-- Portability             : non-portable
+--
+
+module XMonad.Custom.Config
+    ( myConfig
+    ) where
+
+import           Flow
+import           XMonad
+import           XMonad.Actions.Navigation2D
+import qualified XMonad.Custom.Bindings        as C
+import qualified XMonad.Custom.Event           as C
+import qualified XMonad.Custom.Layout          as C
+import qualified XMonad.Custom.Manage          as C
+import qualified XMonad.Custom.Misc            as C
+import qualified XMonad.Custom.Navigation      as C
+import qualified XMonad.Custom.Theme           as C
+import qualified XMonad.Custom.Workspaces      as C
+import           XMonad.Hooks.EwmhDesktops
+import           XMonad.Hooks.ManageDocks
+import           XMonad.Hooks.UrgencyHook
+import           XMonad.Layout.IndependentScreens
+
+myConfig = do
+    screens <- countScreens
+    def { borderWidth        = C.border
+        , workspaces         = C.myWorkspaces screens
+        , layoutHook         = C.layoutHook
+        , terminal           = C.term C.applications
+        , normalBorderColor  = C.colorN
+        , focusedBorderColor = C.colorF
+        , modMask            = C.modMask
+        , keys               = C.keys
+        , mouseBindings      = C.mouseBindings
+        , manageHook         = C.manageHook
+        , handleEventHook    = C.handleEventHook
+        , focusFollowsMouse  = False
+        , clickJustFocuses   = False
+        }
+        |> withUrgencyHook (borderUrgencyHook C.red1)
+        |> withNavigation2DConfig C.myNavigation2DConfig
+        |> ewmh
+        |> ewmhFullscreen
+        |> docks
+        |> (return :: a -> IO a)
diff --git a/src/lib/XMonad/Custom/Misc.hs b/src/lib/XMonad/Custom/Misc.hs
index b9901b4..355df91 100644
--- a/src/lib/XMonad/Custom/Misc.hs
+++ b/src/lib/XMonad/Custom/Misc.hs
@@ -31,6 +31,6 @@ applications = Applications { browser = "qutebrowser"
                             , mixer   = "pulsemixer"
                             , notify  = "notify-send"
                             , player  = "ncmpcpp"
-                            , term    = "urxvtc"
+                            , term    = "xterm"
                             , top     = "htop"
                             }
diff --git a/src/lib/XMonad/Custom/Navigation.hs b/src/lib/XMonad/Custom/Navigation.hs
index 2646db4..cf96ab7 100644
--- a/src/lib/XMonad/Custom/Navigation.hs
+++ b/src/lib/XMonad/Custom/Navigation.hs
@@ -9,13 +9,13 @@
 --
 
 module XMonad.Custom.Navigation
-  ( navigation
+  ( myNavigation2DConfig
   ) where
 
 import           XMonad.Actions.Navigation2D
 
-navigation :: Navigation2DConfig
-navigation = def
+myNavigation2DConfig :: Navigation2DConfig
+myNavigation2DConfig = def
   { defaultTiledNavigation = hybridOf sideNavigation centerNavigation
   , floatNavigation        = hybridOf lineNavigation centerNavigation
   , layoutNavigation       = [("Full", centerNavigation)]
diff --git a/src/lib/XMonad/Custom/Startup.hs b/src/lib/XMonad/Custom/Startup.hs
index f2415ea..935d08f 100644
--- a/src/lib/XMonad/Custom/Startup.hs
+++ b/src/lib/XMonad/Custom/Startup.hs
@@ -50,8 +50,8 @@ addEWMHFullscreen = do
 
 startupHook :: X ()
 startupHook = do
-  spawnNamedPipe "xmobar ~/.xmonad/xmobarrc/top.hs" "xmobarTop"
-  spawnNamedPipe "xmobar ~/.xmonad/xmobarrc/bot.hs" "xmobarBot"
+  -- spawnNamedPipe "xmobar ~/.xmonad/xmobarrc/top.hs" "xmobarTop"
+  -- spawnNamedPipe "xmobar ~/.xmonad/xmobarrc/bot.hs" "xmobarBot"
   docksStartupHook
   addEWMHFullscreen
   setDefaultCursor xC_left_ptr
diff --git a/src/lib/XMonad/Custom/Workspaces.hs b/src/lib/XMonad/Custom/Workspaces.hs
index ba2a1e7..43d8aa2 100644
--- a/src/lib/XMonad/Custom/Workspaces.hs
+++ b/src/lib/XMonad/Custom/Workspaces.hs
@@ -9,10 +9,11 @@
 --
 
 module XMonad.Custom.Workspaces
-  ( workspaces
+  ( myWorkspaces
   ) where
 
-import           XMonad.Core             hiding ( workspaces )
+import           XMonad.Core
+import           XMonad.Layout.IndependentScreens
 
-workspaces :: [WorkspaceId]
-workspaces = map show [1 .. 9 :: Int]
+myWorkspaces :: ScreenId -> [PhysicalWorkspace]
+myWorkspaces = flip withScreens $ map show [1 .. 9 :: Int]
diff --git a/stack.yaml b/stack.yaml
index 6658c36..3f06915 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -1,5 +1,8 @@
 ---
 resolver: lts-18.18
+extra-deps:
+  - xmonad-0.17.0
+  - xmonad-contrib-0.17.0
 nix:
   enable: true
   packages:
diff --git a/stack.yaml.lock b/stack.yaml.lock
index a9834e3..59970bc 100644
--- a/stack.yaml.lock
+++ b/stack.yaml.lock
@@ -3,7 +3,21 @@
 # For more information, please see the documentation at:
 #   https://docs.haskellstack.org/en/stable/lock_files
 
-packages: []
+packages:
+- completed:
+    hackage: xmonad-0.17.0@sha256:fc90c8fa647390c68c902912a5a7417f04025dfe72f7de51b248217f7ca0d484,5533
+    pantry-tree:
+      size: 2485
+      sha256: 6fd7c6a64621a088fcbb2e5a66030a78b0832d7341e4c465d3aeb4e668d097a5
+  original:
+    hackage: xmonad-0.17.0
+- completed:
+    hackage: xmonad-contrib-0.17.0@sha256:defd04a9ca0e031eb7280b734ccd6d6b73f757babfe4a561a7ff718e75211749,20357
+    pantry-tree:
+      size: 21783
+      sha256: 81a4589ef85fed434a852ba1324466b5ad8f4fd752cd88840aa4ea4348a16cec
+  original:
+    hackage: xmonad-contrib-0.17.0
 snapshots:
 - completed:
     size: 586296
diff --git a/test.sh b/test.sh
new file mode 100755
index 0000000..fd86536
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,103 @@
+#!/usr/bin/env bash
+
+################################################################################
+usage() {
+	cat <<EOF
+Usage: run-in-xephyr.sh [options]
+
+  -d NxN  Set the screen size to NxN
+  -h      This message
+  -n NUM  Set the internal DISPLAY to NUM
+  -s NUM  Set the number of screens to NUM
+EOF
+}
+
+################################################################################
+ARCH=$(uname -m)
+OS=$(uname -s | tr '[:upper:]' '[:lower:]')
+SCREENS=1
+SCREEN_SIZE="800x600"
+DISPLAY_NUMBER=5
+
+################################################################################
+while getopts "hs:" o; do
+	case "${o}" in
+		d)
+			SCREEN_SIZE=$OPTARG
+			;;
+
+		h)
+			usage
+			exit
+			;;
+
+		n)
+			DISPLAY_NUMBER=$OPTARG
+			;;
+
+		s)
+			SCREENS=$OPTARG
+			;;
+
+		*)
+			echo
+			usage
+			exit 1
+			;;
+	esac
+done
+
+shift $((OPTIND - 1))
+
+################################################################################
+if [ -d .stack-work ]; then
+	echo "stack build detected"
+	options=""
+	[ "${NIX_PATH:-NO}" = "NO" ] || options="--nix"
+	BIN_PATH=$(stack path $options --dist-dir)/build/xmonad-ng
+elif [ -d dist-newstyle ]; then
+	echo "cabal build detected"
+	BIN_PATH=$(find dist-newstyle/ -type f -executable -name xmonad-ng -printf '%h')
+else
+	echo "you need to build xmonad-ng first, see README for instructions"
+	exit 1
+fi
+
+RAW_BIN=$BIN_PATH/xmonad-ng
+ARCH_BIN=$BIN_PATH/xmonad-$ARCH-$OS
+
+################################################################################
+cp -p "$RAW_BIN" "$ARCH_BIN"
+
+################################################################################
+XMONAD_CONFIG_DIR=$(pwd)/state/config
+XMONAD_CACHE_DIR=$(pwd)/state/cache
+XMONAD_DATA_DIR=$(pwd)/state/data
+export XMONAD_CONFIG_DIR XMONAD_CACHE_DIR XMONAD_DATA_DIR
+
+mkdir -p "$XMONAD_CONFIG_DIR" "$XMONAD_CACHE_DIR" "$XMONAD_DATA_DIR"
+echo "xmonad will store state files in $(pwd)/state"
+
+################################################################################
+SCREEN_COUNTER=0
+SCREEN_OPTS=""
+X_OFFSET_CURRENT="0"
+X_OFFSET_ADD=$(echo "$SCREEN_SIZE" | cut -dx -f1)
+
+while expr "$SCREEN_COUNTER" "<" "$SCREENS"; do
+	SCREEN_OPTS="$SCREEN_OPTS -origin ${X_OFFSET_CURRENT},0 -screen ${SCREEN_SIZE}+${X_OFFSET_CURRENT}"
+	SCREEN_COUNTER=$(("$SCREEN_COUNTER" + 1))
+	X_OFFSET_CURRENT=$(("$X_OFFSET_CURRENT" + "$X_OFFSET_ADD"))
+done
+
+(
+	# shellcheck disable=SC2086
+	Xephyr $SCREEN_OPTS +xinerama +extension RANDR \
+		-ac -br -reset -terminate -verbosity 10 \
+		-softCursor ":$DISPLAY_NUMBER" &
+
+	export DISPLAY=":$DISPLAY_NUMBER"
+	echo "Waiting for windows to appear..." && sleep 2
+
+	$ARCH_BIN
+)
diff --git a/xmonad-ng.cabal b/xmonad-ng.cabal
index ae1b31f..748fc8b 100644
--- a/xmonad-ng.cabal
+++ b/xmonad-ng.cabal
@@ -25,6 +25,7 @@ source-repository head
 library
   exposed-modules:
       XMonad.Custom.Bindings
+      XMonad.Custom.Config
       XMonad.Custom.Event
       XMonad.Custom.Layout
       XMonad.Custom.Log
@@ -41,11 +42,12 @@ library
       src/lib
   ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
   build-depends:
-      X11 >=1.10.2 && <1.11
-    , base >=4.14 && <5
-    , containers >=0.6.5 && <0.7
-    , xmonad ==0.15.*
-    , xmonad-contrib ==0.16.*
+      X11 ==1.10.*
+    , base ==4.*
+    , containers ==0.6.*
+    , flow ==1.0.*
+    , xmonad ==0.17.*
+    , xmonad-contrib ==0.17.*
   default-language: Haskell2010
 
 executable xmonad-ng
@@ -54,8 +56,9 @@ executable xmonad-ng
       src/exe
   ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -rtsopts -threaded -v0 -with-rtsopts=-N
   build-depends:
-      base >=4.14 && <5
-    , xmonad ==0.15.*
-    , xmonad-contrib ==0.16.*
+      base ==4.*
+    , flow ==1.0.*
+    , xmonad ==0.17.*
+    , xmonad-contrib ==0.17.*
     , xmonad-ng
   default-language: Haskell2010

Consider giving Nix/NixOS a try! <3