From e2282bd77f041430c510203365b18436a60d0586 Mon Sep 17 00:00:00 2001 From: Hatem Nassrat Date: Mon, 23 Feb 2009 09:57:18 -0400 Subject: Allowing for next and prev workspace switching. --- contrib/rpws | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/contrib/rpws b/contrib/rpws index 089e0a2..4408734 100755 --- a/contrib/rpws +++ b/contrib/rpws @@ -1,5 +1,11 @@ #!/usr/bin/perl -w +# +# Copyright (c) 2009 Hatem Nassrat +# All rights reserved. Modifications under same license as original script. +# ChangeLog: +# +# Added C-M-Right and C-M-Left for next and prev workspace # # Copyright (c) 2005 Mike O'Connor # All rights reserved. @@ -72,6 +78,9 @@ sub ws_init rp_call( "setenv fspl1 $fd" ); rp_call( "setenv wspl 1" ); + # Keep track of workspace count + rp_call( "setenv wspc $num" ); + # restore the frames rp_call( "frestore $fd" ); @@ -94,6 +103,22 @@ sub ws_restore ws_save(); + if ( $which =~ /^(?:next|prev)$/ ) + { + my $ws = rp_call( "getenv wspl" ); + my $wspc = rp_call( "getenv wspc" ); + + if ( $which eq 'next' ) + { + $ws++; + } + else + { + $ws--; + } + $which = ( ( $ws - 1 ) % $wspc ) + 1; + } + if( $which == 1 ) { rp_call( "gselect default" ); @@ -115,6 +140,8 @@ sub add_aliases foreach my $i (1..$n) { rp_call ( "alias rpws$i exec $0 $i" ); } + rp_call ( "alias rpwsn exec $0 next" ); + rp_call ( "alias rpwsp exec $0 prev" ); } sub add_keys @@ -123,6 +150,8 @@ sub add_keys foreach my $i (1..$n) { rp_call ( "definekey top M-F$i rpws$i" ); } + rp_call ( "definekey top C-M-Right rpwsn" ); + rp_call ( "definekey top C-M-Left rpwsp" ); } my $arg = shift @ARGV || 'help'; @@ -170,7 +199,8 @@ Add the following line in ~/.ratpoisonrc exec /path/to/rpws init 6 -k This creates 6 aliases rpws1, rpws2, etc. It also binds the keys M-F1, -M-F2, etc to each rpwsN alias. +M-F2, etc to each rpwsN alias. Moreover, rpwsn (Next) and rpwsp (Prev) are +created, and C-M-{Right,Left} are bound to rpws{n,p}. =head1 FILES -- cgit v1.2.3