Compare commits

..

3 Commits

Author SHA1 Message Date
d5c86cddee Enable unstable tests 2019-03-21 22:27:26 +02:00
5041d5bf99 hlint rules 2019-03-21 22:26:47 +02:00
c3d5eaed3e Bump base 2019-03-21 22:19:57 +02:00
6 changed files with 17 additions and 13 deletions

View File

@ -13,7 +13,9 @@ matrix:
- NIXPKGS=https://github.com/NixOS/nixpkgs-channels/archive/nixos-18.09.tar.gz - NIXPKGS=https://github.com/NixOS/nixpkgs-channels/archive/nixos-18.09.tar.gz
- env: - env:
- NIXPKGS=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz - NIXPKGS=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz
- env:
- NIXPKGS=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz
script: script:
# - nix run nixpkgs.haskellPackages.hlint -c hlint src - nix run nixpkgs.haskellPackages.hlint -c hlint src
- nix build -I nixpkgs=$NIXPKGS -f ./release.nix xmonad-masser - nix build -I nixpkgs=$NIXPKGS -f ./release.nix xmonad-masser

View File

@ -184,7 +184,7 @@ myKeys extraConfig conf =
, ("M-n", scratchSubmaps conf) , ("M-n", scratchSubmaps conf)
, ("M-s", searchSubmaps conf) , ("M-s", searchSubmaps conf)
, ("M-p", addName "Retrieve password" $ passPrompt def) , ("M-p", addName "Retrieve password" $ passPrompt def)
, ("M-S-e", addName "Open with app" xdg_open) , ("M-S-e", addName "Open with app" xdgOpen)
, ("M-e", addName "Run app" $ runOrRaisePrompt def)] ^++^ , ("M-e", addName "Run app" $ runOrRaisePrompt def)] ^++^
subKeys "Windows" [ ("M-j", addName "Go down" $ windowGo D False) subKeys "Windows" [ ("M-j", addName "Go down" $ windowGo D False)
, ("M-k", addName "Go up" $ windowGo U False) , ("M-k", addName "Go up" $ windowGo U False)

View File

@ -1,4 +1,4 @@
module XMonad.CustomPrompt (xdg_open, browser) where module XMonad.CustomPrompt (xdgOpen, browser) where
import qualified XMonad.Prompt.AppLauncher as AL import qualified XMonad.Prompt.AppLauncher as AL
import XMonad.Prompt import XMonad.Prompt
@ -7,8 +7,8 @@ import XMonad (X)
launchApp :: AL.Application -> X () launchApp :: AL.Application -> X ()
launchApp = AL.launchApp def launchApp = AL.launchApp def
xdg_open :: X () xdgOpen :: X ()
xdg_open = launchApp "xdg-open" xdgOpen = launchApp "xdg-open"
browser :: X () browser :: X ()
browser = launchApp "qutebrowser" browser = launchApp "qutebrowser"

View File

@ -10,7 +10,7 @@ import XMonad.Core
import XMonad.Prompt import XMonad.Prompt
import XMonad.Util.Run (runProcessWithInput) import XMonad.Util.Run (runProcessWithInput)
data Pass = Pass { passLabel :: String } newtype Pass = Pass { passLabel :: String }
-- Rosetta code levenshtein -- Rosetta code levenshtein
levenshtein :: String -> String -> Int levenshtein :: String -> String -> Int
@ -37,7 +37,7 @@ mkPassPrompt label f conf = do
-- I'm just sorting here, but could use some kind of fuzzy matching instead, but it requires a bit more effort -- I'm just sorting here, but could use some kind of fuzzy matching instead, but it requires a bit more effort
passwords <- sort <$> liftIO getPasswords passwords <- sort <$> liftIO getPasswords
-- Other change, use infixof instead of prefixof -- Other change, use infixof instead of prefixof
mkXPrompt (Pass label) conf (\input -> pure (sortBy (compare `on` (levenshtein input)) . filter (consumes input) $ passwords)) f mkXPrompt (Pass label) conf (\input -> pure (sortBy (compare `on` levenshtein input) . filter (consumes input) $ passwords)) f
where where
consumes [] _ = True -- everything consumed consumes [] _ = True -- everything consumed
consumes (_:_) [] = False -- all not consumed consumes (_:_) [] = False -- all not consumed

View File

@ -1,7 +1,8 @@
{-# LANGUAGE TupleSections #-}
module XMonad.TopicUtils where module XMonad.TopicUtils where
import Data.Maybe (fromMaybe, listToMaybe, mapMaybe) import Data.Maybe (fromMaybe, listToMaybe, mapMaybe)
import Data.List (isPrefixOf, sort, nub) import Data.List (isPrefixOf, nub, sortOn)
import XMonad.Actions.TopicSpace import XMonad.Actions.TopicSpace
import XMonad import XMonad
import qualified Data.Map as M import qualified Data.Map as M
@ -11,6 +12,7 @@ import qualified XMonad.StackSet as W
import XMonad.Util.Dmenu (dmenu) import XMonad.Util.Dmenu (dmenu)
import XMonad.Actions.DynamicWorkspaces import XMonad.Actions.DynamicWorkspaces
import XMonad.Util.NamedWindows (getName) import XMonad.Util.NamedWindows (getName)
import Data.Ord
realTopicDir :: M.Map String FilePath -> X String realTopicDir :: M.Map String FilePath -> X String
@ -58,7 +60,7 @@ gridselectCurrentWindows :: GSConfig Window -> X (Maybe Window)
gridselectCurrentWindows gsconf = windowMap >>= gridselect gsconf gridselectCurrentWindows gsconf = windowMap >>= gridselect gsconf
where where
getName' = fmap show . getName getName' = fmap show . getName
kvPair w = flip (,) w `fmap` getName' w kvPair w = (, w) <$> getName' w
windowMap = do windowMap = do
ws <- gets (nub . W.integrate' . W.stack . W.workspace . W.current . windowset) ws <- gets (nub . W.integrate' . W.stack . W.workspace . W.current . windowset)
mapM kvPair ws mapM kvPair ws
@ -78,11 +80,11 @@ currentTopicAction' tg = do
copyTopic :: X () copyTopic :: X ()
copyTopic = do copyTopic = do
currentTopic <- realTopic currentTopic <- realTopic
lastN <- gets (listToMaybe . reverse . sort . mapMaybe (subset currentTopic . W.tag) . W.workspaces . windowset) lastN <- gets (listToMaybe . sortOn Down . mapMaybe (subset currentTopic . W.tag) . W.workspaces . windowset)
addWorkspace (currentTopic ++ ":" ++ (show $ maybe 2 (+1) lastN)) addWorkspace (currentTopic ++ ":" ++ show (maybe 2 (+1) lastN))
where where
subset :: String -> String -> Maybe Int subset :: String -> String -> Maybe Int
subset topic other = if topic `isPrefixOf` other then (readM $ tail' $ snd $ break (== ':') other) else Nothing subset topic other = if topic `isPrefixOf` other then readM $ tail' $ dropWhile (/= ':') other else Nothing
readM a = case reads a of readM a = case reads a of
[(x,_)] -> Just x [(x,_)] -> Just x
_ -> Nothing _ -> Nothing

View File

@ -25,7 +25,7 @@ library
, XMonad.TopicSpace , XMonad.TopicSpace
, XMonad.XMobar , XMonad.XMobar
-- other-extensions: -- other-extensions:
build-depends: base >=4.11 && <4.12 build-depends: base >=4.11 && <4.13
, xmonad , xmonad
, xmonad-contrib , xmonad-contrib
, mtl , mtl