Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it easier to install nwm #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions nwm
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#! /usr/bin/env bash

dir=`readlink -e $BASH_SOURCE`
dir=`dirname $dir`

nwm_dir="$HOME/.nwm/"

# you probably have a something in your .bashrc to setup node.
# i do, and this makes it work when you run sudo.
# this may not be the best way to tackle this, but it works now, for me.
# post an issue and mention @dominictarr if this breaks something.


start () {
log=''
if [ "x$1" = x ]; then
log='2> "$nwm_dir/nwm.err.log" 1> "$nwm_dir/nwm.log"'
fi
node "$dir/nwm-user-sample.js" $log
exit
}

mkdir -p ~/.nwm


init () {
NODE=`which node`
plat=`uname`
case $plat in
Linux)
cat << NWM1 > $HOME/.nwm/nwm-start
#! /usr/bin/env bash
$NODE "$dir/nwm-user-sample.js" 2> "$nwm_dir/err.log" 1> "$nwm_dir/out.log"

NWM1

chmod +x "$nwm_dir/nwm-start"

cat << NWM2 > "$nwm_dir/nwm.desktop"
[Desktop Entry]
Encoding=UTF-8
Name=nwm
Comment=This session starts nwm
Exec=$nwm_dir/nwm-start
Type=Application
NWM2
;;
*)
echo nwm does not yet have install script for
echo your platform: $plat. see readme for manual instructions
exit 1
esac
exit
}

#run this command as sudo.
install () {
plat=`uname`
case $plat in
Linux)
#nwm.desktop is generated by `nwm init`
cp $nwm_dir/nwm.desktop /usr/share/xsessions/
;;
*)
echo nwm does not yet have install script for
echo your platform: $plat. see readme for manual instructions
exit 1
esac
exit

}

uninstall () {
plat=`uname`
case $plat in
Linux)
rm /usr/share/xsessions/nwm.desktop
;;
esac
exit

}

xephyr () {
#the default size is small, so you can see loggers, etc.
if [ "x$1" = x ]; then
size=800x600
else
size="$1"
fi
Xephyr -screen "$size" -nodri -br :1 &
DISPLAY=:1 start --nolog
}

help () {
less $dir/readme.md
}

$@

echo 'USAGE: nwm start|install|uninstall|help'
exit 1
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
"main": "index.js",
"devDependencies": {
"mocha": "~1.2.1"
},
"bin":"./nwm",
"scripts": {
"test": "mocha",
"postinstall": "./nwm init; cd ./build; make"
}
}
33 changes: 9 additions & 24 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ From github:
git clone git://github.com/mixu/nwm.git
rm -rf ./build
npm install --production
#add nwm option to login screen!
sudo ./nwm install

If you are using Node 0.6.x, you need to checkout src/nwm_node.cc at revision db3545413d:

Expand Down Expand Up @@ -132,21 +134,9 @@ That's it.

If you are using Gnome (GDM as login manager)

1: Create nwm.sh somewhere (and chmod +x it):

#!/bin/sh
/usr/local/bin/node /path/to/nwm-user-sample.js 2> ~/nwm.err.log 1> ~/nwm.log

Note: run "which node" to find out the path to Node in the script above.

2: add the following as nwm.desktop to /usr/share/xsessions:

[Desktop Entry]
Encoding=UTF-8
Name=nwm
Comment=This session starts nwm
Exec=/PATH/TO/nwm.sh
Type=Application
```
sudo ./nwm install
```

Select "nwm" from the Sessions menu when logging in. If you run into issues, have a look at ~/nwm.err.log. Mostly, it's a matter of getting all the paths (to Node, to the nwm files) right.

Expand Down Expand Up @@ -187,15 +177,10 @@ For more extensive customization, see https://github.com/mixu/nwm-user which has

# Running under a secondary X11 server (Xephyr)

If you want to test or develop nwm, the easiest way is to use Xephyr:

# start Xephyr
Xephyr -screen 1024x768 -nodri -br :1 &
# export gedit to the X server on display 1
DISPLAY=:1 gedit
DISPLAY=:1 gnome-terminal
# now start nwm.js on display 1
DISPLAY=:1 node nwm-user-sample.js
```
./nwm xephyr [WIDTHxHEIGHT]
```
(the default size is 800x600)

Under Xephyr, the base key combination is Ctrl+Meta (e.g. Ctrl+Win). When running natively, the base key is Meta (Win). This is so that I can test nwm inside itself, yet have decent shortcuts:

Expand Down