From c4a9c6462d891be666ee1cb9853613a6366452ad Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Mon, 29 Nov 2021 00:55:33 -0500 Subject: [PATCH] FIX make bt client accept cli args --- app/rofi-bt.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/rofi-bt.hs b/app/rofi-bt.hs index 8f8f105..40b42e1 100644 --- a/app/rofi-bt.hs +++ b/app/rofi-bt.hs @@ -18,20 +18,20 @@ import DBus.Client import Rofi.Command -main :: IO () -main = runPrompt +import System.Environment --- dummy type with nothing in it since there is nothing to configure for this --- (yet) -newtype RofiBTConf = RofiBTConf ObjectPath +main :: IO () +main = getArgs >>= runPrompt + +data RofiBTConf = RofiBTConf [String] ObjectPath instance RofiConf RofiBTConf where - defArgs (RofiBTConf _) = [] + defArgs (RofiBTConf as _) = as type BTAction = RofiAction RofiBTConf -runPrompt :: IO () -runPrompt = do +runPrompt :: [String] -> IO () +runPrompt args = do c <- getClient maybe (putStrLn "could not get DBus client") run c where @@ -41,7 +41,7 @@ runPrompt = do $ getAdapter paths actions client paths adapter = do ras <- getRofiActions client paths - runRofiIO (RofiBTConf adapter) $ selectAction $ emptyMenu + runRofiIO (RofiBTConf args adapter) $ selectAction $ emptyMenu { groups = [untitledGroup $ toRofiActions ras] , prompt = Just "Select Device" } @@ -66,7 +66,7 @@ deviceToRofiAction client dev = do powerAdapterMaybe :: Client -> RofiIO RofiBTConf () powerAdapterMaybe client = do - (RofiBTConf adapter) <- ask + (RofiBTConf _ adapter) <- ask let mc = btMethodCall adapter i m let powerOnMaybe = flip unless $ void $ setProperty client mc value powered <- io $ getBTProperty client adapter i m