summaryrefslogtreecommitdiffhomepage
path: root/src/Actions.hs
blob: f3dc55a7a66028ef5458fa5cda2f87d73a93d7e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-----------------------------------------------------------------------------
-- |
-- Module      :  Xmobar.Actions
-- Copyright   :  (c) Alexander Polakov
-- License     :  BSD-style (see LICENSE)
--
-- Maintainer  :  Jose A. Ortega Ruiz <jao@gnu.org>
-- Stability   :  unstable
-- Portability :  unportable
--
-----------------------------------------------------------------------------

module Actions (Action(..), runAction, stripActions) where

import System.Process (system)
import Control.Monad (void)
import Text.Regex (subRegex, mkRegex)

data Action = Spawn String
                deriving (Eq)

runAction :: Action -> IO ()
runAction (Spawn s) = void $ system (s ++ "&")

stripActions :: String -> String
stripActions s = subRegex actionRegex s "[action=\1]\2[action]"
  where actionRegex = mkRegex "<action=([^>])*>(.+?)</action>"