Permalink
Browse files

Add Rogue mode, change Pair modes meaning.

Pair mode now joins the hosts wemux session, and does not allow
independent movement between windows as it can lead to users getting
separated when doing a normal pair session.
Rogue mode mirrors the old Pair mode behavior, allowing users to go off
on their own and work in their own windows.
  • Loading branch information...
zolrath committed Apr 4, 2012
1 parent 40ff692 commit b12b17c0fb9d2c979820ed51478aacbd01fe0060
Showing with 97 additions and 52 deletions.
  1. +21 −14 README.md
  2. +71 −38 wemux
  3. +5 −0 wemux.conf.example
View
@@ -56,7 +56,7 @@ and notifications when users attach/detach.
socket.
#### wemux kick *username*
Use `wemux kick <username>` to kick an SSH user from the server and remove
- their wemux pair sessions.
+ their wemux rogue sessions.
#### wemux config
Use `wemux config` to open `/usr/local/etc/wemux.conf` in your $EDITOR.
Note this only works if you have the environment variable EDITOR configured.
@@ -70,18 +70,21 @@ and notifications when users attach/detach.
Use `wemux mirror` to attach to server in read-only mode.
#### wemux pair
Use `wemux pair` to attach to server in pair mode, which allows editing.
+#### wemux rogue
+ Use `wemux rogue` to attach to server in rogue mode, which allows editing and
+ switching to windows independently from the host.
#### wemux logout
Use `wemux logout` to remove your pair mode session.
#### wemux
When `wemux` is run without any arguments in client mode, its behavior
- attempts to intelligently select mirror or pair:
+ attempts to intelligently select mirror, pair, or rogue:
- * If the client does not have an existing pair session it will attach to the
- wemux server in mirror mode.
- * If the client has already started a wemux pair mode session, it will
- reattach to the server in pair mode.
- * By setting `default_client_mode="pair"` in `wemux.conf` this can be changed
- to always join in pair mode, even if a pair session doesn't already exist.
+ * If the client does not have an existing rogue session it will attach to the
+ wemux server in pair mode.
+ * If the client has already started a wemux rogue session, it will
+ reattach to the server in rogue mode.
+ * By setting `default_client_mode="rogue"` in `wemux.conf` this can be changed
+ to always join in rogue mode, even if a rogue session doesn't already exist.
#### Other Commands
wemux passes commands it doesn't understand through to tmux with the correct
@@ -210,14 +213,18 @@ and notifications when users attach/detach.
Pair mode can be disabled, only allowing clients to attach to the server in
mirror mode by setting `allow_pair_mode="false"`
+### Rogue Mode
+ Rogue mode can be disabled, only allowing clients to attach to the server in
+ mirror mode by setting `allow_rogue_mode="false"`
+
### Default Client Mode
When clients enter 'wemux' with no arguments by default it will first attempt to
- join an existing pair mode session. If there is no pair session it will start
- in mirror mode.
- By setting default_client_mode to "pair", 'wemux' with no arguments will always
- join a pair mode session, even if it has to create it.
+ join an existing rogue mode session. If there is no rogue session it will start
+ in pair mode.
+ By setting default_client_mode to "rogue", 'wemux' with no arguments will always
+ join a rogue mode session, even if it has to create it.
- This can be changed by setting `default_client_mode="pair"`
+ This can be changed by setting `default_client_mode="rogue"`
### Default Server Name
The default wemux server name will be used with `wemux reset` and when
@@ -241,7 +248,7 @@ and notifications when users attach/detach.
`allow_kick_user="false"` in `wemux.conf`
### Announcements
- When a user joins a server in either mirror or pair mode, a message is
+ When a user joins a server in either mirror, pair, or rogue mode, a message is
displayed to all currently attached users:
csagan has attached in mirror mode.
View
109 wemux
@@ -2,8 +2,10 @@
# wemux by Matt Furden @zolrath
#
# wemux allows you to start a shared tmux session using the command 'wemux'.
-# Clients have the option of mirroring, which will give them read-only access,
-# or pairing, which will allow them to edit your file (shared cursor) or work
+# Clients have the option of:
+# Mirroring, which will give them read-only access,
+# Pairing, which will allow them to control the hosts cursor.
+# Rogue mode, which allows them to work in the same window (shared cursor) or
# in another window (separate cursors) in the hosts tmux session.
#
# To set a user as host add their username to the host_list in the configuration
@@ -26,7 +28,9 @@
# WEMUX CLIENT COMMANDS:
# wemux mirror: Attach to Host in read-only mode.
# wemux pair : Attach to Host in pair mode, which allows editing.
-# wemux logout: Log out of the wemux pairing session.
+# wemux rogue : Attach to Host in rogue mode, which allows editing and switching
+# to windows independently from the host.
+# wemux logout: Log out of the wemux rogueing session.
# wemux users : List the currently attached wemux users.
# wemux help : Display the help screen.
#
@@ -39,14 +43,15 @@
###############################################################################
# Current wemux version.
-version="3.0.0"
+version="3.1.0"
# Setup and Configuration Files.
# Default settings, modify them in the /usr/local/etc/wemux.conf file:
host_list=(change_this_in_wemux_conf)
socket_prefix="/tmp/wemux"
options="-u"
allow_pair_mode="true"
+allow_rogue_mode="true"
default_client_mode="mirror"
allow_kick_user="true"
allow_server_change="false"
@@ -211,8 +216,8 @@ session_exists() {
[ "$does_exist" == 0 ] && return 0 || return 1;
}
-# Returns true if pair session with current host already exists.
-has_pair_session() {
+# Returns true if rogue session with current host already exists.
+has_rogue_session() {
redirect=`$wemux has-session -t $client_session 2>&1`; does_exist=$?
[ "$does_exist" == 0 ] && return 0 || return 1;
}
@@ -368,7 +373,7 @@ host_mode() {
echo ""
if [ "$allow_server_change" == "true" ]; then
echo " [j] join [name]: Join the specified wemux server."
- echo " [r] reset: Join default wemux server: $default_server_name"
+ echo " [d] reset: Join default wemux server: $default_server_name"
if [ "$allow_server_list" == "true" ]; then
echo " [l] list: List all currently active wemux servers."
fi
@@ -398,7 +403,7 @@ host_mode() {
help|h) display_host_commands;;
join|j) shift; change_server $@;;
name|n) shift; change_server $@;;
- reset|r) change_server "$default_server_name";;
+ reset|d) change_server "$default_server_name";;
list|l) list_active_servers;;
users|u) list_users;;
kick) kick_user $2;;
@@ -428,53 +433,69 @@ client_mode() {
# Pair mode, allows user to interact with wemux server.
pair_mode() {
if [ "$allow_pair_mode" == "true" ]; then
- if has_pair_session; then
+ if session_exists; then
+ $wemux attach -t $server
+ else
+ echo "No wemux server to pair with on '$server'."
+ fi
+ else
+ echo "Pair mode is disabled."
+ return 126
+ fi
+ }
+
+ # Rogue mode, allows user to interact with wemux server and operate
+ # independently in other windows.
+ # Will connect to existing rogue session or create one if necessary.
+ rogue_mode() {
+ if [ "$allow_rogue_mode" == "true" ]; then
+ if has_rogue_session; then
$wemux attach -t $client_session
elif session_exists; then
$wemux new-session -d -t $server -s $client_session
$wemux new-window -n $username
$wemux attach -t $client_session
else
- echo "No wemux server to pair with on '$server'"
+ echo "No wemux server to go 'rogue' with on '$server'."
fi
else
- echo "Pair mode is disabled."
+ echo "Rogue mode is disabled."
return 126
fi
}
- # Log user out of pair mode, removing their session..
- logout_pair() {
- if [ "$allow_pair_mode" == "true" ]; then
- if has_pair_session; then
+ # Log user out of rogue mode, removing their session..
+ logout_rogue() {
+ if [ "$allow_rogue_mode" == "true" ]; then
+ if has_rogue_session; then
[ "$announce_attach" == "true" ] && $wemux display-message \
- "$username has logged out of pair mode."
+ "$username has logged out of rogue mode."
$wemux kill-session -t $client_session
- echo "Logged out of pair mode on '$server'."
+ echo "Logged out of rogue mode on '$server'."
else
echo "No wemux server to log out of on '$server'."
fi
else
- echo "Pair mode is disabled."
+ echo "Rogue mode is disabled."
return 126
fi
}
- # Reattach based upon presence of existing pair mode session.
- # If pair mode session exists, reattach to it.
- # If no pair mode session exists, mirror the host.
smart_reattach() {
+ # If default_client_mode has been set to "rogue" in wemux.conf:
+ if [ "$default_client_mode" == "rogue" ] && [ "$allow_rogue_mode" == "true" ]; then
+ announce_connection "rogue" rogue_mode
# If default_client_mode has been set to "pair" in wemux.conf:
- if [ "$default_client_mode" == "pair" ] && [ "$allow_pair_mode" == "true" ]; then
- announce_connection "pair" pair_mode
+ elif [ "$default_client_mode" == "pair" ] && [ "$allow_pair_mode" == "true" ]; then
+ announce_connection "pair" pair_mode
+ elif has_rogue_session && [ "$allow_rogue_mode" == "true" ]; then
+ announce_connection "rogue" rogue_mode
+ elif [ "$allow_pair" == "true" ]; then
+ announce_connection "pair" pair_mode
+ elif session_exists; then
+ announce_connection "mirror" $wemux attach -t $server -r
else
- if has_pair_session && [ "$allow_pair_mode" == "true" ]; then
- announce_connection "pair" $wemux attach -t $client_session
- elif session_exists; then
- announce_connection "mirror" $wemux attach -t $server -r
- else
- echo "No wemux server to attach to on '$server'"
- fi
+ echo "No wemux server to attach to on '$server'"
fi
}
@@ -491,7 +512,11 @@ client_mode() {
echo " [m] mirror: Attach to '$server' in read-only mode."
if [ "$allow_pair_mode" == "true" ]; then
echo " [p] pair: Attach to '$server' in pair mode, which allows editing."
- echo " [o] logout: Log out of the current wemux pairing session."
+ fi
+ if [ "$allow_rogue_mode" == "true" ]; then
+ echo " [r] rogue: Attach to '$server' in rogue mode, allowing you to pair"
+ echo " and also work in other windows independent of the host."
+ echo " [o] logout: Log out of the current wemux rogue session."
fi
echo ""
if [ "$allow_server_change" == "true" ]; then
@@ -506,11 +531,18 @@ client_mode() {
fi
echo ""
echo " [h] help: Display this screen."
- if [ "$default_client_mode" == "pair" ] && [ "$allow_pair_mode" == "true" ]; then
- echo " no args: Attach to '$server' in pair mode, which allows editing."
- elif [ "$allow_pair_mode" == "true" ]; then
- echo " no args: Attach to pair session on '$server' if it already exists,"
+ if [ "$default_client_mode" == "rogue" ] && [ "$allow_rogue_mode" == "true" ]; then
+ echo " no args: Attach to '$server' in rogue mode."
+ elif [ "$default_client_mode" == "pair" ] && [ "$allow_pair_mode" == "true" ]; then
+ echo " no args: Attach to '$server' in pair mode."
+ elif [ "$allow_rogue_mode" == "true" ] && [ "$allow_pair_mode" == "true" ]; then
+ echo " no args: Attach to rogue session on '$server' if it already exists,"
+ echo " otherwise, attach in pair mode."
+ elif [ "$allow_rogue_mode" == "true" ] && [ "$allow_pair_mode" == "false" ]; then
+ echo " no args: Attach to rogue session on '$server' if it already exists,"
echo " otherwise, attach in mirror mode."
+ elif [ "$allow_pair_mode" == "true" ]; then
+ echo " no args: Attach to '$server' in pair mode."
else
echo " no args: Attach to '$server' in mirror mode."
fi
@@ -524,9 +556,10 @@ client_mode() {
case "$1" in
mirror|m) announce_connection "mirror" mirror_mode;;
pair|p) announce_connection "pair" pair_mode;;
- edit|e) announce_connection "pair" pair_mode;;
- logout|o) logout_pair;;
- stop|s) logout_pair;;
+ rogue|r) announce_connection "rogue" rogue_mode;;
+ edit|e) announce_connection "rogue" rogue_mode;;
+ logout|o) logout_rogue;;
+ stop|s) logout_rogue;;
help|h) display_client_commands;;
join|j) shift; change_server $@;;
name|n) shift; change_server $@;;
View
@@ -19,6 +19,11 @@ host_list=(change_this)
## Defaults to "true"
# allow_pair_mode="false"
+## Allow users to attach to the wemux sever in rogue mode.
+## When set to false, clients will only be able to attach in pair or mirror mode.
+## Defaults to "true"
+# allow_rogue_mode="false"
+
## When clients enter 'wemux' with no arguments by default it will attempt to
## join an existing pair mode session, if there is no pair session it will start
## a mirror mode session.

0 comments on commit b12b17c

Please sign in to comment.