packages feed

uacpid 1.0.3.0 → 1.1

raw patch · 15 files changed

+244/−137 lines, 15 filesdep ~timesetup-changed

Dependency ranges changed: time

Files

− README
@@ -1,38 +0,0 @@-------Getting started developing:--This daemon is designed to make files for itself in ~/.uacpid/ the-first time it's run. To assist with development, there is a script-which will build a development installation and execution environment-in /tmp/uacpid-dev/ for you.---To initialize for development:--   $ bin/uacpid-dev-setup---Once that's completed, it can be run like this:--   $ bin/uacpid-dev---------A word about the version numbering scheme:--   4-part: major.minor.status.build-   3-part: major.status.build--   status:-      0 alpha-      1 beta-      2 release candidate-      3 release--   examples:-      1.3.0.2         v1.3 alpha build 2-      1.2.1.0         v1.2 beta build 0-      4.2.24          v4 release candidate build 24-      2.10.3.5        v2.10 release build 5 (say they were bug fixes)-      1.5.2.20090818  Can even use a date for build-                      v1.5 release candidate 2009-08-18 build
+ README.md view
@@ -0,0 +1,80 @@+# uacpid+++## Synopsis++Userspace Advanced Configuration and Power Interface event daemon+(Haskell)+++## Description++uacpid is a daemon designed to be run in userspace that will monitor+the local system's acpid socket for hardware events. These events can+then be acted upon by handlers with access to the user's environment.++An example of why you need this: Suppose you want to have a hardware+event change the active X displays, like a laptop external monitor+function button. Some tools to achieve this display change require+the logged in user's DISPLAY and other settings that may be difficult+or impossible to gain access to from acpid scripts.++Another example is media control function buttons, like play/pause+or next/previous track for a music player.++uacpid is running as you and is getting the hardware events reported+by the system's acpid. uacpid can then act on the events on your+behalf, with your environment.++uacpid will respond to SIGHUP by reloading the event handlers and+reestablishing its connection to the acpid socket. Changes to the+config file will require that uacpid be restarted, it will not+reload the config on SIGHUP.++Handler syntax closely follows that of acpid. Users familiar with+acpid should have no problem here. An example is included.++Note that uacpid requires acpid. It must be installed and running.++(Please see the uacpid man page for more detailed info) +++## Getting source++- Download the cabalized source package [from Hackage](http://hackage.haskell.org/package/uacpid)+- epub-tools is available for Arch Linux [from the AUR](https://aur.archlinux.org/packages/uacpid/)+- Get the source with darcs: `$ darcs get http://hub.darcs.net/dino/uacpid`+- If you're just looking, [browse the source](http://hub.darcs.net/dino/uacpid)++Getting started developing:++This daemon is designed to make files for itself in ~/.uacpid/ the+first time it's run. To assist with development, there is a script+which will build a development installation and execution environment+in /tmp/uacpid-dev/ for you.++To initialize for development:++    $ bin/uacpid-dev-setup+++Once that's completed, it can be run like this:++    $ bin/uacpid-dev++And once you have it, building the usual way:++    $ cabal configure+    $ cabal build+    $ cabal install+++## Installing++Build and install with cabal-install:+  `$ cabal update ; cabal install uacpid`+++## Contact++Dino Morelli <[dino@ui3.info](mailto:dino@ui3.info)>
Setup.hs view
@@ -1,6 +1,5 @@ #! /usr/bin/env runhaskell --- Copyright: 2009, 2010 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
− TODO
@@ -1,11 +0,0 @@-- Can some of the code in main.hs be factored into other modules? Maybe Uacpid.Signals to start with--- If the event handler script's shell process fails, we need to log the exit code. WARNING priority. The real question here is do we have any business waiting for the shell process to come back? Maybe just report on failure to launch?--- Need to be careful about when acpid is stopped and the socket goes away on a running uacpid. Must deal with this gracefully.--- If acpid has run but is not now running, the socket file in /var/run/ can still be there. What happens then is that the connection is refused and you get no message in the uacpid log. You do get a message to stderr, but this is likely to be missed when running from .xinitrc  Need to fix this soon.--- Add version number output to logging when daemon is started--- Need to develop a simulator event server to use for automated testing and development
+ TODO.md view
@@ -0,0 +1,18 @@+- Can some of the code in `main.hs` be factored into other+  modules? Maybe Uacpid.Signals to start with+- If the event handler script's shell process fails, we need to log+  the exit code. WARNING priority. The real question here is do we+  have any business waiting for the shell process to come back? Maybe+  just report on failure to launch?+- Need to be careful about when acpid is stopped and the socket+  goes away on a running uacpid. Must deal with this gracefully.+- If acpid has run but is not now running, the socket file+  in `/var/run/` can still be there. What happens then is that the+  connection is refused and you get no message in the uacpid log. You+  do get a message to stderr, but this is likely to be missed when+  running from `.xinitrc`  Need to fix this soon.+- Add version number output to logging when daemon is started+- Need to develop a simulator event server to use for automated+  testing and development+- Could use some unit tests (see simulator above also for other+  tests)
+ changelog.md view
@@ -0,0 +1,43 @@+1.1 (2015-06-28)++   * Replaced deprecated Control.Monad.ErrorT with ExceptT+   * Fixed defaultTimeLocale import problem+   * Now getting version from cabal info using Paths_ code+   * Updated cabal info+   * Moved copyright date up to 2015+   * Adjustments to documentation+++1.0.3.0 (2011-03-18)++   * Fixed code that was leaving zombie child processes by not+     waiting for them+   * Changed listenAcpi delay time from 0.25 secs to 2 secs+   * Refined developer and testing environment creation scripts+   * Updated and clarified some documentation+++1.0.1 (2010-04-06)++   * Fix for a recent change in how System.Directory.doesFileExist+     behaves with sockets+   * Fixes for new GHC 6.12.x unused do binding warnings+   * Various cosmetic changes of copyright dates and version strings+   * Added HCAR info+++0.0.4 (2009-07-19)++   * Another try at fixing the broken man page installation problem+     on Arch Linux.+++0.0.3 (2009-07-15)++   * Fix for installation problem on Arch Linux. The man page was+     not getting installed.+++0.0.2 (2009-07-15)++   * Initial release
doc/hcar-uacpid.tex view
@@ -1,30 +1,20 @@-\documentclass{scrreprt}-\usepackage{paralist}-\usepackage{graphicx}-\usepackage{hcar}--\begin{document}--\begin{hcarentry}{uacpid}+\begin{hcarentry}{uacpid (Userspace ACPI daemon)} \report{Dino Morelli} \status{experimental, actively developed} \makeheader  uacpid is a daemon designed to be run in userspace that will monitor the local system's acpid socket for hardware events. These events can then be acted upon by handlers with access to the user's environment. Configuration of uacpid closely mimics that of acpid. +Recent development has involved fixing bugs that were leaving zombie processes.+ uacpid is available in binary form for Arch Linux through the AUR and can be acquired using darcs or other methods.  \FurtherReading \begin{compactitem} \item Project page:- \url{http://ui3.info/d/proj/uacpid.html}  \item Source repository:- \texttt{darcs get} \url{http://ui3.info/darcs/uacpid} \end{compactitem}- \end{hcarentry}--\end{document}
src/Uacpid/Conf.hs view
@@ -1,4 +1,3 @@--- Copyright: 2009, 2010 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> 
− src/Uacpid/Control/Monad/Error.hs
@@ -1,49 +0,0 @@--- Copyright: 2009, 2010 Dino Morelli--- License: BSD3 (see LICENSE)--- Author: Dino Morelli <dino@ui3.info>--{-# LANGUAGE FlexibleContexts #-}--{- |-   Convenience function for turning (Maybe a) values into -   (MonadError e a) actions plus functions for expressing Data.Map -   lookups as MonadError actions--}-module Uacpid.Control.Monad.Error-   ( maybeThrow-   , lookupEWith, lookupEString-   )-   where--import Control.Monad.Error-import Data.Map hiding ( map )-import Prelude hiding ( lookup )---{- |-   Turn an error value and a (Maybe a) into a (MonadError e a) action--}-maybeThrow :: (MonadError e m) => e -> Maybe a -> m a-maybeThrow err mval = maybe (throwError err) return mval---{- |-   Look up a String key in a Map as an action in (MonadError e), -   providing a function to transform key type k to error type e.--   See lookupEString below for a usage example.--}-lookupEWith :: (MonadError e m, Ord k) =>-               (k -> e) -> k -> Map k a -> m a-lookupEWith f k m = maybeThrow (f k) $ lookup k m---{- |-   Look up a String key in a Map as an action in (MonadError String), -   with a default message that the key was not found as the-   error.--}-lookupEString :: (MonadError String m) =>-                 String -> Map String a -> m a-lookupEString =-   lookupEWith (\j -> "Key " ++ j ++ " not found")
+ src/Uacpid/Control/Monad/Except.hs view
@@ -0,0 +1,48 @@+-- License: BSD3 (see LICENSE)+-- Author: Dino Morelli <dino@ui3.info>++{-# LANGUAGE FlexibleContexts #-}++{- |+   Convenience function for turning (Maybe a) values into +   (MonadError e a) actions plus functions for expressing Data.Map +   lookups as MonadError actions+-}+module Uacpid.Control.Monad.Except+   ( maybeThrow+   , lookupEWith, lookupEString+   )+   where++import Control.Monad.Except+import Data.Map hiding ( map )+import Prelude hiding ( lookup )+++{- |+   Turn an error value and a (Maybe a) into a (MonadError e a) action+-}+maybeThrow :: (MonadError e m) => e -> Maybe a -> m a+maybeThrow err mval = maybe (throwError err) return mval+++{- |+   Look up a String key in a Map as an action in (MonadError e), +   providing a function to transform key type k to error type e.++   See lookupEString below for a usage example.+-}+lookupEWith :: (MonadError e m, Ord k) =>+               (k -> e) -> k -> Map k a -> m a+lookupEWith f k m = maybeThrow (f k) $ lookup k m+++{- |+   Look up a String key in a Map as an action in (MonadError String), +   with a default message that the key was not found as the+   error.+-}+lookupEString :: (MonadError String m) =>+                 String -> Map String a -> m a+lookupEString =+   lookupEWith (\k -> "Key " ++ k ++ " not found")
src/Uacpid/Events.hs view
@@ -1,4 +1,3 @@--- Copyright: 2009, 2010 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -8,7 +7,7 @@    ( Handler (..), loadHandlers, executeHandlers )    where -import Control.Monad.Error+import Control.Monad.Except import Data.List import Data.Maybe import System.Directory@@ -18,7 +17,7 @@ import Text.Regex ( matchRegex, mkRegex )  import Uacpid.Conf ( ConfMap, getConfDir, parseToMap )-import Uacpid.Control.Monad.Error+import Uacpid.Control.Monad.Except import Uacpid.Log ( logM )  @@ -41,7 +40,7 @@    evMap <- liftM parseToMap $ readFile path     -- Extract data from it to make an Handler, with error reporting-   eitherStringHandler <- runErrorT $ do+   eitherStringHandler <- runExceptT $ do       event <- lookupHandlerE name "event" evMap       action <- lookupHandlerE name "action" evMap       return $ Handler name event action
src/Uacpid/Log.hs view
@@ -1,4 +1,3 @@--- Copyright: 2009, 2010 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info> @@ -10,10 +9,9 @@ import Data.Map ( lookup ) import Data.Maybe import Data.Time.Clock ( getCurrentTime )-import Data.Time.Format ( formatTime )+import Data.Time.Format ( defaultTimeLocale, formatTime ) import Data.Time.LocalTime ( utcToLocalZonedTime ) import Prelude hiding ( lookup )-import System.Locale ( defaultTimeLocale ) import System.Log.Handler.Simple ( fileHandler ) import qualified System.Log.Logger as L ( logM ) import           System.Log.Logger hiding ( logM )@@ -24,8 +22,8 @@  -- Format the time right now given a formatting string formattedDate :: String -> IO String-formattedDate formatString =-   liftM (formatTime defaultTimeLocale formatString)+formattedDate formatString' =+   liftM (formatTime defaultTimeLocale formatString')       $ getCurrentTime >>= utcToLocalZonedTime  
src/main.hs view
@@ -1,13 +1,13 @@--- Copyright: 2009, 2010 Dino Morelli -- License: BSD3 (see LICENSE) -- Author: Dino Morelli <dino@ui3.info>  {-# LANGUAGE FlexibleContexts #-}  import Control.Concurrent-import Control.Monad.Error+import Control.Monad.Except import Data.Map hiding ( null ) import Data.Maybe+import Data.Version ( showVersion ) import Prelude hiding ( lookup ) import Network.Socket import System.Environment@@ -17,8 +17,9 @@ import System.Posix.Files import System.Posix.Signals hiding ( Handler ) +import Paths_uacpid ( version ) import Uacpid.Conf-import Uacpid.Control.Monad.Error+import Uacpid.Control.Monad.Except import Uacpid.Events import Uacpid.Log ( initLogging, logM ) @@ -76,7 +77,7 @@    when (runStatus == RESTART) $ do       handlers <- loadHandlers -      eHdl <- runErrorT $ openAcpidSocket conf+      eHdl <- runExceptT $ openAcpidSocket conf       either exitFail          (\hdl -> do             _ <- takeMVar mvRunStatus@@ -175,7 +176,7 @@       , ""       , "Please see man uacpid for detailed info"       , ""-      , "Version 1.0.3.0  Dino Morelli <dino@ui3.info>"+      , "Version " ++ (showVersion version) ++ "  Dino Morelli <dino@ui3.info>"       ]     exitWith ExitSuccess
uacpid.cabal view
@@ -1,14 +1,14 @@ name:                uacpid-version:             1.0.3.0-cabal-version:       >= 1.2+version:             1.1+cabal-version:       >= 1.8 build-type:          Simple license:             BSD3 license-file:        LICENSE-copyright:           2009, 2010 Dino Morelli+copyright:           2009-2015 Dino Morelli author:              Dino Morelli maintainer:          Dino Morelli <dino@ui3.info> stability:           experimental-homepage:            http://ui3.info/d/proj/uacpid.html+homepage:            http://hub.darcs.net/dino/uacpid synopsis:            Userspace Advanced Configuration and Power Interface                       event daemon description:         uacpid is a daemon designed to be run in userspace @@ -17,14 +17,36 @@                      upon by handlers with access to the user's                      environment. category:            System-tested-with:         GHC>=6.12.3+tested-with:         GHC >= 7.10.1 data-dir:            resources data-files:          uacpid/uacpid.conf, uacpid/events/anything +extra-source-files:  bin/uacpid-dev+                     bin/uacpid-dev-setup+                     changelog.md+                     doc/dev/events/noaction+                     doc/dev/events/noevent+                     doc/hcar-uacpid.tex+                     README.md+                     resources/man/uacpid.1+                     resources/uacpid/events/anything+                     resources/uacpid/uacpid.conf+                     TODO.md+                     util/gentags.sh+                     util/prefs/boring++source-repository    head+   type:             darcs+   location:         http://hub.darcs.net/dino/uacpid+ executable           uacpid    main-is:          main.hs-   hs-source-dirs:   src    build-depends:    base >= 3 && < 5, containers, directory, filepath,                       hslogger, mtl, network, old-locale, process,                       regex-compat, time, unix+   hs-source-dirs:   src+   other-modules:    Uacpid.Conf+                     Uacpid.Control.Monad.Except+                     Uacpid.Events+                     Uacpid.Log    ghc-options:      -Wall
util/prefs/boring view
@@ -1,4 +1,11 @@-# Boring file regexps:+# This file contains a list of extended regular expressions, one per+# line. A file path matching any of these expressions will be filtered+# out during `darcs add', or when the `--look-for-adds' flag is passed+# to `darcs whatsnew' and `record'.  The entries in ~/.darcs/boring (if+# it exists) supplement those in this file.+# +# Blank lines, and lines beginning with an octothorpe (#) are ignored.+# See regex(7) for a description of extended regular expressions.  ### compiler and interpreter intermediate files # haskell (ghc) interfaces@@ -38,8 +45,11 @@ # cabal intermediates \.installed-pkg-config \.setup-config+# cabal sandbox+^\.cabal-sandbox(/|$)+cabal\.sandbox\.config # standard cabal build dir, might not be boring for everybody-# ^dist(/|$)+^dist(/|$) # autotools (^|/)autom4te\.cache($|/) (^|/)config\.(log|status)$@@ -111,5 +121,3 @@ (^|/)\.lock-wscript$ # mac os finder (^|/)\.DS_Store$-# cabal-(^|/)dist($|/)