From 088f52a3163b96be53e702d50501424d56e4de56 Mon Sep 17 00:00:00 2001 From: eeva Date: Sat, 26 May 2018 18:08:13 +0300 Subject: [PATCH] spring refactor no more Bar bullshit, introducing dynamic projects --- .gitignore | 6 ++++++ lib/KeyBindings.hs | 14 ++++++-------- lib/Projects.hs | 22 ++++++++++++++++++++++ xmonad.hs | 31 +++++++++---------------------- 4 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 lib/Projects.hs diff --git a/.gitignore b/.gitignore index 1422057..c7fd0c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ +.*.swp +artwork/ *.hi *.o +prompt-history +xmonad-x86_64-linux +xmonad.errors +xmonad.state diff --git a/lib/KeyBindings.hs b/lib/KeyBindings.hs index 67f37dd..93cc16c 100644 --- a/lib/KeyBindings.hs +++ b/lib/KeyBindings.hs @@ -9,6 +9,7 @@ import System.Exit import Text.EditDistance import XMonad import XMonad.Actions.CycleWS +import XMonad.Actions.DynamicProjects import XMonad.Actions.GridSelect import XMonad.Core import XMonad.Layout.ToggleLayouts @@ -42,18 +43,15 @@ modify conf = conf , ("M-S-", spawn "/run/current-system/sw/bin/i3lock-fancy -g -p") , ("M-S-", shiftToPrev >> prevWS) , ("M-S-", shiftToNext >> nextWS) - , ("M-S-p", shellPrompt promptConfig) , ("M-S-s", spawn "sleep 0.2 ; /run/current-system/sw/bin/scrot -s /tmp/screenSel.png") - --, ("M-p", fuzzyPrompt promptConfig) - , ("M-p", goToSelected defaultGSConfig) , ("M-s", spawn "/run/current-system/sw/bin/scrot /tmp/screen.png") + -- Workspace and tasks + , ("M-p v", gridselectWorkspace defaultGSConfig W.view) + , ("M-p n", switchProjectPrompt promptConfig) + , ("M-p m", shiftToProjectPrompt promptConfig) + , ("M-p s", shellPrompt promptConfig) ] - `additionalKeys`-- Add some more (automatic) key bindings: - [ ((mod4Mask .|. mask, key), windows $ actionWith tag) - | (tag, key) <- zip (workspaces conf) [ xK_F1 .. ] - , (mask, actionWith) <- zip [ 0, shiftMask ] [ W.view, W.shift ] ] - promptConfig = def { position = Top , alwaysHighlight = True diff --git a/lib/Projects.hs b/lib/Projects.hs new file mode 100644 index 0000000..3e8184e --- /dev/null +++ b/lib/Projects.hs @@ -0,0 +1,22 @@ +module Projects ( + Projects.modify +) where + +import XMonad +import XMonad.Actions.DynamicProjects + +projects :: [Project] +projects = [ Project { projectName = "games" + , projectDirectory = "~/" + , projectStartHook = Nothing + } + , Project { projectName = "web" + , projectDirectory = "~/" + , projectStartHook = Nothing + } + ] + +modify :: XConfig l -> XConfig l +modify conf = dynamicProjects projects conf + { workspaces = ["games", "web"] } + diff --git a/xmonad.hs b/xmonad.hs index 1c478c6..7aa0931 100755 --- a/xmonad.hs +++ b/xmonad.hs @@ -5,6 +5,7 @@ module Main (main) where import XMonad +import XMonad.Actions.DynamicProjects import XMonad.Config.Desktop import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageHelpers @@ -16,22 +17,9 @@ import XMonad.Util.EZConfig import qualified Solarized as S -- Tidy modules -import StatusBar as Bar (modify) import KeyBindings as Keys (modify) import MouseBindings as Mouse (modify) - --------- A list of my usual workspaces (with some FontAwesome & xmobar format) -wkspcs = [ wrap "" "" "\xF0E0" --  email - , wrap "" "" "\xF086" --  chat - , wrap "" "" "\xF120" --  work - , wrap "" "" "\xF1B6" --  game - , wrap "" "" "\xF11B" --  game - , wrap "" "" "\xF09C" --  password - , wrap "" "" "\xF16C" --  web work - , wrap "" "" "\xF025" --  sound - , wrap "" "" "\xF269" --  web perso - , wrap "" "" "\xF03D" --  movie - ] +import Projects as Projects (modify) --------- toggle btw vvvvvvvvvv or vvvvv layouts = toggleLayouts fullscreen tiled @@ -45,12 +33,12 @@ layouts = toggleLayouts fullscreen tiled -- For className, use the second value that xprop gives you. -------------- Here be the law of windows myManageHook = composeOne - [ className =? "mpv" -?> doFullFloat <+> (doShift $ last wkspcs) - , className =? "Pinentry" -?> doFloat - , className =? "Steam" -?> doShift $ wkspcs !! 3 - , className =? "csgo_linux64" -?> doFullFloat - , className =? "Pavucontrol" -?> doShift $ wkspcs !! 7 - , className =? "qutebrowser" -?> doShift $ wkspcs !! 5 + [ className =? "Pinentry" -?> doFloat + , className =? "mpv" -?> doFullFloat <+> (doShift "Flims") + , className =? "Steam" -?> doShift "Steam" + , className =? "csgo_linux64" -?> doFullFloat <+> (doShift "CSGO") + , className =? "Pavucontrol" -?> doShift "Music" + , className =? "qutebrowser" -?> doShift "Web Perso" , isDialog -?> doCenterFloat -- Move transient windows to their parent: @@ -59,14 +47,13 @@ myManageHook = composeOne ------------ build the full config withConfig = - Bar.modify -- Apply statusBar config + Projects.modify -- Apply projects config $ Keys.modify -- Apply keybindings config $ Mouse.modify -- Apply mouse bindings config $ desktopConfig -- on a default desktop config { manageHook = myManageHook <+> manageHook desktopConfig , layoutHook = desktopLayoutModifiers layouts , terminal = "/run/current-system/sw/bin/alacritty" - , workspaces = wkspcs , normalBorderColor = S.base03 , focusedBorderColor = S.violet , borderWidth = 5