xmobar -> test own Modules 7
This commit is contained in:
43
home/programs/xmonad/src/xmobar/Plugins/Utils.hs
Normal file
43
home/programs/xmonad/src/xmobar/Plugins/Utils.hs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
------------------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Module: Plugins.Utils
|
||||||
|
-- Copyright: (c) 2010 Jose Antonio Ortega Ruiz
|
||||||
|
-- License: BSD3-style (see LICENSE)
|
||||||
|
--
|
||||||
|
-- Maintainer: Jose A Ortega Ruiz <jao@gnu.org>
|
||||||
|
-- Stability: unstable
|
||||||
|
-- Portability: unportable
|
||||||
|
-- Created: Sat Dec 11, 2010 20:55
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- Miscellaneous utility functions
|
||||||
|
--
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
module Plugins.Utils (expandHome, changeLoop, safeHead) where
|
||||||
|
|
||||||
|
import Control.Monad
|
||||||
|
import Control.Concurrent.STM
|
||||||
|
|
||||||
|
import System.Environment
|
||||||
|
import System.FilePath
|
||||||
|
|
||||||
|
|
||||||
|
expandHome :: FilePath -> IO FilePath
|
||||||
|
expandHome ('~':'/':path) = fmap (</> path) (getEnv "HOME")
|
||||||
|
expandHome p = return p
|
||||||
|
|
||||||
|
changeLoop :: Eq a => STM a -> (a -> IO ()) -> IO ()
|
||||||
|
changeLoop s f = atomically s >>= go
|
||||||
|
where
|
||||||
|
go old = do
|
||||||
|
f old
|
||||||
|
go =<< atomically (do
|
||||||
|
new <- s
|
||||||
|
guard (new /= old)
|
||||||
|
return new)
|
||||||
|
|
||||||
|
safeHead :: [a] -> Maybe a
|
||||||
|
safeHead [] = Nothing
|
||||||
|
safeHead (x:_) = Just x
|
||||||
@@ -23,10 +23,10 @@ name: xmobar-custom
|
|||||||
version: 0.1.0.0
|
version: 0.1.0.0
|
||||||
|
|
||||||
-- The package author(s).
|
-- The package author(s).
|
||||||
author: 4Lost
|
author: einfischy
|
||||||
|
|
||||||
-- An email address to which users can send suggestions, bug reports, and patches.
|
-- An email address to which users can send suggestions, bug reports, and patches.
|
||||||
maintainer: elias.schroeter@e.email
|
maintainer: accounts.codeberg@kstn.in
|
||||||
|
|
||||||
-- A copyright notice.
|
-- A copyright notice.
|
||||||
-- copyright:
|
-- copyright:
|
||||||
@@ -42,18 +42,13 @@ executable xmobar
|
|||||||
-- .hs or .lhs file containing the Main module.
|
-- .hs or .lhs file containing the Main module.
|
||||||
main-is: xmobar.hs
|
main-is: xmobar.hs
|
||||||
|
|
||||||
other-modules: Commands,
|
other-modules: XUtil, Plugins.Utils
|
||||||
ColorCache,
|
|
||||||
Signal,
|
|
||||||
XUtil,
|
|
||||||
Plugins,
|
|
||||||
Plugins.Audio
|
|
||||||
-- Other library packages from which modules are imported.
|
-- Other library packages from which modules are imported.
|
||||||
build-depends: base ^>=4.17.2.1,
|
build-depends: base ^>=4.17.2.1,
|
||||||
xmobar ^>=0.47.1,
|
X11 >= 1.6.1,
|
||||||
process ^>=1.6.18.0,
|
xmobar ^>=0.47.1
|
||||||
mtl,
|
|
||||||
X11 >= 1.6.1
|
|
||||||
-- Directories containing source files.
|
-- Directories containing source files.
|
||||||
hs-source-dirs: .
|
hs-source-dirs: .
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user