From 90fd606fb31f033373a3bd40030f19e5a1d586a0 Mon Sep 17 00:00:00 2001 From: qvalentin Date: Tue, 21 Sep 2021 10:59:13 +0200 Subject: [PATCH] initial project setup --- .gitignore | 23 ++++++++ .gitmodules | 6 +++ hie.yaml | 22 ++++++++ package.yaml | 40 ++++++++++++++ src/Lib.hs | 6 +++ stack.yaml | 69 ++++++++++++++++++++++++ stack.yaml.lock | 13 +++++ xmonad | 1 + xmonad-contrib | 1 + xmonad-qv.cabal | 44 +++++++++++++++ xmonad.hs | 138 ++++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 363 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 hie.yaml create mode 100644 package.yaml create mode 100644 src/Lib.hs create mode 100644 stack.yaml create mode 100644 stack.yaml.lock create mode 160000 xmonad create mode 160000 xmonad-contrib create mode 100644 xmonad-qv.cabal create mode 100644 xmonad.hs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c9e245 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +dist +dist-* +cabal-dev +*.o +*.hi +*.hie +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +.stack-work/ +cabal.project.local +cabal.project.local~ +.HTF/ +.ghc.environment.* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0bb7f03 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "xmonad"] + path = xmonad + url = https://github.com/xmonad/xmonad +[submodule "xmonad-contrib"] + path = xmonad-contrib + url = https://github.com/xmonad/xmonad-contrib diff --git a/hie.yaml b/hie.yaml new file mode 100644 index 0000000..44756ad --- /dev/null +++ b/hie.yaml @@ -0,0 +1,22 @@ +cradle: + stack: + - path: "xmonad/src" + component: "xmonad:lib" + + - path: "xmonad/./Main.hs" + component: "xmonad:exe:xmonad" + + - path: "xmonad/tests" + component: "xmonad:test:properties" + + - path: "xmonad-contrib/./" + component: "xmonad-contrib:lib" + + - path: "xmonad-contrib/tests" + component: "xmonad-contrib:test:tests" + + - path: "xmonad-contrib/." + component: "xmonad-contrib:test:tests" + + - path: "././xmonad.hs" + component: "xmonad-qv:lib" diff --git a/package.yaml b/package.yaml new file mode 100644 index 0000000..bc6807c --- /dev/null +++ b/package.yaml @@ -0,0 +1,40 @@ +--- +name: xmonad-qv +version: "0.1.0.0" +github: "qvalentin/xmonad" +license: GPL-3.0 +author: "qvalentin" +maintainer: "qvalentin" +copyright: "GPL-3.0" + +description: My xmonad Configuration + +dependencies: + - base >= 4.7 && < 5 + - xmonad + - xmonad-contrib + +ghc-options: + - -Wall + - -Wcompat + - -Wincomplete-record-updates + - -Wincomplete-uni-patterns + - -Wredundant-constraints + +library: + source-dirs: src + +executable: + main: xmonad.hs + other-modules: [] + ghc-options: + - -i + - -ilib + - -v0 + - -O2 + - -threaded + - -rtsopts + - -with-rtsopts=-N + - -Wall + dependencies: + - xmonad-qv diff --git a/src/Lib.hs b/src/Lib.hs new file mode 100644 index 0000000..d36ff27 --- /dev/null +++ b/src/Lib.hs @@ -0,0 +1,6 @@ +module Lib + ( someFunc + ) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..ac065f6 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,69 @@ +# 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: + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/10.yaml + +# 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: +- . +- 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.7" +# +# 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: [/home/qv/.config/xmonad/Lib] +#extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor diff --git a/stack.yaml.lock b/stack.yaml.lock new file mode 100644 index 0000000..fa94efb --- /dev/null +++ b/stack.yaml.lock @@ -0,0 +1,13 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +snapshots: +- original: + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/10.yaml + completed: + sha256: 88b4f81e162ba3adc230a9fcccc4d19ac116377656bab56c7382ca88598b257a + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/10.yaml + size: 587546 +packages: [] diff --git a/xmonad b/xmonad new file mode 160000 index 0000000..33a86c0 --- /dev/null +++ b/xmonad @@ -0,0 +1 @@ +Subproject commit 33a86c0cdb9aa481e23cc5527a997adef5e32d42 diff --git a/xmonad-contrib b/xmonad-contrib new file mode 160000 index 0000000..0c6fdf4 --- /dev/null +++ b/xmonad-contrib @@ -0,0 +1 @@ +Subproject commit 0c6fdf4e75dd4d31bc8423010fbabbab7c23ee03 diff --git a/xmonad-qv.cabal b/xmonad-qv.cabal new file mode 100644 index 0000000..4af3fe6 --- /dev/null +++ b/xmonad-qv.cabal @@ -0,0 +1,44 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.34.4. +-- +-- see: https://github.com/sol/hpack + +name: xmonad-qv +version: 0.1.0.0 +description: My xmonad Configuration +homepage: https://github.com/qvalentin/xmonad#readme +bug-reports: https://github.com/qvalentin/xmonad/issues +author: qvalentin +maintainer: qvalentin +copyright: GPL-3.0 +license: GPL-3.0 +build-type: Simple + +source-repository head + type: git + location: https://github.com/qvalentin/xmonad + +library + exposed-modules: + Lib + other-modules: + Paths_xmonad_qv + hs-source-dirs: + src + ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints + build-depends: + base >=4.7 && <5 + , xmonad + , xmonad-contrib + default-language: Haskell2010 + +executable xmonad-qv + main-is: xmonad.hs + ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -i -ilib -v0 -O2 -threaded -rtsopts -with-rtsopts=-N -Wall + build-depends: + base >=4.7 && <5 + , xmonad + , xmonad-contrib + , xmonad-qv + default-language: Haskell2010 diff --git a/xmonad.hs b/xmonad.hs new file mode 100644 index 0000000..13a0d98 --- /dev/null +++ b/xmonad.hs @@ -0,0 +1,138 @@ +import Control.Monad (liftM2) +import qualified Data.Monoid +import XMonad +import XMonad.Actions.WindowGo +import XMonad.Hooks.DynamicLog +import XMonad.Hooks.EwmhDesktops +import XMonad.Hooks.StatusBar +import qualified XMonad.Layout.LayoutModifier +import XMonad.Layout.Spacing +import XMonad.Layout.WindowNavigation +import XMonad.StackSet (Workspace (tag), currentTag, integrate', stack, greedyView, shift) +import XMonad.Util.EZConfig +import XMonad.Util.Loggers +import XMonad.Util.SpawnOnce +import XMonad.Util.Ungrab +import XMonad.Util.WorkspaceCompare (getSortByIndex) +import XMonad.Hooks.InsertPosition (insertPosition, Position(Master, End), Focus (Newer)) + +main :: IO () +main = do + colors <- getWalColors + xmonad . ewmhFullscreen . ewmh + . withEasySB (statusBarProp "xmobar ~/.config/xmobar/xmobarrc" (pure $ myXmobarPP colors)) defToggleStrutsKey + $ def + { modMask = mod4Mask, + terminal = "st", + startupHook = myStartupHook, + normalBorderColor = colors !! 10, + focusedBorderColor = colors !! 12, + workspaces = myWorkspaces, + manageHook = myManageHook, + layoutHook = myLayout + } + `additionalKeysP` [ ("M-S-z", spawn "xscreensaver-command -lock"), + ("M-S-s", unGrab *> spawn "scrot -s"), + ("M-f", runOrRaise "brave" (className =? "Brave-browser")), + -- audio settings + ("", spawn "amixer set Master 5%- unmute"), + ("", spawn "amixer set Master 5%+ unmute"), + ("", spawn "amixer set Master toggle"), + -- window navigation + ("M-l", sendMessage $ Go R), + ("M-h", sendMessage $ Go L) + ] + +myXmobarPP :: [String] -> PP +myXmobarPP colors = + def + { ppSep = magenta " • ", + ppTitleSanitize = xmobarStrip, + ppCurrent = wrap " " "" . xmobarBorder "Top" "#8be9fd" 2, + ppHidden = white . wrap " " "", + ppHiddenNoWindows = white . wrap " " "", + ppUrgent = red . wrap (yellow "!") (yellow "!"), + ppOrder = \[ws, l, _, wins] -> [ws, l, wins], + ppExtras = [logTitles formatFocused formatUnfocused], + ppSort = hideWorkspaces + } + where + formatFocused = wrap (white "[") (white "]") . (xmobarColor (colors !! 7) "") . ppWindow + formatUnfocused = wrap (lowWhite "[") (lowWhite "]") . (xmobarColor (colors !! 4) "") . ppWindow + + ppWindow :: String -> String + ppWindow = xmobarRaw . (\w -> if null w then "untitled" else w) . shorten 30 + + blue, lowWhite, magenta, red, white, yellow :: String -> String + magenta = xmobarColor "#ff79c6" "" + blue = xmobarColor "#bd93f9" "" + white = xmobarColor "#f8f8f2" "" + yellow = xmobarColor "#f1fa8c" "" + red = xmobarColor "#ff5555" "" + lowWhite = xmobarColor "#bbbbbb" "" + hideWorkspaces = do + sortByIndex <- getSortByIndex + wsfilter <- thefilter + return (wsfilter . sortByIndex) + where + thefilter :: X ([WindowSpace] -> [WindowSpace]) + --thefilter = filter ( not . isEmptyWs) . sortworkspaces + thefilter = do + currentWS <- withWindowSet (pure . currentTag) + return $ reverse . dropWhile (liftM2 (&&) ((currentWS /=) . tag) isEmptyWs) . reverse + where + isEmptyWs workspace = null $ integrate' $ stack workspace + +myStartupHook :: X () +myStartupHook = do + spawnOnce "picom &" + spawnOnce "sh $HOME/.fehbg" + +getWalColors :: IO [String] +getWalColors = do + let file = "/home/qv/.cache/wal/colors" + contents <- readFile file + let colors = lines contents + return (colors ++ replicate (16 - length colors) "#000000") + +mySpacing' :: Integer -> l a -> XMonad.Layout.LayoutModifier.ModifiedLayout Spacing l a +mySpacing' i = spacingRaw True (Border i i i i) True (Border i i i i) True + +--myWorkspaces = [" dev ", " www ", " sys ", " doc ", " vbox ", " chat ", " mus ", " vid ", " gfx "] +myWorkspaces :: [String] +myWorkspaces = show <$> [1 .. 9] + + +myLayout = windowNavigation tiled ||| Mirror tiled ||| Full + where + tiled = mySpacing' 8 $ Tall nmaster delta ratio + nmaster = 1 -- Default number of windows in the master pane + ratio = 1/2 -- Default proportion of screen occupied by master pane + delta = 3/100 -- Percent of screen to increment by when resizing panes + +myManageHook :: XMonad.Query (Data.Monoid.Endo WindowSet) +myManageHook = + composeAll + -- 'doFloat' forces a window to float. Useful for dialog boxes and such. + -- using 'doShift ( myWorkspaces !! 7)' sends program to workspace 8! + -- I'm doing it this way because otherwise I would have to write out the full + -- name of my workspaces and the names would be very long if using clickable workspaces. + [ className =? "confirm" --> doFloat, + className =? "file_progress" --> doFloat, + className =? "dialog" --> doFloat, + className =? "download" --> doFloat, + className =? "error" --> doFloat, + className =? "Gimp" --> doFloat, + className =? "notification" --> doFloat, + className =? "pinentry-gtk-2" --> doFloat, + className =? "splash" --> doFloat, + className =? "toolbar" --> doFloat, + title =? "Oracle VM VirtualBox Manager" --> doFloat, + title =? "Mozilla Firefox" --> viewShift (myWorkspaces !! 1), + title =? "Signal" --> viewShift (myWorkspaces !! 2), + className =? "TelegramDesktop" --> viewShift (myWorkspaces !! 2), + className =? "Gimp" --> doShift (myWorkspaces !! 8), + className =? "VirtualBox Manager" --> doShift (myWorkspaces !! 4), + (className =? "firefox" <&&> resource =? "Dialog") --> doFloat -- Float Firefox Dialog + ] <+> insertPosition End Newer + where viewShift = doF . liftM2 (.) greedyView shift