diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/Makefile.am | 24 | ||||
-rwxr-xr-x | contrib/allwindows.sh | 38 | ||||
-rw-r--r-- | contrib/clickframe.pl | 79 | ||||
-rw-r--r-- | contrib/expose.pl | 282 | ||||
-rwxr-xr-x | contrib/genrpbindings | 207 | ||||
-rw-r--r-- | contrib/nogaps.el | 16 | ||||
-rw-r--r-- | contrib/ratpoison.el | 199 | ||||
-rw-r--r-- | contrib/rpbatch.pl | 14 | ||||
-rw-r--r-- | contrib/rpshowall.sh | 78 | ||||
-rwxr-xr-x | contrib/rpws | 343 | ||||
-rw-r--r-- | contrib/sloppy.c | 109 | ||||
-rwxr-xr-x | contrib/split.sh | 52 | ||||
-rw-r--r-- | contrib/unrat.c | 101 |
13 files changed, 0 insertions, 1542 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am deleted file mode 100644 index 5ae7445..0000000 --- a/contrib/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2000, 2001, 2002, 2003, 2004 Shawn Betts <sabetts@vcn.bc.ca> -# -# This file is part of ratpoison. -# -# ratpoison is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# ratpoison is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -bin_SCRIPTS = rpws - -pkgdata_DATA = ratpoison.el split.sh genrpbindings rpws allwindows.sh clickframe.pl rpshowall.sh unrat.c sloppy.c -EXTRA_DIST = ratpoison.el split.sh genrpbindings rpws allwindows.sh clickframe.pl rpshowall.sh unrat.c sloppy.c -MAINTAINERCLEANFILES = Makefile.in diff --git a/contrib/allwindows.sh b/contrib/allwindows.sh deleted file mode 100755 index a1c291b..0000000 --- a/contrib/allwindows.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# Copyright (C) 2003 Rupert Levene -# Author: Rupert Levene <r.levene@lancaster.ac.uk> - -# List all groups and the windows in each group. - -# we want to cope with spaces in group names -IFS=' -' - -#initialize our list -list='' - -# Allow external scripts to tell it where ratpoison is -if [ -z "$RATPOISON" ]; then - RATPOISON=ratpoison -fi - -GROUPLIST=$($RATPOISON -c groups) -SED_GET_NUM='s/^\([0-9]*\).*/\1/' - -FIRSTGROUPNUM=$(echo "$GROUPLIST"|head -n 1|sed -e "$SED_GET_NUM") -LASTGROUP=$(echo "$GROUPLIST"|tail -n 1) -CURRENTGROUPNUM=$(echo "$GROUPLIST"|grep '^[0-9]*\*'|sed -e "$SED_GET_NUM") - -$RATPOISON -c "gselect $FIRSTGROUPNUM" - -for i in $GROUPLIST; do - list=$(printf '%s%s\n%s' "$list" "$i" "$($RATPOISON -c windows|sed -e 's/^/ /')"); - if [ "$i" != "$LASTGROUP" ]; then - list="${list} -" - fi - $RATPOISON -c gnext -done; - -$RATPOISON -c "echo $list" -$RATPOISON -c "gselect $CURRENTGROUPNUM" diff --git a/contrib/clickframe.pl b/contrib/clickframe.pl deleted file mode 100644 index 4268074..0000000 --- a/contrib/clickframe.pl +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env perl -# -# Copyright (C) 2003,2004 Shawn Betts -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# notice and this notice are preserved. -# -# clickframe.pl is a utility to switch frames by clicking the -# mouse. You must apply the patch below to xbindkeys for this script -# to work. And add an entry like this to your .xbindkeysrc file: -# -# # bind C-mouse1 to ratpoison click focus hack -# "perl /home/sabetts/src/ratpoison/contrib/clickframe.pl &" -# control + b:1 -# -# Requires xbindkeys-1.6.4 with the patch at the end of this file -# applied. This file can be fed directly to patch. - -# Make sure the env vars are there -$ENV{XBINDKEYS_BUTTONLOC} || die '$XBINDKEYS_BUTTONLOC not bound'; - -# Parse the required environment variables -$ratpoison_bin = $ENV{RATPOISON} || 'ratpoison'; -($x_loc,$y_loc) = split(/,/, $ENV{XBINDKEYS_BUTTONLOC}); - -# Rip the frameset from ratpoison -$frameset = `$ratpoison_bin -c fdump`; -@framelist = split(/,/,$frameset); - -# Check each frame to see if the mouse was clicked in that frame. -# FIXME: it goes through all the frames even if it found one. -foreach $frame (@framelist) { - ($num,$left,$top,$width,$height,$win,$access) = split(/ /,$frame); - if ($x_loc > $left && $x_loc < $left + $width && $y_loc > $top && $y_loc < $top + $height) { - # Tell ratpoison to switch to the frame - print "User clicked in frame $num\n"; - system ("$ratpoison_bin -c \"fselect $num\""); - } -} - -__END__ - ---- xbindkeys.c~ 2003-04-06 08:43:27.000000000 -0700 -+++ xbindkeys.c 2003-09-24 11:46:20.000000000 -0700 -@@ -143,7 +143,15 @@ - - - -+void -+add_button_env (int x, int y) -+{ -+ char *env; - -+ env = malloc (256 * sizeof (char)); -+ snprintf (env, 255, "XBINDKEYS_BUTTONLOC=%d,%d", x, y); -+ putenv (env); -+} - - - static void -@@ -240,6 +248,8 @@ - | Button1Mask | Button2Mask | Button3Mask - | Button4Mask | Button5Mask); - -+ add_button_env (e.xbutton.x, e.xbutton.y); -+ - for (i = 0; i < nb_keys; i++) - { - if (keys[i].type == BUTTON && keys[i].event_type == PRESS) -@@ -266,6 +276,8 @@ - | Button1Mask | Button2Mask | Button3Mask - | Button4Mask | Button5Mask); - -+ add_button_env (e.xbutton.x, e.xbutton.y); -+ - for (i = 0; i < nb_keys; i++) - { - if (keys[i].type == BUTTON && keys[i].event_type == RELEASE) diff --git a/contrib/expose.pl b/contrib/expose.pl deleted file mode 100644 index 0a7127e..0000000 --- a/contrib/expose.pl +++ /dev/null @@ -1,282 +0,0 @@ -#!/usr/bin/env perl -# Maintainer: Trent Buck <[EMAIL PROTECTED]> -# License: Public Domain - -# Changelog: -# 2003-11-16 cantsin rpshowall.sh -# 2003-11-19 various Misc. fixes to rpshowall -# 2003-11-20 twb expose.pl -# 2003-11-20 cantsin minor changes -# 2003-11-22 twb new algorithm, broke script -# 2004-05-21 bkhl posted on wiki -# 2004-06-22 twb full rewrite, changelog started -# 2004-06-24 twb release candidate -# 2004-07-07 twb toggle logic for fselect (line 43) -# 2005-07-05 ivan updated for the new fdump format (works with 1.4.0-beta4) - -# Description: -# Duplicates OS-X 10.3's Expose' functionality for ratpoison. -# You should apply the TWBPatch or reverse the logic at line 43. - -#-- tweaking ------------------------------------------------------------------- - -require "assert.pl"; #used for validation. -use strict; -my $N_LIMIT = 2; -my $LIMIT = 0.01; #smaller number --> slower, but more accurate -my $RATPOISON = $ENV{RATPOISON} || 'ratpoison'; - -#-- main ----------------------------------------------------------------------- - -#&th_ratio (1400, 1050, 23); -#&th_split (\&split, 5, (0, 0, 1400, 1050)); - -# my $id = &xid2num(8388638); -# print "'$id'\n"; -# exit 0; - -my @xids = &rp('windows %i'); chomp @xids; -my $n = @xids; #@ in $ context evals to length of @. -my $frames_old = &rp('fdump'); chomp $frames_old; -my @r; # Sub-optimal way of grabbing screen x,y,w,h. - -#fixed to use sdump -($_, $r[0], $r[1], $r[2], $r[3]) = split(/ /,&rp ('sdump')); - -my $ret = join(", ", &rp_split(\@xids, \&split, $n, \@r)); - -&rp("frestore $ret"); - -$ret = &rpi('fselect'); - -&rp('only'); - -#-- subroutines ---------------------------------------------------------------- - -#-- rp-specific -------------------------------------------- - -sub rp { return `$RATPOISON -c "@_"`; } -sub rpi { return `$RATPOISON -i -c "@_"`; } - -sub rpb { - my @accum = (); - for (@_) - { - push @accum, "-c \"$_\""; - } - return `$RATPOISON @accum`; -} - -sub rp_split -{ - # Prints partitions in :fdump format. - my ($xids, $alg, $n, $r) = @_; - my @ret = (); - my $num = 0; - my $i; - - foreach $i (&$alg($n, @$r)) - { - my ($x, $y, $w, $h) = @$i; - my $xid = pop(@$xids); - push @ret, "(frame :number $num :x $x :y $y :width $w :height $h :window $xid)"; - $num++; - } - return @ret; -} - - -# sub frame2xid { -# my ($fnum) = @_; -# my ($frame, $num, $xid); -# foreach $frame ( split(/,/, &rp('sfdump')) ) -# { -# ($num, $_, $_, $_, $_, $xid) = split(/ /, $frame); -# if ($num eq $fnum) -# { -# chomp $xid; -# return $xid; -# } -# } -# return -1; # canthappen -# } - -# sub xid2num { -# my ($xid) = @_; -# my @windows = &rp('windows %i %n'); -# my ($window, $id, $num); -# foreach $window ( @windows ) -# { -# ($id, $num) = split(/ /, $window); -# if ($id eq $xid) -# { -# chomp $num; -# return $num; -# } -# } -# return -1; # canthappen -# } - - -#-- generic ------------------------------------------------ - - -sub isint { #from http://google.com/groups?selm=BECK.95Oct20135611%40visi5.qtp.ufl.edu - my $x = shift; - return 0 if ($x eq ""); - my $sign ='^\s* [-+]? \s*'; - my $int ='\d+ \s* $ '; - return ($x =~ /$sign $int/x) ? 1 : 0; -} - - -sub isnum { #from http://google.com/groups?selm=90ra0g%24u0m%241%40nnrp1.deja.com - my $x = shift; - return ($x eq $x+0) ? 1:0; -} - -sub ratio { - my ($t, $n) = @_; - my $ret = 1; - my $i; - &assert(&isnum($t) and &isint($n) and $n >= 0); - - for $i ( 2 .. $n ) - { - if ( &isint($n / $i) # $j must also be an integer. - and abs(($i**2 / $n) - $t) < abs(($ret**2 / $n) - $t) ) - { - $ret = $i; - } - } - #Third return value is `error', used by split(). - return ( $ret, $n / $ret, abs(($ret**2 / $n) - $t)); -} - -sub hsplit ($@) { - my ($n, $rx, $ry, $rw, $rh) = @_; - my @ret = (); - my $i; - &assert(isint($n) and $n >= 0); - &assert(isint($rx) and isint($ry) and isint($rw) and isint($rh)); - &assert($rx>=0 and $ry>=0 and $rw>0 and $rh>0); - &assert($rw >= $n); - - # remove remainder from rw, add to the last rectangle. - my $rem = $rw % $n; - $rw -= $rem; - &assert(0 == $rw % $n); - - for $i (1 .. $n) - { - push @ret, [ ($rx + ($i-1)*$rw/$n, - $ry, - $rw/$n + ($i==$n?$rem:0), - $rh) ]; - } - return @ret; -} - -sub vsplit ($@) { - my ($n, $rx, $ry, $rw, $rh) = @_; - my @ret = (); - my $i; - &assert(isint($n) and $n >= 0); - &assert(isint($rx) and isint($ry) and isint($rw) and isint($rh)); - &assert($rx>=0 and $ry>=0 and $rw>0 and $rh>0); - &assert($rh >= $n); - - # remove remainder from rh, add to the last rectangle. - my $rem = $rh % $n; - $rh -= $rem; - &assert(0 == $rh % $n); - - for $i (1 .. $n) - { - push @ret, [ ($rx, - $ry + ($i-1)*$rh/$n, - $rw, - $rh/$n + ($i==$n?$rem:0)) ]; - } - return @ret; -} - -sub boxsplit ($@) { - my ($n, $rx, $ry, $rw, $rh) = @_; - my @ret = (); - my ($rows, $cols) = &ratio($rw/$rh, $n); - my $i; - &assert(isint($n) and $n >= 0); - &assert(isint($rx) and isint($ry) and isint($rw) and isint($rh)); - &assert($rx>=0 and $ry>=0 and $rw>0 and $rh>0); - &assert(($rh * $rw) >= $n); - - foreach $i (&vsplit($rows, ($rx, $ry, $rw, $rh))) - { - @ret = (@ret, &hsplit($cols, @$i)); - } - return @ret; -} - -sub split ($@) { - my ($n, $rx, $ry, $rw, $rh) = @_; - my ($rows, $cols, $prox) = &ratio($rw/$rh, $n); - - # if base case, palm off to boxsplit() - if ($n < $N_LIMIT or $prox < $LIMIT) - { - return &boxsplit($n, $rx, $ry, $rw, $rh); - } - else - { - my @ret = (); - my $nA = int($n/2); #fixme: int() is bad. Use POSIX::floor? - my $x = $nA / ($n - $nA); - my $i; - &assert(isint($n) and $n >= 0); - &assert(isint($rx) and isint($ry) and isint($rw) and isint($rh)); - &assert($rx>=0 and $ry>=0 and $rw>0 and $rh>0); - &assert(($rh * $rw) >= $n); - - if ($rw > $rh) # Divide the larger dimension - { - my $k = int($rw * $x / (1 + $x)); #fixme: bad int(). - @ret = (@ret, &split($nA, ($rx, $ry, $k, $rh))); - @ret = (@ret, &split($n - $nA, ($rx+$k, $ry, $rw-$k, $rh))); - } - else - { - my $k = int($rh * $x / (1 + $x)); #fixme: bad int(). - @ret = (@ret, &split($nA, ($rx, $ry, $rw, $k ))); - @ret = (@ret, &split($n - $nA, ($rx, $ry+$k, $rw, $rh-$k))); - } - return @ret; - } -} - -#-- test harnesses ------------------------------------------------------------- - -# Commented out to speed up compilation. - -# sub th_ratio -# { -# my ($num, $denom, $n) = @_; -# my ($row, $col, $prox) = &ratio ($num / $denom, $n); -# print "$n = $row * $col, proximity $prox\n"; -# } - -# sub th_split -# { # Prints partitions as a SVG. See inkscape.org for info. -# my ($alg, $n, @r) = @_; -# my $i; - -# print "<svg width=\"$r[2]\" height=\"$r[3]\">\n"; -# foreach $i (&$alg($n, @r)) -# { -# my ($x, $y, $w, $h) = @$i; -# print "<rect x=\"$x\"\ty=\"$y\"\twidth=\"$w\"\theight=\"$h\"", -# " style=\"fill:white;stroke:black;\"/>\n"; -# } -# print "</svg>\n"; -# } - diff --git a/contrib/genrpbindings b/contrib/genrpbindings deleted file mode 100755 index 0f924d3..0000000 --- a/contrib/genrpbindings +++ /dev/null @@ -1,207 +0,0 @@ -#!/usr/bin/env perl -# genrpbindings -- generate ratpoison bindings for various languages -# -# Copyright (C) 2003, 2004 Ryan Yeske, Doug Kearns, Shawn Betts -# -# currently generates bindings for: -# * Perl (Ratpoison.pm) Ryan Yeske <rcyeske@sfu.ca> -# * Emacs Lisp (ratpoison-cmd.el) Ryan Yeske <rcyeske@sfu.ca> -# * Ruby (ratpoison.rb) Doug Kearns <djkea2@mugc.its.monash.edu.au> -# * Common Lisp (ratpoison.lisp) Shawn Betts <sabetts@vcn.bc.ca> -# * Python (ratpoison.py) Mike O'Connor <stew@vireo.org> -# add more languages! -# -# Bindings are just very thin wrappers, no argument checking is done. -# All of the functions return a string. -# -# Example: ratpoison --command='echo hello world' -# -# #!perl -# use Ratpoison; -# Ratpoison::echo ("hello world") -# -# ;;; elisp -# (require 'ratpoison-cmd) -# (ratpoison-echo "hello world") -# -# #!ruby -# require "ratpoison" -# Ratpoison.echo ("hello world") -# -# ;;; Common Lisp -# (load "ratpoison.lisp") -# (ratpoison:rp-echo "hello world") -# -# #!python -# import ratpoison -# ratpoison.echo( "hello world" ) - -use warnings; - -$\="\n"; - -# set this to your rp binary -$RATPOISON=$ENV{RATPOISON} || "ratpoison"; - -# open source file -$ACTIONS_C="../src/actions.c"; -open ACTIONS_C or die "Can't open $ACTIONS_C"; - -# open target files -$PERL_FILE="./Ratpoison.pm"; -$ELISP_FILE="./ratpoison-cmd.el"; -$RUBY_FILE="./ratpoison.rb"; -$COMMONLISP_FILE="./ratpoison.lisp"; -$PYTHON_FILE="./ratpoison.py"; -open PERL, ">$PERL_FILE" or die "Can't create $PERL_FILE"; -open ELISP, ">$ELISP_FILE" or die "Can't create $ELISP_FILE"; -open RUBY, ">$RUBY_FILE" or die "Can't create $RUBY_FILE"; -open COMMONLISP, ">$COMMONLISP_FILE" or die "Can't create $COMMONLISP_FILE"; -open PYTHON, ">$PYTHON_FILE" or die "Can't create $PYTHON_FILE"; - -# PERL preamble -print PERL 'package Ratpoison;'; -print PERL '$RATPOISON="',$RATPOISON,'";'; -print PERL 'sub command { my $a = "@_"; $a =~ s/(\')/\'\\\\\'\'/g; return `$RATPOISON -c \'$a\'`; }'; - -# ELISP preamble -print ELISP '(defvar ratpoison-program "',$RATPOISON,'")'; -print ELISP <<PREAMBLE; - -(defmacro defun-ratpoison (cmd) - `(progn (defun ,(intern (concat "ratpoison-" (symbol-name cmd))) (&rest args) - (apply 'ratpoison-cmd ,(symbol-name cmd) args)))) - -(defun ratpoison-cmd (cmd &rest args) - (with-temp-buffer - (call-process ratpoison-program nil (current-buffer) t - "-c" (format "%s %s" - cmd - (mapconcat (lambda (x) - (if (stringp x) - x - (prin1-to-string x))) - args " "))) - (buffer-substring (point-min) (if (> (point-max) 1) - (- (point-max) 1) - (point-max))))) -PREAMBLE - -# RUBY preamble -print RUBY <<PREAMBLE; -module Ratpoison - - RATPOISON="$RATPOISON" - - def command(command, *args) - return `#{RATPOISON} -c "#{command} #{args.join(' ')}"` - end - module_function :command -PREAMBLE - -# Scheme preamble - -print COMMONLISP <<PREAMBLE; -(defpackage :ratpoison - (:use :cl)) - -;; Needs the CLOCC PORT package -(asdf:operate 'asdf:load-op :port) - -(in-package :ratpoison) - -(defvar ratpoison-program "$RATPOISON") - -(defmacro defun-ratpoison (cmd) - (let ((sym (intern (concatenate 'string "RP-" (symbol-name cmd))))) - `(progn (defun ,sym (&rest args) - (apply 'ratpoison-cmd ,(string-downcase (symbol-name cmd)) args)) - (export ',sym)))) - -(defun ratpoison-cmd (cmd &rest args) - (labels ((mapconcat (fn list sep) - (apply 'concatenate 'string - (loop for x on list - collect (if (cdr x) - (concatenate 'string (funcall fn (car x)) sep) - (funcall fn (car x)))))) - (build-cmd (cmd args) - (mapconcat (lambda (x) - (if (stringp x) - x - (prin1-to-string x))) - (nconc (list cmd) args) " "))) - (let ((stream (port:pipe-input ratpoison-program - "-c" (build-cmd cmd args)))) - (do ((line (read-line stream nil nil) - (read-line stream nil nil)) - (accum nil (cons line accum))) - ((null line) accum))))) -PREAMBLE - -# python preamble - -print PYTHON <<PREAMBLE; -import os -ratpoison="ratpoison -c " -def rp_command( *args ): - p = os.popen( ratpoison + '"' + (' '.join( args ) ) + '"', 'r' ) - r = p.readlines(); - p.close(); - return r - -PREAMBLE - -# bindings -while (<ACTIONS_C>) { - if (m!/\*\@begin !) { - while (<ACTIONS_C>) - { - last if (m!/\*\@end !); - if (/\s*add_command\s*\(\"([^\"]+)\",\s*[^\"]+,\s*([0-9]+),\s*[0-9]+,\s*([0-9]+)/) { - my $name = $1; - my $numargs = $2; - my $optargs = $3; - - # Skip the arguments - for (my $i=0; $i<$numargs; $i++) { - <ACTIONS_C>; - } - - $nbindings++; - print PERL "sub $name { return command (\"$name\", \@_); }"; - print ELISP "(defun-ratpoison $name)"; - print COMMONLISP "(defun-ratpoison $name)"; - print RUBY " def $name(*args)"; - print RUBY " return command(\"$name\", args)"; - print RUBY " end"; - print RUBY " module_function :$name\n"; - print PYTHON "def rp_$name( *args ): return rp_command ( '$name ' + ' '.join( args ) )"; - } - } - } -} -print "$nbindings bindings."; - -# PERL postamble -# nothing - -# ELISP postamble -print ELISP '(provide \'ratpoison-cmd)'; - -# RUBY postamble -print RUBY "end"; - -# PYTHON postamble -# nothing - -close PERL; -print "Created $PERL_FILE"; -close ELISP; -print "Created $ELISP_FILE"; -close RUBY; -print "Created $RUBY_FILE"; -close COMMONLISP; -print "Created $COMMONLISP_FILE"; -close PYTHON; -print "Created $PYTHON_FILE"; diff --git a/contrib/nogaps.el b/contrib/nogaps.el deleted file mode 100644 index 033c963..0000000 --- a/contrib/nogaps.el +++ /dev/null @@ -1,16 +0,0 @@ -;;; Copyright (C) 2003, 2004 Shawn Betts -;;; -;;; Copying and distribution of this file, with or without modification, -;;; are permitted in any medium without royalty provided the copyright -;;; notice and this notice are preserved. - -(eval-when-compile - (require 'cl)) - -(require 'ratpoison-cmd) - -(defun ratpoison-nogaps () - (let ((wins (mapcar 'string-to-number (split-string (ratpoison-windows "%n"))))) - (loop for n in wins - for i from 1 to (length wins) - do (ratpoison-number i n)))) diff --git a/contrib/ratpoison.el b/contrib/ratpoison.el deleted file mode 100644 index 993ca7f..0000000 --- a/contrib/ratpoison.el +++ /dev/null @@ -1,199 +0,0 @@ -;;; ratpoison.el --- ratpoison support for Emacs -;; -;; Copyright (C) 2003 Gergely Nagy, Shawn Betts, Jay Belanger -;; -;; Authors: Gergely Nagy <algernon@debian.org>, -;; Shawn Betts <sabetts@users.sourceforge.net>, -;; Jay Belanger <belanger@truman.edu>, -;; Maintainer: Gergely Nagy <algernon@debian.org> -;; Version: 0.2 -;; Keywords: faces, ratpoison, X -;; CVS Id: $Id: ratpoison.el,v 1.5 2006/03/16 00:33:34 sabetts Exp $ -;; Last updated: <2001/10/05 17:58:38 algernon> - -;; This file is NOT part of GNU Emacs. - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2 of -;; the License, or (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public -;; License along with this program; if not, write to the Free -;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, -;; MA 02111-1307 USA - -;;; Commentary: -;; -;; This file provides a major mode for editing .ratpoisonrc files, and -;; functions to access ratpoison from within Emacs. - -;;; History: -;; Version 0.2: -;; - Added command-interpreter (from Shawn and Jay) -;; - Added info-lookup functions (from Jay) -;; - renamed to ratpoison.el -;; - far better font-locking -;; Version 0.1: -;; - initial version - -;;; Todo: -;; - auto-completion of commands -;; - probably a bunch of other things - -(require 'font-lock) -(require 'generic-x) - -(defvar ratpoison-commands-0 - (list - "abort" - "banish" - "clock" - "curframe" - "delete" - "focus" - "focusup" - "focusdown" - "focusleft" - "focusright" - "meta" - "help" - "info" - "kill" - "lastmsg" - "redisplay" - "restart" - "next" - "only" - "other" - "prev" - "quit" - "remove" - "split" - "hsplit" - "version" - "vsplit" - )) - -(defvar ratpoison-commands-rest - (list - "bind" - "chdir" - "colon" - "defbarloc" - "msgwait" - "defborder" - "deffont" - "definputwidth" - "defmaxsizepos" - "defpadding" - "deftranspos" - "defwaitcursor" - "defwinfmt" - "defwinname" - "defwinpos" - "deffgcolor" - "defbgcolor" - "escape" - "echo" - "exec" - "newwm" - "number" - "pos" - "rudeness" - "select" - "setenv" - "source" - "startup_message" - "title" - "unbind" - "unsetenv" - "windows" - )) - -;; ratpoisonrc-mode -(define-generic-mode 'ratpoisonrc-mode - ;; comments - (list ?#) - ;; keywords - nil - ;; font-lock stuff - (list - ;; commands without arguments - (generic-make-keywords-list - ratpoison-commands-0 font-lock-builtin-face "^[ \t]*") - ;; commands with arguments - (generic-make-keywords-list - ratpoison-commands-rest font-lock-builtin-face "^[ \t]*" "[ \t]+") - ;; exec <arg> - (list "^[ \t]*\\(exec\\)[ \t]+\\(.*\\)" - '(1 'font-lock-builtin-face) - '(2 'font-lock-string-face)) - ;; arguments, the first is a keyword, the rest is tring - (list (concat - (car (generic-make-keywords-list - ratpoison-commands-rest font-lock-builtin-face "^[ \t]*" "[ \t]+")) - "\\([0-9a-zA-Z\\/\\.\\-]+\\)[ \t]*\\(.*\\)") - '(2 'font-lock-keyword-face) - '(3 'font-lock-string-face))) - ;; auto-mode alist - (list "\\.ratpoisonrc\\'") - ;; additional setup functions - (list 'ratpoisonrc-mode-setup) - "Generic mode for ratpoison configuration files.") - -(defun ratpoisonrc-mode-setup() - (defvar ratpoisonrc-mode-keymap (make-sparse-keymap) - "Keymap for ratpoisonrc-mode") - (define-key ratpoisonrc-mode-keymap "\C-c\C-e" 'ratpoison-line) - (use-local-map ratpoisonrc-mode-keymap)) - -(provide 'ratpoisonrc-mode) - -;; Ratpoison access -; Groups & Variables -(defgroup ratpoison nil "Ratpoison access" - :group 'languages - :prefix "ratpoison-") - -(defcustom ratpoison-program "ratpoison" - "The command to call the window manager." - :group 'ratpoison - :type 'string) - -; Command stuff -(defun ratpoison-command (command) - (interactive "sRP Command: ") - (call-process ratpoison-program nil nil nil "-c" command)) - -(defun ratpoison-command-on-region (start end) - (interactive "r") - (mapcar 'ratpoison-command - (split-string (buffer-substring start end) - "\n"))) - -(defun ratpoison-line () - "Send the current line to ratpoison." - (interactive) - (ratpoison-command - (buffer-substring-no-properties - (line-beginning-position) - (line-end-position)))) - -;; Documentation -(defun ratpoison-manual () - "Call up the ratpoison info page." - (interactive) - (info "ratpoison")) - -(defun ratpoison-manual-commands () - "Call up the info page listing the ratpoison commands." - (interactive) - (info "(ratpoison) Commands")) - -(provide 'ratpoison) diff --git a/contrib/rpbatch.pl b/contrib/rpbatch.pl deleted file mode 100644 index 0f1c50e..0000000 --- a/contrib/rpbatch.pl +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env perl -# -# Copyright (C) 2003 Shawn Betts -# Execute a sequence of commands read from stdin. - -$ratpoison = $ENV{RATPOISON} || 'ratpoison'; - -while (<>) { - chomp; - push @accum, "-c"; - push @accum, "\"$_\""; -} - -system ("$ratpoison @accum"); diff --git a/contrib/rpshowall.sh b/contrib/rpshowall.sh deleted file mode 100644 index 458f2fa..0000000 --- a/contrib/rpshowall.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -# rpshowall -# ratpoison script to show all open windows -# Copyright (C) 2003 Florian Cramer <cantsin@zedat.fu-berlin.de> - -# Usage : -# -# rpshowall [no arguments] -# if called from a terminal, show all open windows and -# restore previous frame layout upon keystroke -# -# rpshowall [n>1] -# show all open windows for n seconds, -# then restore previous frame layout -# -# rpshowall 0 -# show all open windows, do not restore previous frame layout - -if [ -z "$RATPOISON" ]; then - RATPOISON=ratpoison -fi - -# Parse input argument - -case $# in - 0) wait=-1 - ;; - 1) - wait=$1 - ;; - *) - printf '%s\n' "Usage: $0 [sleep_seconds]" >&2 - exit 1 - ;; -esac - -# Save current frameset - -framecount=`$RATPOISON -c windows | wc -l | sed -e "s/[ ]*//g"` -curframe=`$RATPOISON -c windows | grep "^[0-9]*\*" | sed -e "s/^\([0-9]*\).*/\1/"` -curlayout=`$RATPOISON -c fdump` - - -# Create split view of all open windows - -$RATPOISON -c only -i=2 -while [ "$i" -le "$framecount" ]; do - if [ "$i" -le $(($framecount/2)) ] ; then - $RATPOISON -c vsplit - else - $RATPOISON -c hsplit - fi - $RATPOISON -c focus - $RATPOISON -c focus - i=$(($i+1)); -done - -# Depending on the argument the script was executed with, -# 1- select a new window and exit opening it fullscreen -# 2- restore frameset after keyboard input -# 3- restore frameset after $wait seconds of delay - -$RATPOISON -c "select $curframe" -if [ $wait -eq 0 ]; then - $RATPOISON -i -c fselect - $RATPOISON -c only -else - $RATPOISON -i -c windows - if [ "$wait" -eq -1 ]; then - printf '%s' "Hit return to restore window layout. " - read i - else - sleep "$wait" - fi - $RATPOISON -c "frestore $curlayout" -fi diff --git a/contrib/rpws b/contrib/rpws deleted file mode 100755 index 49105c5..0000000 --- a/contrib/rpws +++ /dev/null @@ -1,343 +0,0 @@ -#!/usr/bin/env perl - -# -# Copyright (c) 2009 Hatem Nassrat <hnassrat@gmail.com> -# All rights reserved. Modifications under same license as original script. -# ChangeLog: -# -# Added C-M-Right and C-M-Left for next and prev workspace -# Added move window to next prev workspace -# Added dump/restore workspaces -# -# Copyright (c) 2005 Mike O'Connor -# All rights reserved. -# Author Mike O'Connor <stew@vireo.org> -# -# Modified by Shawn Betts. -# -# code was adapeted from rpws that comes from ratpoison containing the follwing copyright: -# Copyright (C) 2003 Shawn Betts -# Author: Shawn Betts -# - -use strict; -use warnings; -use Fcntl qw (:flock); -use Getopt::Std; - -my $ratpoison = $ENV{ "RATPOISON" } || "ratpoison"; -my $tmp=$ENV{ "TMP" } || "/tmp"; -my $lockfile = $ENV{ "RPWS_LOCKFILE" } || "$tmp/rpws.$<.lock"; - -sub help -{ - system("pod2usage", $0); - print( "for more detailed documentation run \"perldoc $0\"\n" ); -} - -sub rp_call -{ - my $result = `$ratpoison -c "@_"`; - chomp( $result ); - chomp( $result ); - return $result; -} - -sub ws_init_ws -{ - - my $num = shift; - - rp_call( "gnew wspl$num" ); - my $fd = fdump(); - rp_call( "setenv fspl$num $fd" ); -} - -sub fdump -{ - return rp_call( "fdump" ); -} - -sub ws_init -{ - my $num = shift; - - $num >= 2 || die "You must create at least 2 workspaces."; - - # Backup the frames - my $fd = fdump(); - - rp_call( "select -" ); - rp_call( "only" ); - - my $i; - for my $i (2..$num) - { - ws_init_ws( $i ); - } - - # Workspace 1 uses the 'default' group. - # Start in workspace 1. - $fd = fdump(); - rp_call( "gselect default" ); - 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" ); - - if( -e "$lockfile" ) - { - unlink ("$lockfile" ); - } -} - -sub ws_save -{ - my $ws = rp_call( "getenv wspl" ); - my $fd = fdump(); - rp_call( "setenv fspl$ws $fd" ); -} - -sub ws_restore -{ - my $which = shift; - my $which_name; - my $move; - - # Step1: determine which workspace to move to - - if ( $which =~ /^move/ ) - { - $move = 1; - $which = substr($which, 4); - } - - 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 ) - { - $which_name = "default"; - } - else - { - $which_name = "wspl$which"; - } - - # Step 2a: Moving Window if necessary - if ( $move ) - { - rp_call( "gmove $which_name" ); - rp_call( "select -" ); - rp_call( "prev" ); - } - - # Step2: Process the workspace switch - ws_save(); - rp_call( "gselect $which_name"); - my $last = rp_call( "getenv fspl$which" ); - rp_call( "frestore $last" ); - rp_call( "setenv wspl $which" ); - - # Step 2x: Display the moved Window - if ( $move ) - { - rp_call( "next" ); - } - - rp_call( "echo Workspace $which" ); - -} - -sub ws_dump -{ - my $ws_dumpf = shift; - my $wspc = rp_call( "getenv wspc" ); - - open WSDUMP, ">$ws_dumpf" or die $!; - - ws_save(); - - for my $i (1..$wspc) - { - print WSDUMP rp_call( "getenv fspl$i" )."\n"; - } - - close WSDUMP; - - rp_call( "echo Workspaces dumped to $ws_dumpf" ); -} - -sub ws_dumprestore -{ - my $ws_dumpf = shift; - my $ws = rp_call( "getenv wspl" ); - my $wspc = rp_call( "getenv wspc" ); - - # Get dumped frame info - open WSDUMP, "$ws_dumpf" or die $!; - my @wsdata=<WSDUMP>; - close WSDUMP; - - my $wspc_dump = scalar @wsdata; - - if ($wspc < $wspc_dump) - { - # Number of workspaces to restore more than available - die "Cannot restore all workspaces (dump_count = " . $wspc_dump . ", rp_count = " . $wspc . ")"; - } - - # Restoring all workspaces - for my $i (1..$wspc_dump) - { - # calculating previous workspace number - my $j = ( $wspc + $i - 2 ) % $wspc + 1; - # moving to workspace $i -1 - ws_restore( $j ); - # restoring workspace $i - rp_call( "setenv fspl$i $wsdata[$i-1]" ); - } - - # goto the originally visible workspace - ws_restore( $ws ); - - rp_call( "echo Workspaces loaded from $ws_dumpf" ); -} - -sub add_aliases -{ - my $n = shift; - foreach my $i (1..$n) { - # Switch Workspace - rp_call ( "alias rpws$i exec $0 $i" ); - # Move Window to wrokspace - rp_call ( "alias rpwsm$i exec $0 move$i" ); - } - rp_call ( "alias rpwsn exec $0 next" ); - rp_call ( "alias rpwsp exec $0 prev" ); - rp_call ( "alias rpwsmn exec $0 movenext" ); - rp_call ( "alias rpwsmp exec $0 moveprev" ); - - -} - -sub add_keys -{ - my $n = shift; - foreach my $i (1..$n) { - # Switch Workspace - rp_call ( "definekey top M-F$i rpws$i" ); - # Move Window to wrokspace - rp_call ( "definekey top C-M-S-F$i rpwsm$i" ); - } - rp_call ( "definekey top C-M-Right rpwsn" ); - rp_call ( "definekey top C-M-Left rpwsp" ); - rp_call ( "definekey top C-M-greater rpwsmn" ); - rp_call ( "definekey top C-M-less rpwsmp" ); -} - -my $arg = shift @ARGV || 'help'; - -if( $arg eq "help" ) { - help(); -} elsif( $arg eq "init" ) { - my $num = shift @ARGV; - my %opts; - ws_init( $num ); - getopts('ka', \%opts); - add_aliases( $num ) if $opts{'a'} || $opts{'k'}; - add_keys ( $num ) if $opts{'k'}; -} elsif( $arg eq "dump" ) { - my $filename = shift @ARGV; - ws_dump($filename); -} elsif( $arg eq "restore" ) { - my $filename = shift @ARGV; - ws_dumprestore($filename); -} else { - open LOCK, ">>$lockfile" or die "Cannot open lockfile: $lockfile"; - flock(LOCK, LOCK_EX); - ws_restore( $arg ); -} - -__END__ - -=head1 NAME - -rpws - Implements multiple workspaces in ratpoison - -=head1 SYNOPSIS - - rpws init n [-k] [-a] - setup rpws with n workspaces. - -a sets up command aliases; - -k sets up key bindings and aliases. - rpws dump <fname> - dumps the current layout to <fname> - rpws restore <fname> - restores rpws workspaces from <fname> - rpws help - this documentation - rpws n - switch to this workspace - - -=head1 DESCRIPTION - - B<rpws> implements multiple workspaces in ratpoison by making calls - to fdump, freestore. It was adapted from rpws which comes with - ratpoison in the contrib directory. - -=head1 USAGE - -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. Moreover, rpwsn (Next) and rpwsp (Prev) are -created, and C-M-{Right,Left} are bound to rpws{n,p}. Full list of keybindings -created are: - - M-F$i Goto workspace $i - C-M-Right Goto Next workspace - C-M-Left Goto Prev workspace - C-M-S-F$i Move window to workspace $i - C-M-greater Move current window to next workspace - C-M-less Move current window to prev workspace - -=head1 FILES - - rpws requires use of a lockfile. It defaults to using -/tmp/rpws.<UID>.lock but this can be changed by setting the -environment variable RPWS_LOCKFILE to your desired lockfile. - -=head1 AUTHOR - - Mike O'Connor <stew@vireo.org> - -=head1 COPYRIGHT - - Copyright (c) 2005 Mike O'Connor - All rights reserved. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. diff --git a/contrib/sloppy.c b/contrib/sloppy.c deleted file mode 100644 index 623e57e..0000000 --- a/contrib/sloppy.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Sloppy focus - * - * Copyright (C) 2005 Shawn Betts <sabetts@vcn.bc.ca> - * - * unrat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * unrat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - */ - -#include <X11/Xos.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xproto.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/wait.h> - -int (*defaulthandler)(); - -int -errorhandler(Display *display, XErrorEvent *error) -{ - if(error->error_code!=BadWindow) - (*defaulthandler)(display,error); - return 0; -} - -int -spawn(char *cmd) -{ - int pid; - - pid = fork(); - if (pid == 0) - { - execl("/bin/sh", "sh", "-c", cmd, 0); - _exit(EXIT_FAILURE); - } - return pid; -} - -int -main (int argc, char **argv) -{ - Display *display; - int i, numscreens; - - display = XOpenDisplay(NULL); - if(!display) - { - perror("could not open display"); - exit(1); - } - - defaulthandler = XSetErrorHandler(errorhandler); - numscreens = ScreenCount(display); - - for (i=0; i<numscreens; i++) - { - unsigned int j, nwins; - Window dw1, dw2, *wins; - - XSelectInput(display,RootWindow(display, i), SubstructureNotifyMask); - XQueryTree(display, RootWindow(display, i), &dw1, &dw2, &wins, &nwins); - for (j=0; j<nwins; j++) - XSelectInput(display, wins[j], EnterWindowMask); - } - - while (1) - { - XEvent event; - do - { - XNextEvent(display,&event); - if (event.type == CreateNotify) - XSelectInput(display, event.xcreatewindow.window, EnterWindowMask); - } while(event.type != EnterNotify); - - /* A window was entered. select it. */ - { - char shell[256]; - snprintf (shell, 255, "$RATPOISON -c \"select `$RATPOISON -c 'windows %%i %%n' | grep '%ld' | awk '{print $2}'`\"", event.xcrossing.window); - //printf ("%s\n", shell); - spawn (shell); - wait (NULL); - } - } - - XCloseDisplay (display); - - return 0; -} - -/* -Local Variables: *** -compile-command: "gcc -g -Wall -O2 -I/usr/X11R6/include -o sloppy sloppy.c -L/usr/X11R6/lib -lX11" *** -End: *** -*/ diff --git a/contrib/split.sh b/contrib/split.sh deleted file mode 100755 index 1c8c009..0000000 --- a/contrib/split.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2003 Shawn Betts -# -# Copying and distribution of this file, with or without modification, -# are permitted in any medium without royalty provided the copyright -# -# Split the current frame into 16 little frames. This is an example of -# how to script ratpoison. - -if [ -z "$RATPOISON" ]; then - RATPOISON=ratpoison -fi - -# $RATPOISON -c only - -#split into 4 frames - -$RATPOISON -c split -$RATPOISON -c hsplit -$RATPOISON -c focusdown -$RATPOISON -c hsplit - -# split each new frame into 4 - -$RATPOISON -c split -$RATPOISON -c hsplit -$RATPOISON -c focusdown -$RATPOISON -c hsplit - -$RATPOISON -c focusup -$RATPOISON -c focusup - -$RATPOISON -c split -$RATPOISON -c hsplit -$RATPOISON -c focusdown -$RATPOISON -c hsplit - -$RATPOISON -c focusright -$RATPOISON -c focusright - -$RATPOISON -c split -$RATPOISON -c hsplit -$RATPOISON -c focusdown -$RATPOISON -c hsplit - -$RATPOISON -c focusdown - -$RATPOISON -c split -$RATPOISON -c hsplit -$RATPOISON -c focusdown -$RATPOISON -c hsplit diff --git a/contrib/unrat.c b/contrib/unrat.c deleted file mode 100644 index 272ed6e..0000000 --- a/contrib/unrat.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Warp the pointer to the bottom right corner of the screen any time a key is pressed. - * - * Copyright (C) 2005 Shawn Betts <sabetts@vcn.bc.ca> - * - * unrat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * unrat is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - */ - -/* -This is what I used to compile it: - -gcc -g -Wall -O2 -I/usr/X11R6/include -o unrat unrat.c -L /usr/X11R6/lib -lX11 -*/ - -#include <X11/Xos.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xproto.h> -#include <stdio.h> -#include <stdlib.h> - -int (*defaulthandler)(); - -int -errorhandler(Display *display, XErrorEvent *error) -{ - if(error->error_code!=BadWindow) - (*defaulthandler)(display,error); - return 0; -} - -int -main (int argc, char **argv) -{ - Display *display; - int i, numscreens; - - display = XOpenDisplay(NULL); - if(!display) - { - perror("could not open display"); - exit(1); - } - - defaulthandler = XSetErrorHandler(errorhandler); - numscreens = ScreenCount(display); - - for (i=0; i<numscreens; i++) - { - unsigned int j, nwins; - Window dw1, dw2, *wins; - - XSelectInput(display,RootWindow(display, i), KeyReleaseMask | SubstructureNotifyMask); - XQueryTree(display, RootWindow(display, i), &dw1, &dw2, &wins, &nwins); - for (j=0; j<nwins; j++) - XSelectInput(display, wins[j], KeyReleaseMask); - } - - while (1) - { - XEvent event; - do - { - XNextEvent(display,&event); - if (event.type == CreateNotify) - XSelectInput(display, event.xcreatewindow.window, KeyReleaseMask); - } while(event.type != KeyRelease); - - /* A key was pressed. warp the rat. */ - for (i=0; i<numscreens; i++) - { - int x, y, wx, wy; - unsigned int mask; - Window root, child; - - XQueryPointer (display, RootWindow(display, i), - &root, &child, - &x, &y, &wx, &wy, - &mask); - if (x < DisplayWidth (display, i)-1 - || y < DisplayHeight (display, i)-1) - XWarpPointer (display, None, RootWindow(display, i), 0, 0, 0, 0, DisplayWidth (display, i), DisplayHeight (display, i)); - } - } - - XCloseDisplay (display); - - return 0; -} |