commit ce984446b05604ef1657a8048427c2d71324823f
parent 026c887fbe8baf6ace14e0d355315e00105935dc
Author: Georg Neis <gn@wmii.de>
Date: Sat, 25 Feb 2006 19:36:53 +0100
add first version of sh scripts
Diffstat:
| cmd/wm/wmii | | | 17 | +++++++++++++++++ |
| rc/extern | | | 9 | +++++++++ |
| rc/status | | | 23 | +++++++++++++++++++++++ |
| rc/welcome | | | 66 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| rc/wmiirc | | | 170 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
5 files changed, 285 insertions(+), 0 deletions(-)
diff --git a/cmd/wm/wmii b/cmd/wm/wmii
@@ -0,0 +1,17 @@
+#!/bin/sh
+# start wmiiwm and wait for its termination
+
+test $# -eq 0 || exec wmiiwm "$@"
+wmiiwm -c || exit 1
+
+OLD_PATH=$PATH export OLD_PATH
+PATH=$HOME/.wmii-3:CONFPREFIX/wmii-3:$PATH export PATH
+WMII_ADDRESS=unix!/tmp/ns.$USER.$DISPLAY/wmii export WMII_ADDRESS
+
+mkdir -m 700 /tmp/ns.$USER.$DISPLAY 2>/dev/null
+wmiiwm -a $WMII_ADDRESS &
+wmiiwmpid=$!
+mkdir $HOME/.wmii-3 2>/dev/null && welcome &
+sleep 1
+wmiirc &
+wait $wmiiwmpid
diff --git a/rc/extern b/rc/extern
@@ -0,0 +1,9 @@
+#!/bin/sh
+# clean the environment and execute the given command
+
+PATH=$OLD_PATH export PATH
+unset OLD_PATH
+unset WMII_NORMCOLORS
+unset WMII_SELCOLORS
+
+exec "$@"
diff --git a/rc/status b/rc/status
@@ -0,0 +1,23 @@
+#!/bin/sh
+# periodically print date and load average to the bar
+
+pidfile=/tmp/ns.$USER.$DISPLAY/statuspid
+
+xwrite() {
+ file="$1"; shift
+ echo -n "$@" | wmiir write "$file"
+}
+
+# race condition alert
+test -f $pidfile && kill `cat $pidfile` 2>/dev/null
+echo $$ >$pidfile
+sleep 2
+xwrite /bar/new/colors $WMII_NORMCOLORS
+n=`wmiir read /bar | awk '/[0-9]+$/ {if($NF>max) max=$NF} END {print max}'`
+trap "wmiir remove /bar/$n 2>/dev/null; exit" 15
+
+while true
+do
+ xwrite /bar/$n/data `date` `uptime | sed 's/.*://; s/,//g'` || exit
+ sleep 2
+done
diff --git a/rc/welcome b/rc/welcome
@@ -0,0 +1,66 @@
+#!/bin/sh
+# display a welcome message that contains the wmii tutorial
+
+xmessage -file - <<'EOF'
+Welcome to wmii, the non-wimp environment of the WMI Project.
+
+This is a small step by step tutorial, intended to make you a little bit
+familiar with wmii.
+
+NOTE: Some characters in shortcuts have a special meaning. S is the Shift
+key, C is the Ctrl key, M is the Meta key (usually Alt), and the hyphen means
+that you have to press the surrounding keys at the same time.
+
+Let's go!
+
+- Start two xterms by pressing M-t twice.
+- Switch between the three windows: M-j, M-k
+ You can also use M-Tab instead of M-j. If you prefer the mouse, then
+ just click the desired window.
+- Create a new page: M-C-y
+ IMPORTANT: this text will then no longer be visible. In order to continue
+ reading you'll now often have to go back to the first page. Use M-h
+ or M-l for cycling through the existing pages. The digit in the left
+ corner at the bottom indicates which page you're on. You can directly
+ select a specific page as well: M-S-1, etc. Make sure that you are on the
+ second page before performing the next steps.
+- Apply the float layout to the current page: M-S-f
+ Watch the leftmost bar label: the 't', which stood for 'tiled', has now
+ turned into an 'f', for 'float'.
+- Open the programs menu: M-C-p
+ Type 'xclock' and press Enter.
+- Resize the xclock window: left-click on the border and, while holding the
+ button down, move the cursor around.
+- Move the xclock window: left-click on the title bar and, while holding
+ the button down, move the cursor around.
+- Open the actions menu: M-C-a
+ Remove the current page by selecting the rmpage action. The xclock window
+ will be automatically detached and we'll land on the first page.
+- Attach the xclock window again: M-a
+- Select one of the terminals and close it: M-C-c
+ Close xclock as well.
+- Swap the remaining terminal with the left master tile by moving the terminal
+ window somewhere to the left. Afterwards, swap them once again, but this
+ time by pressing M-Enter.
+- Working with mouse efficiently:
+ selecting a window: just click the desired window
+ move a window : press M+Button1Press and move the window
+ resize a window (only with non managed): press M+Button3Press and resize it
+ (this can also be done by clicking the titlebar of the window/borders respectively)
+- We'll now have a look at the internal filesystem used by wmii. Executing
+ wmiir read /
+ in the shell of the terminal will list all the files in the root directory.
+ Files ending with a slash are directories. As you can see, / contains a
+ "normal" file and four directories. These directories correspond to the
+ four main components of wmii: wmiiwm, wmiibar, wmiikeys, and wmiimenu. If you
+ are curious, you can now dig deeper into the directory trees. For instance,
+ wmiir read /bar/1/b1press
+ will show you which command gets executed when you left-click on the page
+ label in the bar.
+
+We hope that these steps gave you an idea of how wmii works. You can reread
+them at any time by pressing M-C-a and selecting 'welcome'.
+
+You should now take a look at the wmii(1) man page. An FAQ is available on
+<http://wmii.de>.
+EOF
diff --git a/rc/wmiirc b/rc/wmiirc
@@ -0,0 +1,170 @@
+#!/bin/sh
+# configure wmii
+
+pidfile=/tmp/ns.$USER.$DISPLAY/wmiircpid
+
+xwrite() {
+ file="$1"; shift
+ echo -n "$@" | wmiir write "$file"
+}
+
+proglist() {
+ for dir in `echo $@ | sed 's/^:/.:/; s/::/:.:/; s/:$/:./' | tr : ' '`
+ do
+ for i in $dir/*
+ do
+ test -x "$i" && test ! -d "$i" && echo `basename "$i"`
+ done
+ done | sort | uniq
+}
+
+test -f $pidfile && kill -9 `cat $pidfile` 2>/dev/null
+echo $$ >$pidfile
+
+MODKEY=Alt
+WMII_NORMCOLORS='#222222 #eeeeee #666666' export WMII_NORMCOLORS
+WMII_SELCOLORS='#ffffff #285577 #4c7899' export WMII_SELCOLORS
+
+# WM CONFIGURATION
+xwrite /def/border 3
+xwrite /def/inc 1
+xwrite /def/snap 20
+xwrite /def/font fixed
+xwrite /def/selcolors $WMII_SELCOLORS
+xwrite /def/normcolors $WMII_NORMCOLORS
+
+# BAR CONFIGURATION
+i=1
+n=`wmiir read /bar | awk '/[0-9]+$/ {if($NF>max) max=$NF} END {print max}'`
+while test $i -le ${n:-0}
+do
+ wmiir remove /bar/1
+ i=`expr $i + 1`
+done
+xwrite /bar/new/colors $WMII_NORMCOLORS
+xwrite /bar/new/colors $WMII_SELCOLORS
+xwrite /bar/1/data 1
+xwrite /bar/expand 2
+
+# MISC
+xsetroot -solid '#0b1014'
+status &
+proglist $OLD_PATH >/tmp/ns.$USER.$DISPLAY/progs &
+
+# SHORTCUTS
+while read key
+do
+ echo -n | wmiir create /keys/$key
+done <<EOF
+$MODKEY-Control-c
+$MODKEY-Control-w,y
+$MODKEY-Control-q,y
+$MODKEY-Control-p
+$MODKEY-Control-a
+$MODKEY-Control-y
+$MODKEY-t
+$MODKEY-n
+$MODKEY-m
+$MODKEY-Return
+$MODKEY-h
+$MODKEY-l
+$MODKEY-j
+$MODKEY-k
+$MODKEY-Tab
+$MODKEY-Shift-h
+$MODKEY-Shift-l
+$MODKEY-Shift-p
+$MODKEY-Shift-Return
+$MODKEY-Shift-1
+$MODKEY-Shift-2
+$MODKEY-Shift-3
+$MODKEY-Shift-4
+$MODKEY-Shift-5
+$MODKEY-Shift-6
+$MODKEY-Shift-7
+$MODKEY-Shift-8
+$MODKEY-Shift-9
+$MODKEY-Control-1
+$MODKEY-Control-2
+$MODKEY-Control-3
+$MODKEY-Control-4
+$MODKEY-Control-5
+$MODKEY-Control-6
+$MODKEY-Control-7
+$MODKEY-Control-8
+$MODKEY-Control-9
+EOF
+
+# EVENT LOOP
+wmiir read /event 2>/dev/null |
+while read event
+do
+ set -- $event
+ type="$1"; shift
+ case "$type" in
+ PN)
+ xwrite /bar/1/data "$@";;
+ CN)
+ xwrite /bar/2/data "$@";;
+ CF)
+ xwrite /ctl `echo "$@" | awk '{print "warp " $1+6 " " $2+6}'`;;
+ LB)
+ case "$2" in
+ 1)
+ if test 1 -eq "$1"
+ then
+ xwrite /ctl pager
+ else
+ xwrite /ctl select prev
+ fi;;
+ 3|4)
+ xwrite /ctl select next;;
+ 5)
+ xwrite /ctl select prev;;
+ esac;;
+ K)
+ case "$1" in
+ $MODKEY-Control-c)
+ xwrite /sel/sel/sel/ctl kill;;
+ $MODKEY-Control-w,y)
+ wmiirc &;;
+ $MODKEY-Control-q,y)
+ xwrite /ctl quit;;
+ $MODKEY-Control-p)
+ extern `wmiimenu </tmp/ns.$USER.$DISPLAY/progs` &;;
+ $MODKEY-Control-a)
+ `proglist CONFPREFIX/wmii-3:$HOME/.wmii-3 | wmiimenu` &;;
+ $MODKEY-t)
+ extern xterm &;;
+ $MODKEY-n)
+ wmiir read /sel/new >/dev/null;;
+ $MODKEY-m)
+ xwrite /sel/sel/sel/ctl max;;
+ $MODKEY-Return)
+ xwrite /sel/sel/ctl sendtoarea prev;;
+ $MODKEY-Shift-Return)
+ xwrite /sel/sel/sel/ctl sendtoarea next;;
+ $MODKEY-Control-y)
+ wmiir read /new >/dev/null;;
+ $MODKEY-h)
+ xwrite /sel/ctl select prev;;
+ $MODKEY-l)
+ xwrite /sel/ctl select next;;
+ $MODKEY-Tab)
+ xwrite /sel/sel/ctl select next;;
+ $MODKEY-j)
+ xwrite /sel/sel/ctl select next;;
+ $MODKEY-k)
+ xwrite /sel/sel/ctl select prev;;
+ $MODKEY-Shift-h)
+ xwrite /ctl select prev;;
+ $MODKEY-Shift-l)
+ xwrite /ctl select next;;
+ $MODKEY-Shift-p)
+ xwrite /ctl pager;;
+ $MODKEY-Shift-[1-9])
+ xwrite /ctl select `echo $1 | sed 's/.*-//'`;;
+ esac;;
+ esac
+done &
+echo $! >$pidfile