From a2d9de37d6a5fbdec27f27c4460606f15928a772 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Fri, 25 Jun 2021 00:04:50 -0400 Subject: [PATCH] ADD virtual profiles to autorander --- app/rofi-autorandr.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/rofi-autorandr.hs b/app/rofi-autorandr.hs index 158956a..8ea89f4 100644 --- a/app/rofi-autorandr.hs +++ b/app/rofi-autorandr.hs @@ -40,11 +40,17 @@ instance RofiConf ARClientConf where runPrompt :: [String] -> IO () runPrompt a = do let c = ARClientConf a - profs <- getAutoRandrProfiles + staticProfs <- getAutoRandrProfiles runRofiIO c $ selectAction $ emptyMenu - { groups = [untitledGroup $ toRofiActions [(p, selectProfile p) | p <- profs]] + { groups = [mkGroup "Static" staticProfs, mkGroup "Virtual" virtProfs] , prompt = Just "Select Profile" } + where + mkGroup header = titledGroup header . toRofiActions + . fmap (\s -> (" " ++ s, selectProfile s)) + +virtProfs :: [String] +virtProfs = ["off", "common", "clone-largest", "horizontal", "vertical"] -- TODO filter profiles based on which xrandr outputs are actually connected getAutoRandrProfiles :: IO [String] @@ -55,16 +61,10 @@ getAutoRandrProfiles = do getAutoRandrDir :: IO String getAutoRandrDir = do - x <- xdgDir - res <- doesDirectoryExist x - if res then return x else legacyDir + c <- getXdgDirectory XdgConfig "autorandr" + e <- doesDirectoryExist c + if e then return c else appendToHome ".autorandr" where - xdgDir = do - e <- lookupEnv "XDG_CONFIG_HOME" - case e of - Nothing -> appendToHome "./config/autorandr" - Just p -> return $ p "autorandr" - legacyDir = appendToHome ".autorandr" appendToHome p = ( p) <$> getHomeDirectory selectProfile :: String -> RofiIO ARClientConf ()