ADD virtual profiles to autorander

This commit is contained in:
Nathan Dwarshuis 2021-06-25 00:04:50 -04:00
parent aa950334f9
commit a2d9de37d6
1 changed files with 11 additions and 11 deletions

View File

@ -40,11 +40,17 @@ instance RofiConf ARClientConf where
runPrompt :: [String] -> IO () runPrompt :: [String] -> IO ()
runPrompt a = do runPrompt a = do
let c = ARClientConf a let c = ARClientConf a
profs <- getAutoRandrProfiles staticProfs <- getAutoRandrProfiles
runRofiIO c $ selectAction $ emptyMenu runRofiIO c $ selectAction $ emptyMenu
{ groups = [untitledGroup $ toRofiActions [(p, selectProfile p) | p <- profs]] { groups = [mkGroup "Static" staticProfs, mkGroup "Virtual" virtProfs]
, prompt = Just "Select Profile" , 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 -- TODO filter profiles based on which xrandr outputs are actually connected
getAutoRandrProfiles :: IO [String] getAutoRandrProfiles :: IO [String]
@ -55,16 +61,10 @@ getAutoRandrProfiles = do
getAutoRandrDir :: IO String getAutoRandrDir :: IO String
getAutoRandrDir = do getAutoRandrDir = do
x <- xdgDir c <- getXdgDirectory XdgConfig "autorandr"
res <- doesDirectoryExist x e <- doesDirectoryExist c
if res then return x else legacyDir if e then return c else appendToHome ".autorandr"
where 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 appendToHome p = (</> p) <$> getHomeDirectory
selectProfile :: String -> RofiIO ARClientConf () selectProfile :: String -> RofiIO ARClientConf ()