FIX make bt client accept cli args
This commit is contained in:
parent
3d21688a83
commit
c4a9c6462d
|
@ -18,20 +18,20 @@ import DBus.Client
|
||||||
|
|
||||||
import Rofi.Command
|
import Rofi.Command
|
||||||
|
|
||||||
main :: IO ()
|
import System.Environment
|
||||||
main = runPrompt
|
|
||||||
|
|
||||||
-- dummy type with nothing in it since there is nothing to configure for this
|
main :: IO ()
|
||||||
-- (yet)
|
main = getArgs >>= runPrompt
|
||||||
newtype RofiBTConf = RofiBTConf ObjectPath
|
|
||||||
|
data RofiBTConf = RofiBTConf [String] ObjectPath
|
||||||
|
|
||||||
instance RofiConf RofiBTConf where
|
instance RofiConf RofiBTConf where
|
||||||
defArgs (RofiBTConf _) = []
|
defArgs (RofiBTConf as _) = as
|
||||||
|
|
||||||
type BTAction = RofiAction RofiBTConf
|
type BTAction = RofiAction RofiBTConf
|
||||||
|
|
||||||
runPrompt :: IO ()
|
runPrompt :: [String] -> IO ()
|
||||||
runPrompt = do
|
runPrompt args = do
|
||||||
c <- getClient
|
c <- getClient
|
||||||
maybe (putStrLn "could not get DBus client") run c
|
maybe (putStrLn "could not get DBus client") run c
|
||||||
where
|
where
|
||||||
|
@ -41,7 +41,7 @@ runPrompt = do
|
||||||
$ getAdapter paths
|
$ getAdapter paths
|
||||||
actions client paths adapter = do
|
actions client paths adapter = do
|
||||||
ras <- getRofiActions client paths
|
ras <- getRofiActions client paths
|
||||||
runRofiIO (RofiBTConf adapter) $ selectAction $ emptyMenu
|
runRofiIO (RofiBTConf args adapter) $ selectAction $ emptyMenu
|
||||||
{ groups = [untitledGroup $ toRofiActions ras]
|
{ groups = [untitledGroup $ toRofiActions ras]
|
||||||
, prompt = Just "Select Device"
|
, prompt = Just "Select Device"
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ deviceToRofiAction client dev = do
|
||||||
|
|
||||||
powerAdapterMaybe :: Client -> RofiIO RofiBTConf ()
|
powerAdapterMaybe :: Client -> RofiIO RofiBTConf ()
|
||||||
powerAdapterMaybe client = do
|
powerAdapterMaybe client = do
|
||||||
(RofiBTConf adapter) <- ask
|
(RofiBTConf _ adapter) <- ask
|
||||||
let mc = btMethodCall adapter i m
|
let mc = btMethodCall adapter i m
|
||||||
let powerOnMaybe = flip unless $ void $ setProperty client mc value
|
let powerOnMaybe = flip unless $ void $ setProperty client mc value
|
||||||
powered <- io $ getBTProperty client adapter i m
|
powered <- io $ getBTProperty client adapter i m
|
||||||
|
|
Loading…
Reference in New Issue