summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Run/Actions.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-02-05 02:49:22 +0000
committerjao <jao@gnu.org>2022-02-06 00:24:10 +0000
commitafc2d1ed565910b372f65eaf77ea90878ac3ab2b (patch)
tree4b2b79d683b82cc0e16460884c8bfcc6c27b33cb /src/Xmobar/Run/Actions.hs
parentc0a9c6df0080a0db5981047f80c9c120ac1cef61 (diff)
downloadxmobar-afc2d1ed565910b372f65eaf77ea90878ac3ab2b.tar.gz
xmobar-afc2d1ed565910b372f65eaf77ea90878ac3ab2b.tar.bz2
swaybar-protocol: support for clickable Action
Diffstat (limited to 'src/Xmobar/Run/Actions.hs')
-rw-r--r--src/Xmobar/Run/Actions.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Xmobar/Run/Actions.hs b/src/Xmobar/Run/Actions.hs
index f7d0e45..2a49312 100644
--- a/src/Xmobar/Run/Actions.hs
+++ b/src/Xmobar/Run/Actions.hs
@@ -10,7 +10,11 @@
--
-----------------------------------------------------------------------------
-module Xmobar.Run.Actions (Button, Action(..), runAction, stripActions) where
+module Xmobar.Run.Actions ( Button
+ , Action(..)
+ , runAction
+ , runAction'
+ , stripActions) where
import System.Process (system)
import Control.Monad (void)
@@ -19,12 +23,15 @@ import Data.Word (Word32)
type Button = Word32
-data Action = Spawn [Button] String
- deriving (Eq, Show)
+data Action = Spawn [Button] String deriving (Eq, Read, Show)
runAction :: Action -> IO ()
runAction (Spawn _ s) = void $ system (s ++ "&")
+-- | Run action with stdout redirected to stderr
+runAction' :: Action -> IO ()
+runAction' (Spawn _ s) = void $ system (s ++ " 1>&2 &")
+
stripActions :: String -> String
stripActions s = case matchRegex actionRegex s of
Nothing -> s