summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorsabetts <sabetts>2003-06-22 01:41:44 +0000
committersabetts <sabetts>2003-06-22 01:41:44 +0000
commit2ea0cfd85618507ba51945bcfd1a9df711e069e8 (patch)
tree78918369d992de91f8fe0f4851e349bb8860117a /contrib
parent827b7fcd6d417961cd5a1c2bca9fb8da81a3afcd (diff)
downloadratpoison-2ea0cfd85618507ba51945bcfd1a9df711e069e8.zip
(bin_SCRIPTS): add rpws
Diffstat (limited to 'contrib')
-rw-r--r--contrib/Makefile.am2
-rwxr-xr-xcontrib/rpws111
2 files changed, 113 insertions, 0 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 692a0d4..9963ef1 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -1,2 +1,4 @@
+bin_SCRIPTS = rpws
+
pkgdata_DATA = ratpoison.el split.sh genrpbindings
EXTRA_DIST = ratpoison.el split.sh genrpbindings
diff --git a/contrib/rpws b/contrib/rpws
new file mode 100755
index 0000000..c794b49
--- /dev/null
+++ b/contrib/rpws
@@ -0,0 +1,111 @@
+#!/bin/sh
+#
+# Workspaces for ratpoison
+# Copyright (C) 2003 Shawn Betts
+# Author: Shawn Betts
+#
+# To enable workspaces, put the following lines in your .ratpoisonrc
+# file:
+#
+# exec rpws -i
+# exec rpws -b
+#
+# The first line initializes the workspaces (never call this more than
+# once or it will clutter ratpoison with duplicate window groups). The
+# second line sets up some keybindings:
+#
+# C-t M-1 Workspace 1
+# C-t M-2 Workspace 2
+# ...
+# C-t M-7 Workspace 7
+#
+# You want more workspaces? Edit this script.
+#
+# Code:
+#
+
+RATPOISON=ratpoison
+
+function rp_call ()
+{
+ echo "$RATPOISON -c \"$*\"" >/tmp/cmds
+ $RATPOISON -c "$*"
+}
+
+function ws_init_ws ()
+{
+ rp_call gnew ws$1
+ rp_call setenv fs$1 `rp_call fdump`
+}
+
+function ws_init ()
+{
+ # Backup the frames
+ FS=`rp_call fdump`
+ rp_call select -
+ rp_call only
+
+ # Make 6 workspaces
+ ws_init_ws 2
+ ws_init_ws 3
+ ws_init_ws 4
+ ws_init_ws 5
+ ws_init_ws 6
+ ws_init_ws 7
+
+ # Workspace 1 uses the 'default' group.
+ # Start in workspace 1.
+ rp_call gselect default
+ rp_call setenv fs1 `rp_call fdump`
+ rp_call setenv ws 1
+
+ # restore the frames
+ echo $FS
+ rp_call frestore $FS
+}
+
+function ws_save ()
+{
+ WS=`rp_call getenv ws`
+ rp_call setenv fs$WS `rp_call fdump`
+}
+
+function ws_restore ()
+{
+ ws_save
+ if [ $1 == 1 ]; then
+ rp_call gselect default
+ else
+ rp_call gselect ws$1
+ fi
+ rp_call echo Workspace $1
+ rp_call frestore `rp_call getenv fs$1`
+ rp_call setenv ws $1
+}
+
+function ws_bindings ()
+{
+ # Use $0 so we know the name and location of the script to call.
+ rp_call bind M-1 exec $0 1
+ rp_call bind M-2 exec $0 2
+ rp_call bind M-3 exec $0 3
+ rp_call bind M-4 exec $0 4
+ rp_call bind M-5 exec $0 5
+ rp_call bind M-6 exec $0 6
+ rp_call bind M-7 exec $0 7
+}
+
+if [ -z $@ ]; then
+ echo "Usage:"
+ echo "$0 -i -- initialize the workspaces"
+ echo "$0 -b -- setup some key bindings"
+ echo "$0 <n> -- Switch to workspace n"
+else
+ if [ $1 == -i ]; then
+ ws_init
+ elif [ $1 == -b ]; then
+ ws_bindings
+ else
+ ws_restore $1
+ fi
+fi