aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-02-01 23:46:55 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-02-01 23:46:55 -0700
commit766675ca92cac6aa3bb67fa45ae28da28ae86bcc (patch)
tree6f70cf66faa396b4ddc37683652bc510a3b8f6ce
downloadrde-766675ca92cac6aa3bb67fa45ae28da28ae86bcc.tar.gz
rde-766675ca92cac6aa3bb67fa45ae28da28ae86bcc.tar.bz2
rde-766675ca92cac6aa3bb67fa45ae28da28ae86bcc.zip
First XMonad-JRahm Commit
Have an install script to install XMonad-jrahm on the expected platform.
-rw-r--r--README.md14
-rwxr-xr-xbuild-script.sh17
-rw-r--r--compton.conf52
-rwxr-xr-xinstall.sh10
-rw-r--r--package.yaml16
-rw-r--r--src/Internal/Keys.hs103
-rw-r--r--src/Internal/Layout.hs73
-rw-r--r--src/Internal/Marking.hs77
-rw-r--r--src/Main.hs32
-rw-r--r--stack.yaml70
-rwxr-xr-xstartup16
-rw-r--r--xmobarrc9
12 files changed, 489 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7cb15fd
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+# My XMonad Configuration
+
+Configuration for my XMonad.
+
+Dependencies are:
+
+- XMonad
+- Compton
+- XMobar
+
+## Installation
+
+Simply run `install.sh` and it should provide install everything provided the
+dependencies have already been installed.
diff --git a/build-script.sh b/build-script.sh
new file mode 100755
index 0000000..72b6310
--- /dev/null
+++ b/build-script.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+actual_bin=$(readlink -f "$0")
+proj_dir="$(dirname $actual_bin)"
+olddir="$(pwd)"
+
+cd "$proj_dir"
+stack install
+
+ec="$?"
+if [ "$ec" -ne 0 ] ; then
+ exit "$ec"
+fi
+
+cd "$olddir"
+
+ln -sf "$HOME/.local/bin/jrahm-xmonad" "$1"
diff --git a/compton.conf b/compton.conf
new file mode 100644
index 0000000..aff1471
--- /dev/null
+++ b/compton.conf
@@ -0,0 +1,52 @@
+backend = "glx";
+
+### Shadow
+shadow = true;
+no-dnd-shadow = true;
+no-dock-shadow = true;
+# clear-shadow = true;
+shadow-radius = 10;
+shadow-offset-x = -8;
+shadow-offset-y = -5;
+shadow-opacity = 1;
+shadow-red = 0.0;
+shadow-green = 0.0;
+shadow-blue = 0.0;
+
+inactive-dim=0.1
+inactive-opacity=0.99
+
+shadow-exclude = [
+ # From the Ubuntu forums link ('screaminj3sus')
+ # "! name~=''",
+ # "n:e:Notification",
+ # "n:e:Plank",
+ # "n:e:Docky",
+ # "g:e:Synapse",
+ # "g:e:Kupfer",
+ # "g:e:Conky",
+ # "n:w:*Firefox*",
+ # "class_g ?= 'Notify-osd'",
+ # "class_g ?= 'Cairo-dock'",
+ # "class_g ?= 'Xfce4-notifyd'",
+ # "class_g ?= 'Xfce4-power-manager'"
+];
+shadow-ignore-shaped = false;
+
+blur-background = true;
+
+wintypes:
+{
+ tooltip =
+ {
+ fade = true;
+ shadow = false;
+ opacity = 0.85;
+ focus = true;
+ }
+
+
+
+}
+# shadow-exclude-reg = "x10+0+0";
+# xinerama-shadow-crop = true;
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..7cbcfa8
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+real_dir=$(dirname $(readlink -f "$0"))
+cd "$real_dir"
+
+mkdir -p "$HOME/.xmonad"
+ln -sfv "$real_dir/build-script.sh" "$HOME/.xmonad/build"
+ln -sfv "$real_dir/compton.conf" "$HOME/.config/compton.conf"
+ln -sfv "$real_dir/startup" "$HOME/.xmonad/startup"
+ln -sfv "$real_dir/xmobarrc" "$HOME/.xmobarrc"
diff --git a/package.yaml b/package.yaml
new file mode 100644
index 0000000..056890d
--- /dev/null
+++ b/package.yaml
@@ -0,0 +1,16 @@
+name: jrahm-xmonad
+version: 0.0.1
+
+executables:
+ jrahm-xmonad:
+ main: Main.hs
+ source-dirs: src
+
+dependencies:
+ - base >= 4.0.0
+ - xmonad
+ - xmonad-contrib
+ - directory
+ - filepath
+ - process
+ - containers
diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs
new file mode 100644
index 0000000..b00458e
--- /dev/null
+++ b/src/Internal/Keys.hs
@@ -0,0 +1,103 @@
+module Internal.Keys where
+
+import qualified Data.Map as Map
+import Data.Map (Map)
+import Internal.Marking
+import XMonad.Actions.Submap
+import XMonad.Util.CustomKeys
+import XMonad
+import Control.Monad
+import XMonad.Actions.WindowNavigation
+import qualified XMonad.StackSet as W
+
+type KeyMap l = XConfig l -> Map (KeyMask, KeySym) (X ())
+
+applyKeys :: XConfig l -> IO (XConfig l)
+applyKeys config@(XConfig {modMask = modm}) = do
+ ks <- newKeys
+ withWindowNavigation (xK_k, xK_h, xK_j, xK_l) $
+ config { keys = ks }
+
+newKeys :: IO (KeyMap l)
+newKeys =
+ withNewMarkContext $ \markContext ->
+ return $ \config@(XConfig {modMask = modm}) ->
+ let workspacesByInt =
+ Map.fromList $
+ zip ['1'..] (XMonad.workspaces config)
+
+ gotoWorkspace :: Char -> X ()
+ gotoWorkspace ch =
+ mapM_ (windows . W.greedyView) (Map.lookup ch workspacesByInt)
+
+ in
+
+ Map.fromList
+ [ ((modm, xK_F12), (void $ spawn "spotify-control next"))
+ , ((modm, xK_F11), (void $ spawn "spotify-control prev"))
+ , ((modm, xK_F10), (void $ spawn "spotify-control play"))
+ , ((modm .|. mod1Mask, xK_l), (void $ spawn "xscreensaver-command -lock"))
+ , ((modm, xK_t), (void $ spawn (terminal config)))
+ , ((modm, xK_m), (submap $ mapAlpha modm (markCurrentWindow markContext)))
+ , ((modm, xK_apostrophe), (submap $
+ Map.insert
+ (modm, xK_apostrophe)
+ (jumpToLast markContext)
+ (mapAlpha modm (jumpToMark markContext))))
+ , ((modm, xK_g), (submap $ mapNumbers 0 gotoWorkspace))
+
+ , ((modm .|. shiftMask, xK_bracketleft), sendMessage (IncMasterN (-1)))
+ , ((modm .|. shiftMask, xK_bracketright), sendMessage (IncMasterN 1))
+ , ((modm, xK_bracketleft), sendMessage Shrink)
+ , ((modm, xK_bracketright), sendMessage Expand)
+
+ , ((modm, xK_space), sendMessage NextLayout)
+
+ , ((modm, xK_q), spawn "xmonad --recompile && xmonad --restart")
+ ]
+
+mapNumbers :: KeyMask -> (Char -> X ()) -> Map (KeyMask, KeySym) (X ())
+mapNumbers km fn =
+ Map.fromList [
+ ((km, xK_0), fn '0')
+ , ((km, xK_1), fn '1')
+ , ((km, xK_2), fn '2')
+ , ((km, xK_3), fn '3')
+ , ((km, xK_4), fn '4')
+ , ((km, xK_5), fn '5')
+ , ((km, xK_6), fn '6')
+ , ((km, xK_7), fn '7')
+ , ((km, xK_8), fn '8')
+ , ((km, xK_9), fn '9')
+ ]
+
+mapAlpha :: KeyMask -> (Char -> X ()) -> Map (KeyMask, KeySym) (X ())
+mapAlpha km fn =
+ Map.fromList [
+ ((km, xK_a), fn 'a')
+ , ((km, xK_b), fn 'b')
+ , ((km, xK_c), fn 'c')
+ , ((km, xK_d), fn 'd')
+ , ((km, xK_e), fn 'e')
+ , ((km, xK_f), fn 'f')
+ , ((km, xK_g), fn 'g')
+ , ((km, xK_h), fn 'h')
+ , ((km, xK_i), fn 'i')
+ , ((km, xK_j), fn 'j')
+ , ((km, xK_k), fn 'k')
+ , ((km, xK_l), fn 'l')
+ , ((km, xK_m), fn 'm')
+ , ((km, xK_n), fn 'n')
+ , ((km, xK_o), fn 'o')
+ , ((km, xK_p), fn 'p')
+ , ((km, xK_q), fn 'q')
+ , ((km, xK_r), fn 'r')
+ , ((km, xK_s), fn 's')
+ , ((km, xK_t), fn 't')
+ , ((km, xK_u), fn 'u')
+ , ((km, xK_v), fn 'v')
+ , ((km, xK_w), fn 'w')
+ , ((km, xK_x), fn 'x')
+ , ((km, xK_y), fn 'y')
+ , ((km, xK_z), fn 'z')
+ ]
diff --git a/src/Internal/Layout.hs b/src/Internal/Layout.hs
new file mode 100644
index 0000000..2b35dbc
--- /dev/null
+++ b/src/Internal/Layout.hs
@@ -0,0 +1,73 @@
+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
+module Internal.Layout where
+
+import XMonad.Layout.Spiral
+import XMonad.Layout.ThreeColumns
+import XMonad.Layout.Grid
+import XMonad.Layout
+import XMonad
+
+import qualified XMonad.StackSet as W
+
+myLayout =
+ spiral (6/7) |||
+ Center 0.7 |||
+ Tall 1 (3/100) (1/2) |||
+ ThreeCol 1 (3/100) (1/2) |||
+ Grid
+
+
+data Center a =
+ Center {
+ proportion :: Float -- between 0 and 1
+ }
+ deriving (Show, Read)
+
+instance LayoutClass Center a where
+ doLayout l (Rectangle x y w h) stack =
+
+ let wf = fromIntegral w
+ hf = fromIntegral h
+ x' = (wf - wf * proportion l) / 2
+ y' = (hf - hf * proportion l) / 2
+ w' = wf * proportion l
+ h' = hf * proportion l
+ middleRect = Rectangle (floor x') (floor y') (floor w') (floor h')
+ topRect = Rectangle 0 0 (floor wf) (floor y')
+ rightRect = Rectangle (floor (x' + w')) (floor y') (floor x') (floor h')
+ bottomRect = Rectangle 0 (floor $ y' + h') (floor wf) (floor y')
+ leftRect = Rectangle 0 (floor y') (floor x') (floor h')
+
+ nWin = length (W.integrate stack)
+ winsTop = nWin `div` 8
+
+ portion = fromIntegral $ nWin `div` 6
+ winRem = fromIntegral $ nWin `mod` 6
+ in
+ return $
+ (zip (W.integrate stack) (
+ (:) middleRect $
+ (divRect topRect (portion * 2))
+ ++ (divRect rightRect portion)
+ ++ (divRect bottomRect (portion * 2))
+ ++ (divRect leftRect (portion + winRem))), Just l)
+ where
+ divRect (Rectangle x y w h) n =
+ if h > w
+ then
+ let h' = h `div` n
+ in flip map [0..(n - 1)] $ \mul ->
+ Rectangle x (y + fromIntegral (h' * mul)) w h'
+ else
+ let w' = w `div` n
+ in flip map [0..(n - 1)] $ \mul ->
+ Rectangle (x + fromIntegral (w' * mul)) y w' h
+
+ handleMessage (Center prop) m =
+ return $ fmap resize (fromMessage m)
+ where
+ resize Shrink = (Center (prop - 0.05))
+ resize Expand = (Center (prop + 0.05))
+
+
+ emptyLayout c root = return ([], Just c)
diff --git a/src/Internal/Marking.hs b/src/Internal/Marking.hs
new file mode 100644
index 0000000..352131b
--- /dev/null
+++ b/src/Internal/Marking.hs
@@ -0,0 +1,77 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+module Internal.Marking where
+
+import XMonad
+import Data.IORef
+import Data.Map (Map)
+
+import System.FilePath
+import System.IO
+import Control.Exception
+
+import qualified Data.Map as Map
+
+{- Submodule that handles marking windows so they can be jumped back to. -}
+
+type Mark = Char
+
+data MarkState =
+ MarkState {
+ markStateMap :: Map Mark Window
+ , markLast :: Maybe Window
+ } deriving (Read, Show)
+
+data MarkContext = MarkContext (IORef MarkState)
+
+readMarkState :: IO MarkState
+readMarkState = do
+ dir <- getXMonadDir
+ let markstate = dir </> "markstate"
+ catch
+ (read <$> (hGetContents =<< openFile markstate ReadMode))
+ (\(e :: IOError) -> return (MarkState mempty Nothing))
+
+saveMarkState :: MarkState -> X ()
+saveMarkState ms = do
+ dir <- getXMonadDir
+ let markstate = dir </> "markstate"
+ liftIO $ writeFile markstate (show ms)
+
+
+withNewMarkContext :: (MarkContext -> IO a) -> IO a
+withNewMarkContext fn = do
+ ioref <- newIORef =<< readMarkState
+ fn (MarkContext ioref)
+
+markCurrentWindow :: MarkContext -> Mark -> X ()
+markCurrentWindow (MarkContext ioref) mark = do
+ withFocused $ \win ->
+ liftIO $
+ modifyIORef ioref $ \state@(MarkState {markStateMap = ms}) ->
+ state {
+ markStateMap = Map.insert mark win ms
+ }
+
+ saveMarkState =<< liftIO (readIORef ioref)
+
+jumpToLast :: MarkContext -> X ()
+jumpToLast (MarkContext ioref) = do
+ withFocused $ \win -> do
+ m <- markLast <$> (liftIO $ readIORef ioref)
+ liftIO $ modifyIORef ioref (\state -> state { markLast = Just win })
+ mapM_ focus m
+
+ saveMarkState =<< liftIO (readIORef ioref)
+
+jumpToMark :: MarkContext -> Mark -> X ()
+jumpToMark (MarkContext ioref) mark = do
+ withFocused $ \win -> do
+ MarkState {markStateMap = m} <- liftIO $ readIORef ioref
+ case Map.lookup mark m of
+ Nothing -> return ()
+ Just w -> do
+ liftIO $ modifyIORef ioref $ \state ->
+ state { markLast = Just win }
+ focus w
+
+ saveMarkState =<< liftIO (readIORef ioref)
diff --git a/src/Main.hs b/src/Main.hs
new file mode 100644
index 0000000..c067b62
--- /dev/null
+++ b/src/Main.hs
@@ -0,0 +1,32 @@
+import XMonad
+import XMonad.Hooks.DynamicLog
+import XMonad.Layout.Spacing
+import XMonad.Actions.WindowNavigation
+import XMonad.Util.CustomKeys
+import System.Directory
+import System.FilePath
+import System.Process
+import Internal.Layout
+
+import Internal.Keys
+
+main = do
+ -- Execute some commands.
+ homeDir <- getHomeDirectory
+ let fp = homeDir </> ".xmonad" </> "startup"
+
+ config <-
+ applyKeys $ def
+ { terminal = "st"
+ , modMask = mod4Mask
+ , borderWidth = 0
+ , keys = \config -> mempty
+ , focusedBorderColor = "#FFFFFF"
+ , normalBorderColor = "#000000"
+ , layoutHook = spacingRaw True (Border 5 5 5 5) True (Border 5 5 5 5) True $
+ myLayout
+ , startupHook = do
+ spawn fp
+ }
+
+ xmonad =<< xmobar config { modMask = mod4Mask }
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
index 0000000..e42fa74
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,70 @@
+# This file was automatically generated by 'stack init'
+#
+# Some commonly used options have been documented as comments in this file.
+# For advanced use and comprehensive documentation of the format, please see:
+# https://docs.haskellstack.org/en/stable/yaml_configuration/
+
+# Resolver to choose a 'specific' stackage snapshot or a compiler version.
+# A snapshot resolver dictates the compiler version and the set of packages
+# to be used for project dependencies. For example:
+#
+# resolver: lts-3.5
+# resolver: nightly-2015-09-21
+# resolver: ghc-7.10.2
+#
+# The location of a snapshot can be provided as a file or url. Stack assumes
+# a snapshot provided as a file might change, whereas a url resource does not.
+#
+# resolver: ./custom-snapshot.yaml
+# resolver: https://example.com/snapshots/2018-01-01.yaml
+resolver: lts-14.22
+
+# User packages to be built.
+# Various formats can be used as shown in the example below.
+#
+# packages:
+# - some-directory
+# - https://example.com/foo/bar/baz-0.0.2.tar.gz
+# subdirs:
+# - auto-update
+# - wai
+packages:
+ - .
+
+# dependencies:
+# - xmonad
+# - xmonad-contrib
+# Dependency packages to be pulled from upstream that are not in the resolver.
+# These entries can reference officially published versions as well as
+# forks / in-progress versions pinned to a git hash. For example:
+#
+# extra-deps:
+# - acme-missiles-0.3
+# - git: https://github.com/commercialhaskell/stack.git
+# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
+#
+# extra-deps: []
+
+# Override default flag values for local packages and extra-deps
+# flags: {}
+
+# Extra package databases containing global packages
+# extra-package-dbs: []
+
+# Control whether we use the GHC we find on the path
+# system-ghc: true
+#
+# Require a specific version of stack, using version ranges
+# require-stack-version: -any # Default
+# require-stack-version: ">=2.1"
+#
+# Override the architecture used by stack, especially useful on Windows
+# arch: i386
+# arch: x86_64
+#
+# Extra directories used by stack for building
+# extra-include-dirs: [/path/to/dir]
+# extra-lib-dirs: [/path/to/dir]
+#
+# Allow a newer minor version of GHC than the snapshot specifies
+# compiler-check: newer-minor
diff --git a/startup b/startup
new file mode 100755
index 0000000..a161685
--- /dev/null
+++ b/startup
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Switch the displays around because the default state is for them to be reversed.
+xrandr --output DVI-I-1 --right-of DP-5 --mode 2560x1440
+
+# Change the background image using 'feh'
+feh --bg-scale ~/Downloads/marco-xu-zcvWUNrmPBQ-unsplash.jpg
+
+# Increase the kebyoard repeat rate and decrease the repeat time.
+xset r rate 200 60
+
+# Run the screensaver so I can lock it.
+nohup xscreensaver & > /dev/null
+
+# Run a compositer to make things a little prettier.
+nohup compton & > /dev/null
diff --git a/xmobarrc b/xmobarrc
new file mode 100644
index 0000000..605086f
--- /dev/null
+++ b/xmobarrc
@@ -0,0 +1,9 @@
+Config {
+ font = "xft:Lato"
+ , position = Top
+ , bgColor = "#202020"
+ , border = BottomB
+ , borderColor = "#202020"
+ , borderWidth = 4
+ , lowerOnStart = True
+}