mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Use time instead of old-time and old-locale
Get rid of these deprecated libraries, as the new `time' library provides a strict superset of the functionality of `old-time' and `old-locale'.
This commit is contained in:
parent
f1bd315448
commit
94f1e943d4
@ -19,7 +19,8 @@ module XMonad.Actions.AfterDrag (
|
||||
ifClick') where
|
||||
|
||||
import XMonad
|
||||
import System.Time
|
||||
|
||||
import Data.Time (NominalDiffTime, diffUTCTime, getCurrentTime)
|
||||
|
||||
-- $usage
|
||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||
@ -53,7 +54,7 @@ afterDrag task = do drag <- gets dragging
|
||||
-- A drag is considered a click if it is completed within 300 ms.
|
||||
ifClick
|
||||
:: X () -- ^ The action to take if the dragging turned out to be a click.
|
||||
-> X ()
|
||||
-> X ()
|
||||
ifClick action = ifClick' 300 action (return ())
|
||||
|
||||
-- | Take an action if the current dragging is completed within a certain time (in milliseconds.)
|
||||
@ -61,11 +62,11 @@ ifClick'
|
||||
:: Int -- ^ Maximum time of dragging for it to be considered a click (in milliseconds.)
|
||||
-> X () -- ^ The action to take if the dragging turned out to be a click.
|
||||
-> X () -- ^ The action to take if the dragging turned out to not be a click.
|
||||
-> X ()
|
||||
-> X ()
|
||||
ifClick' ms click drag = do
|
||||
start <- io $ getClockTime
|
||||
afterDrag $ do
|
||||
stop <- io $ getClockTime
|
||||
if diffClockTimes stop start <= noTimeDiff { tdPicosec = fromIntegral ms * 10^(9 :: Integer) }
|
||||
start <- io getCurrentTime
|
||||
afterDrag $ do
|
||||
stop <- io getCurrentTime
|
||||
if diffUTCTime stop start <= (fromIntegral ms / 10^(3 :: Integer) :: NominalDiffTime)
|
||||
then click
|
||||
else drag
|
||||
|
@ -57,11 +57,10 @@ import XMonad.Util.NamedWindows (getName)
|
||||
import Control.Exception as E
|
||||
import Data.List (find, isPrefixOf, isSuffixOf)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Time (defaultTimeLocale, formatTime, getCurrentTime)
|
||||
import System.Directory (getDirectoryContents)
|
||||
import System.IO
|
||||
import System.Locale
|
||||
import System.IO (hGetLine)
|
||||
import System.Process (runInteractiveCommand)
|
||||
import System.Time
|
||||
|
||||
econst :: Monad m => a -> IOException -> m a
|
||||
econst = const . return
|
||||
@ -129,8 +128,7 @@ battery = logCmd "acpi | sed -r 's/.*?: (.*%).*/\\1/; s/[dD]ischarging, ([0-9]+%
|
||||
-- For more information see something like
|
||||
-- <http://www.cplusplus.com/reference/clibrary/ctime/strftime.html>.
|
||||
date :: String -> Logger
|
||||
date fmt = io $ do cal <- getClockTime >>= toCalendarTime
|
||||
return . Just $ formatCalendarTime defaultTimeLocale fmt cal
|
||||
date fmt = io $ Just . formatTime defaultTimeLocale fmt <$> getCurrentTime
|
||||
|
||||
-- | Get the load average. This assumes that you have a
|
||||
-- utility called @uptime@ and that you have @sed@
|
||||
@ -248,7 +246,7 @@ withScreen f n = do
|
||||
ss <- withWindowSet $ return . W.screens
|
||||
case find ((== n) . W.screen) ss of
|
||||
Just s -> f s
|
||||
Nothing -> pure $ Nothing
|
||||
Nothing -> pure Nothing
|
||||
|
||||
-- $format
|
||||
-- Combine logger formatting functions to make your
|
||||
|
@ -52,8 +52,7 @@ library
|
||||
containers >= 0.5 && < 0.7,
|
||||
directory,
|
||||
filepath,
|
||||
old-locale,
|
||||
old-time,
|
||||
time >= 1.8 && < 1.12,
|
||||
process,
|
||||
random,
|
||||
mtl >= 1 && < 3,
|
||||
|
Loading…
x
Reference in New Issue
Block a user