initial commit
This commit is contained in:
commit
94120dde27
6 changed files with 190 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.stack-work/
|
3
Setup.lhs
Normal file
3
Setup.lhs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env runhaskell
|
||||||
|
> import Distribution.Simple
|
||||||
|
> main = defaultMain
|
64
src/XMonad/Custom/BasicKeyBindings.hs
Normal file
64
src/XMonad/Custom/BasicKeyBindings.hs
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
module XMonad.Custom.BasicKeyBindings (myBasicKeyBindings) where
|
||||||
|
|
||||||
|
import System.Exit
|
||||||
|
|
||||||
|
import XMonad
|
||||||
|
import qualified XMonad.StackSet as W
|
||||||
|
|
||||||
|
import XMonad.Custom.BindingUtils
|
||||||
|
|
||||||
|
myBasicKeyBindings :: [([Char], X ())]
|
||||||
|
myBasicKeyBindings = addMainModifierToBinding $ myFocusBindings ++ mySwapBindings ++ myMasterBindings ++ myXMonadBindings ++ myLaunchBindings
|
||||||
|
|
||||||
|
myLaunchBindings :: [([Char], X ())]
|
||||||
|
myLaunchBindings = [
|
||||||
|
("<Return>", spawn "kitty"),
|
||||||
|
("r", spawn "dmenu_run"),
|
||||||
|
("S-r", spawn "gmrun"),
|
||||||
|
("x", kill),
|
||||||
|
("S-x", kill)
|
||||||
|
]
|
||||||
|
|
||||||
|
myFocusBindings :: [([Char], X ())]
|
||||||
|
myFocusBindings = addWindowsToBinding $ [
|
||||||
|
("n", W.focusUp),
|
||||||
|
("d", W.focusDown),
|
||||||
|
("<U>", W.focusUp),
|
||||||
|
("<D>", W.focusDown),
|
||||||
|
("m", W.focusMaster),
|
||||||
|
("<Tab>", W.focusDown),
|
||||||
|
("S-<Tab>", W.focusUp)
|
||||||
|
]
|
||||||
|
|
||||||
|
mySwapBindings :: [([Char], X ())]
|
||||||
|
mySwapBindings = addShiftToBinding . addWindowsToBinding $ [
|
||||||
|
("n", W.swapUp),
|
||||||
|
("d", W.swapDown),
|
||||||
|
("<U>", W.swapUp),
|
||||||
|
("<D>", W.swapDown),
|
||||||
|
("m", W.swapMaster)
|
||||||
|
]
|
||||||
|
|
||||||
|
myMasterBindings :: [([Char], X ())]
|
||||||
|
myMasterBindings = [
|
||||||
|
(",", incMasterWindows),
|
||||||
|
(".", decMasterWindows)
|
||||||
|
] ++ (addShiftToBinding $ [
|
||||||
|
(",", expandMasterSpace),
|
||||||
|
(".", shrinkMasterSpace)
|
||||||
|
])
|
||||||
|
where
|
||||||
|
incMasterWindows = adjMasterWindows 1
|
||||||
|
decMasterWindows = adjMasterWindows (-1)
|
||||||
|
adjMasterWindows n = sendMessage (IncMasterN n)
|
||||||
|
expandMasterSpace = sendMessage Expand
|
||||||
|
shrinkMasterSpace = sendMessage Shrink
|
||||||
|
|
||||||
|
myXMonadBindings :: [([Char], X ())]
|
||||||
|
myXMonadBindings = [
|
||||||
|
("q", restartXMonad),
|
||||||
|
("S-q", quitXMonad)
|
||||||
|
]
|
||||||
|
where
|
||||||
|
restartXMonad = spawn "if type xmonad; then xmonad --recompile && xmonad --restart; else xmessage xmonad not in \\$PATH: \"$PATH\"; fi"
|
||||||
|
quitXMonad = io exitSuccess
|
20
src/XMonad/Custom/BindingUtils.hs
Normal file
20
src/XMonad/Custom/BindingUtils.hs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module XMonad.Custom.BindingUtils where
|
||||||
|
|
||||||
|
import GHC.Utils.Misc
|
||||||
|
|
||||||
|
import XMonad
|
||||||
|
|
||||||
|
addWindowsToBinding :: [(a, WindowSet -> WindowSet)] -> [(a, X ())]
|
||||||
|
addWindowsToBinding = mapSnd $ \action -> windows action
|
||||||
|
|
||||||
|
addShiftToBinding :: [([Char], b)] -> [([Char], b)]
|
||||||
|
addShiftToBinding = addModifierToBinding "S"
|
||||||
|
|
||||||
|
addMainModifierToBinding :: [([Char], b)] -> [([Char], b)]
|
||||||
|
addMainModifierToBinding = addModifierToBinding "M"
|
||||||
|
|
||||||
|
addModifierToBinding :: [Char] -> [([Char], b)] -> [([Char], b)]
|
||||||
|
addModifierToBinding modifier = mapFst $ \key -> modifier ++ "-" ++ key
|
||||||
|
|
||||||
|
addSubMapKey :: [Char] -> [([Char], b)] -> [([Char], b)]
|
||||||
|
addSubMapKey key = mapFst $ \subkey -> key ++ " " ++ subkey
|
84
src/XMonad/Custom/UniversitySetup.hs
Normal file
84
src/XMonad/Custom/UniversitySetup.hs
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
module XMonad.Custom.UniversitySetup (myUniversitySetupKeyBindings) where
|
||||||
|
|
||||||
|
import XMonad
|
||||||
|
|
||||||
|
import GHC.Utils.Misc -- for MapFst, MapSnd
|
||||||
|
|
||||||
|
import XMonad.Custom.BindingUtils
|
||||||
|
|
||||||
|
scriptDir :: String
|
||||||
|
scriptDir = "/home/maximilian/Uni/scripts"
|
||||||
|
|
||||||
|
myUniversitySetupKeyBindings :: [(String, X ())]
|
||||||
|
myUniversitySetupKeyBindings = addMainModifierToBinding . (addSubMapKey myUniversityKey) $ concat myUniversitySetupKeyBindingsRaw
|
||||||
|
where
|
||||||
|
myUniversityKey = "u"
|
||||||
|
|
||||||
|
myUniversitySetupKeyBindingsRaw :: [[(String, X ())]]
|
||||||
|
myUniversitySetupKeyBindingsRaw =
|
||||||
|
map addUniversitySetupScript [ -- prepend scriptPath
|
||||||
|
myMainBindingsScriptNames,
|
||||||
|
addSubMapKey myExerciseOpenKey myExerciseOpenScriptNames -- add to exercises submap
|
||||||
|
]
|
||||||
|
++
|
||||||
|
zipWith addUniversitySetupScriptArg [myCourseOpenScript, myExerciseOpenScript] -- prepend (fixed) open scripts and forward selected argument
|
||||||
|
[
|
||||||
|
addSubMapKey myCourseOpenKey myCourseOpenArguments, -- add to course open submap
|
||||||
|
addSubMapKey myExerciseOpenKey myExerciseOpenArguments -- add to exercises submap
|
||||||
|
]
|
||||||
|
where
|
||||||
|
myCourseOpenKey = "o"
|
||||||
|
myExerciseOpenKey = "e"
|
||||||
|
myCourseOpenScript = "open"
|
||||||
|
myExerciseOpenScript = "rofi-exercises"
|
||||||
|
|
||||||
|
addUniversitySetupScript :: [(a, String)] -> [(a, X ())]
|
||||||
|
addUniversitySetupScript = mapSnd universitySetupScript
|
||||||
|
|
||||||
|
addUniversitySetupScriptArg :: String -> [(a, String)] -> [(a, X ())]
|
||||||
|
addUniversitySetupScriptArg script = mapSnd (universitySetupScriptArg script)
|
||||||
|
|
||||||
|
universitySetupScript :: String -> X()
|
||||||
|
universitySetupScript filename = spawn $ scriptDir ++ "/" ++ filename ++ ".py"
|
||||||
|
|
||||||
|
universitySetupScriptArg :: String -> String -> X()
|
||||||
|
universitySetupScriptArg filename arg = spawn $ scriptDir ++ "/" ++ filename ++ ".py " ++ arg
|
||||||
|
|
||||||
|
|
||||||
|
-- Bindings after M-<myUniversityKey>, listing executed script name
|
||||||
|
myMainBindingsScriptNames :: [(String, String)]
|
||||||
|
myMainBindingsScriptNames = [
|
||||||
|
("c", "rofi-courses"),
|
||||||
|
("l", "rofi-lectures"),
|
||||||
|
("v", "rofi-lectures-view"),
|
||||||
|
("n", "new-lecture"),
|
||||||
|
("m", "compile_all_full_versions")
|
||||||
|
]
|
||||||
|
|
||||||
|
-- Bindings after M-<myUniversityKey> <myCourseOpenKey>, listing argument given to <myCourseOpenScript>
|
||||||
|
myCourseOpenArguments :: [(String, String)]
|
||||||
|
myCourseOpenArguments = [
|
||||||
|
("m", "master"),
|
||||||
|
("f", "full"),
|
||||||
|
("w", "webpage"),
|
||||||
|
("e", "ecampus"),
|
||||||
|
("s", "sciebo"),
|
||||||
|
("g", "github"),
|
||||||
|
("b", "basis"),
|
||||||
|
("t", "terminal")
|
||||||
|
]
|
||||||
|
|
||||||
|
-- Bindings after M-<myUniversityKey> <myExerciseOpenKey>, listing argument given to <myExerciseOpenScript>
|
||||||
|
myExerciseOpenArguments :: [(String, String)]
|
||||||
|
myExerciseOpenArguments = [
|
||||||
|
("s", "solution"),
|
||||||
|
("i", "sheet"),
|
||||||
|
("w", "writeup"),
|
||||||
|
("e", "writeup")
|
||||||
|
]
|
||||||
|
|
||||||
|
-- Bindings after M-<myUniversityKey> <myExerciseOpenKey>, listing executed script name
|
||||||
|
myExerciseOpenScriptNames :: [(String, String)]
|
||||||
|
myExerciseOpenScriptNames = [
|
||||||
|
("n", "new-writeup")
|
||||||
|
]
|
18
xmonad-custom.cabal
Normal file
18
xmonad-custom.cabal
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
name: xmonad-custom
|
||||||
|
version: 1.0
|
||||||
|
cabal-version: 1.12
|
||||||
|
|
||||||
|
flag pedantic
|
||||||
|
description: Be pedantic (-Werror and the like)
|
||||||
|
default: False
|
||||||
|
manual: True
|
||||||
|
|
||||||
|
library
|
||||||
|
exposed-modules: XMonad.Custom.UniversitySetup
|
||||||
|
XMonad.Custom.BasicKeyBindings
|
||||||
|
XMonad.Custom.BindingUtils
|
||||||
|
hs-source-dirs: src
|
||||||
|
ghc-options: -funbox-strict-fields -Wall -Wno-unused-do-bind
|
||||||
|
build-depends: base
|
||||||
|
, xmonad
|
||||||
|
, ghc
|
Loading…
Reference in a new issue