aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDon Stewart <dons@cse.unsw.edu.au>2007-06-09 08:09:13 +0200
committerDon Stewart <dons@cse.unsw.edu.au>2007-06-09 08:09:13 +0200
commit5309cd40cb1384cb9de4ca114b06fbb2d3d5d45f (patch)
treebe5ed7375a0599fbedf2911d47608aaeb524ef26 /scripts
parent9533c8a0d61c5b172294ea2705596af016e1ab86 (diff)
downloadXMonadContrib-5309cd40cb1384cb9de4ca114b06fbb2d3d5d45f.tar.gz
XMonadContrib-5309cd40cb1384cb9de4ca114b06fbb2d3d5d45f.tar.xz
XMonadContrib-5309cd40cb1384cb9de4ca114b06fbb2d3d5d45f.zip
latest version of xmonad-status.hs
darcs-hash:20070609060913-9c5c1-b6d51e6a373cbdf2d8f6bc101d693a3b32251fb5.gz
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/run-xmonad.sh41
-rw-r--r--scripts/xmonad-status.hs (renamed from scripts/xmonad-dynamic-workspaces.hs)88
2 files changed, 102 insertions, 27 deletions
diff --git a/scripts/run-xmonad.sh b/scripts/run-xmonad.sh
new file mode 100755
index 0000000..aad2526
--- /dev/null
+++ b/scripts/run-xmonad.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# launch xmonad, with a couple of dzens to run the status bar
+# send xmonad state over a named pipe
+#
+
+FG='#a8a3f7'
+BG='#3f3c6d'
+FONT="-xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso8859-1"
+
+PATH=/home/dons/bin:$PATH
+
+# simple xmonad use, no interactive status bar.
+#
+#clock | dzen2 -ta r -fg $FG -bg $BG -fn $FONT &
+#exec xmonad
+
+#
+# with a pipe talking to an external program
+#
+PIPE=$HOME/.xmonad-status
+rm -f $PIPE
+/sbin/mkfifo -m 600 $PIPE
+[ -p $PIPE ] || exit
+
+# launch the external 60 second clock, and launch the workspace status bar
+clock | dzen2 -e '' -x 300 -w 768 -ta r -fg $FG -bg $BG -fn $FONT &
+xmonad-status < $PIPE | dzen2 -e '' -w 300 -ta l -fg $FG -bg $BG -fn $FONT &
+
+# now go for it
+xmonad > $PIPE &
+
+# wait for xmonad
+wait $!
+
+pkill -HUP dzen2
+pkill -HUP ssh-agent
+pkill -HUP -f clock
+pkill -HUP -f xmonad-status
+
+wait
diff --git a/scripts/xmonad-dynamic-workspaces.hs b/scripts/xmonad-status.hs
index b2c8fea..a223204 100644
--- a/scripts/xmonad-dynamic-workspaces.hs
+++ b/scripts/xmonad-status.hs
@@ -14,25 +14,53 @@
-- An example use:
--
--
--- #!/bin/sh
--- #
--- # launch xmonad, with a couple of dzens to run the status bar
--- # send xmonad state over a named pipe
--- #
--- FG='#a8a3f7'
--- BG='#3f3c6d'
--- FONT="-xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso8859-1"
---
--- PATH=/home/dons/bin:$PATH
---
--- # clean up and old status bar pipe
--- rm -f ~/.xmonad.pipe
---
--- # create a new one
--- /sbin/mkfifo -m 600 ~/.xmonad.pipe
---
--- xmonad-status < ~/.xmonad.pipe | dzen2 -ta l -fg $FG -bg $BG -fn $FONT &
--- exec xmonad > ~/.xmonad.pipe
+{-
+
+#!/bin/sh
+#
+# launch xmonad, with a couple of dzens to run the status bar
+# send xmonad state over a named pipe
+#
+
+FG='#a8a3f7'
+BG='#3f3c6d'
+FONT="-xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso8859-1"
+
+PATH=/home/dons/bin:$PATH
+
+# simple xmonad use, no interactive status bar.
+#
+#clock | dzen2 -ta r -fg $FG -bg $BG -fn $FONT &
+#exec xmonad
+
+#
+# with a pipe talking to an external program
+#
+PIPE=$HOME/.xmonad-status
+rm -f $PIPE
+/sbin/mkfifo -m 600 $PIPE
+[ -p $PIPE ] || exit
+
+# launch the external 60 second clock, and launch the workspace status bar
+clock | dzen2 -e '' -x 300 -w 768 -ta r -fg $FG -bg $BG -fn $FONT &
+xmonad-status < $PIPE | dzen2 -e '' -w 300 -ta l -fg $FG -bg $BG -fn $FONT &
+
+# now go for it
+xmonad > $PIPE &
+
+# wait for xmonad
+wait $!
+
+pkill -HUP dzen2
+pkill -HUP ssh-agent
+pkill -HUP -f clock
+pkill -HUP -f xmonad-status
+
+# wait for all clients
+wait
+
+-}
+
--
-- Creates a workspace table on the left side of the screen.
--
@@ -45,19 +73,26 @@ import StackSet
import XMonad
import System.IO
import Text.PrettyPrint
+import Control.Exception
--
-- parse the StackSet output, and print it in the form:
--
--- *[1] 2 *3 *4 5 6 7 8
+-- 1 [2] 4 8
--
-- It's an example of how to write a Haskell script to hack
-- the structure defined in StackSet.hs
--
-main = forever $ getLine >>= readIO >>= draw
+main :: IO ()
+main = forever $ do s <- getLine
+ handle (\e -> throwDyn (show e ++ show s))
+ (readIO s >>= draw)
where
- forever a = a >> forever a
+ forever a = catchDyn (loop a) (debug a) >> forever a
+ where
+ loop a = a >> loop a
+ debug a e = hPutStrLn stderr e >> forever a
--
-- All the magic is in the 'ppr' instances, below.
@@ -92,7 +127,7 @@ instance Pretty WS where
--
instance Pretty TaggedW where
ppr (C w) = brackets (int (1 + fromIntegral (tag w))) -- [1]
- ppr (V w) = parens (ppr w) -- <2>
+ ppr (V w) = parens (ppr w) -- <2>
ppr (H w) = ppr w
-- tags are printed as integers (or map them to strings)
@@ -107,7 +142,6 @@ instance Pretty a => Pretty [a] where
ppr [] = empty
ppr (x:xs) = ppr x <> ppr xs
-
-- ---------------------------------------------------------------------
-- Some type information for the pretty printer
@@ -116,9 +150,9 @@ type W = Workspace WorkspaceId Int
type WS = StackSet WorkspaceId Int ScreenId
-- Introduce a newtype to distinguish different workspace flavours
-data TaggedW = C W -- current
- | V W -- visible
- | H W -- hidden
+data TaggedW = C !W -- current
+ | V !W -- visible
+ | H !W -- hidden
-- And the ability to unwrap tagged workspaces
unWrap :: TaggedW -> W