ENH add verbose option
This commit is contained in:
parent
f0b931c29c
commit
bc33c47e3b
|
@ -181,12 +181,14 @@ instance FromJSON TreeConfig where
|
||||||
|
|
||||||
data StaticConfig = StaticConfig
|
data StaticConfig = StaticConfig
|
||||||
{ _staticconfigTmpPath :: Maybe String
|
{ _staticconfigTmpPath :: Maybe String
|
||||||
|
, _staticconfigVerbose :: Maybe Bool
|
||||||
, _staticconfigDevices :: M.Map String TreeConfig
|
, _staticconfigDevices :: M.Map String TreeConfig
|
||||||
} deriving Show
|
} deriving Show
|
||||||
|
|
||||||
instance FromJSON StaticConfig where
|
instance FromJSON StaticConfig where
|
||||||
parseJSON = withObject "devices" $ \o -> StaticConfig
|
parseJSON = withObject "devices" $ \o -> StaticConfig
|
||||||
<$> o .:? "mountdir"
|
<$> o .:? "mountdir"
|
||||||
|
<*> o .:? "verbose"
|
||||||
<*> o .: "devices"
|
<*> o .: "devices"
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -203,6 +205,7 @@ data MountConf = MountConf
|
||||||
{ mountconfVolatilePath :: FilePath
|
{ mountconfVolatilePath :: FilePath
|
||||||
, mountconfRofiArgs :: [String]
|
, mountconfRofiArgs :: [String]
|
||||||
, mountconfStaticDevs :: M.Map String TreeConfig
|
, mountconfStaticDevs :: M.Map String TreeConfig
|
||||||
|
, mountconfVerbose :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
instance RofiConf MountConf where
|
instance RofiConf MountConf where
|
||||||
|
@ -260,12 +263,14 @@ runMounts :: Opts -> IO ()
|
||||||
runMounts opts = do
|
runMounts opts = do
|
||||||
static <- join <$> traverse parseStaticConfig (optsConfig opts)
|
static <- join <$> traverse parseStaticConfig (optsConfig opts)
|
||||||
defaultTmpPath <- ("/tmp/media" </>) <$> getEffectiveUserName
|
defaultTmpPath <- ("/tmp/media" </>) <$> getEffectiveUserName
|
||||||
let tmpPath = fromMaybe defaultTmpPath (_staticconfigTmpPath =<< static)
|
let tmpPath = fromMaybe defaultTmpPath $ _staticconfigTmpPath =<< static
|
||||||
let staticDevs = maybe M.empty _staticconfigDevices static
|
let staticDevs = maybe M.empty _staticconfigDevices static
|
||||||
|
let verbose = fromMaybe False $ _staticconfigVerbose =<< static
|
||||||
let mountconf = MountConf
|
let mountconf = MountConf
|
||||||
{ mountconfVolatilePath = tmpPath
|
{ mountconfVolatilePath = tmpPath
|
||||||
, mountconfRofiArgs = optsRofiArgs opts
|
, mountconfRofiArgs = optsRofiArgs opts
|
||||||
, mountconfStaticDevs = staticDevs
|
, mountconfStaticDevs = staticDevs
|
||||||
|
, mountconfVerbose = verbose
|
||||||
}
|
}
|
||||||
let byAlias = mountByAlias $ optsUnmount opts
|
let byAlias = mountByAlias $ optsUnmount opts
|
||||||
let byPrompt = runPrompt =<< getGroups
|
let byPrompt = runPrompt =<< getGroups
|
||||||
|
@ -558,8 +563,11 @@ class Mountable a where
|
||||||
mountMaybe :: a -> Bool -> RofiIO MountConf ()
|
mountMaybe :: a -> Bool -> RofiIO MountConf ()
|
||||||
mountMaybe dev mountFlag = do
|
mountMaybe dev mountFlag = do
|
||||||
mounted <- isMounted dev
|
mounted <- isMounted dev
|
||||||
|
verbose <- asks mountconfVerbose
|
||||||
if mountFlag == mounted then mount dev mountFlag
|
if mountFlag == mounted then mount dev mountFlag
|
||||||
else io $ notify "dialog-information-symbolic"
|
else when verbose notify'
|
||||||
|
where
|
||||||
|
notify' = io $ notify "dialog-information-symbolic"
|
||||||
$ getLabel dev ++ " already mounted"
|
$ getLabel dev ++ " already mounted"
|
||||||
|
|
||||||
-- | Check if the mounting utilities are present
|
-- | Check if the mounting utilities are present
|
||||||
|
|
Loading…
Reference in New Issue