Commit 1610fce59a2cf8f02bc9d89b6eb2b5312aad0226

Authored by Ian Foster
1 parent f74923bc7f
Exists in master

scripts link to ~/bin

Showing 4 changed files with 8 additions and 4 deletions Inline Diff

#!/usr/bin/env bash 1 1 #!/usr/bin/env bash
2 2
# the dir this script is in 3 3 # the dir this script is in
cwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 4 cwd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5 5
#helper functions 6 6 #helper functions
function link { 7 7 function link {
target=$1 8 8 target=$1
src=$2 9 9 src=$2
if [ -L $src ]; 10 10 if [ -L $src ];
then 11 11 then
rm $src 12 12 rm $src
fi 13 13 fi
mkdir -p `dirname $src` 14 14 mkdir -p `dirname $src`
echo "Creating symlink for $src" 15 15 echo "Creating symlink for $src"
ln -sf $target $src 16 16 ln -sf $target $src
} 17 17 }
18 18
function downloadSubmodules { 19 19 function downloadSubmodules {
dir=$1 20 20 dir=$1
if [ -e $dir/submodules ]; 21 21 if [ -e $dir/submodules ];
then 22 22 then
while read l; 23 23 while read l;
do 24 24 do
if [ -n "$l" ]; 25 25 if [ -n "$l" ];
then 26 26 then
read -a array <<< $l 27 27 read -a array <<< $l
if [ ! -e $dir/${array[1]} ]; 28 28 if [ ! -e $dir/${array[1]} ];
then 29 29 then
git clone ${array[0]} $dir/${array[1]} 30 30 git clone ${array[0]} $dir/${array[1]}
else 31 31 else
echo "Updating git repo ${array[1]}" 32 32 echo "Updating git repo ${array[1]}"
git --git-dir=$dir/${array[1]}/.git pull 33 33 git --git-dir=$dir/${array[1]}/.git pull
fi 34 34 fi
fi 35 35 fi
done < $dir/submodules 36 36 done < $dir/submodules
fi 37 37 fi
} 38 38 }
39 39
40 40
#config functions 41 41 #config functions
function vim { 42 42 function vim {
echo "Linking vim" 43 43 echo "Linking vim"
downloadSubmodules $cwd/vim 44 44 downloadSubmodules $cwd/vim
link $cwd/vim/vimrc ~/.vimrc 45 45 link $cwd/vim/vimrc ~/.vimrc
link $cwd/vim/vim ~/.vim 46 46 link $cwd/vim/vim ~/.vim
} 47 47 }
48 48
function conky { 49 49 function conky {
echo "Linking conky" 50 50 echo "Linking conky"
link $cwd/conky/conkyrc ~/.conkyrc 51 51 link $cwd/conky/conkyrc ~/.conkyrc
} 52 52 }
53 53
#can not be called git, conflicts with download submodules 54 54 #can not be called git, conflicts with download submodules
function git_config { 55 55 function git_config {
echo "Linking git" 56 56 echo "Linking git"
for file in $(ls $cwd/git); 57 57 for file in $(ls $cwd/git);
do 58 58 do
link $cwd/git/$file ~/.$file 59 59 link $cwd/git/$file ~/.$file
done 60 60 done
} 61 61 }
62 62
function shell { 63 63 function shell {
echo "Linking shell" 64 64 echo "Linking shell"
for file in $(ls $cwd/shell); 65 65 for file in $(ls $cwd/shell);
do 66 66 do
link $cwd/shell/$file ~/.$file 67 67 link $cwd/shell/$file ~/.$file
done 68 68 done
} 69 69 }
70 70
function tmux { 71 71 function tmux {
echo "Linking tmux" 72 72 echo "Linking tmux"
link $cwd/tmux/tmux.conf ~/.tmux.conf 73 73 link $cwd/tmux/tmux.conf ~/.tmux.conf
} 74 74 }
75 75
function xscreensaver { 76 76 function xscreensaver {
echo "Linking xscreensaver" 77 77 echo "Linking xscreensaver"
link $cwd/xscreensaver/xscreensaver ~/.xscreensaver 78 78 link $cwd/xscreensaver/xscreensaver ~/.xscreensaver
} 79 79 }
80 80
function awesome { 81 81 function awesome {
echo "Linking awesome" 82 82 echo "Linking awesome"
downloadSubmodules $cwd/awesome 83 83 downloadSubmodules $cwd/awesome
link $cwd/awesome/awesome ~/.config/awesome 84 84 link $cwd/awesome/awesome ~/.config/awesome
} 85 85 }
86 86
function openbox { 87 87 function openbox {
echo "Linking openbox" 88 88 echo "Linking openbox"
link $cwd/openbox/openbox ~/.config/openbox 89 89 link $cwd/openbox/openbox ~/.config/openbox
} 90 90 }
91 91
function terminator { 92 92 function terminator {
echo "Linking terminator" 93 93 echo "Linking terminator"
link $cwd/terminator/terminator ~/.config/terminator 94 94 link $cwd/terminator/terminator ~/.config/terminator
} 95 95 }
96 96
function tint2 { 97 97 function tint2 {
echo "Linking tint2" 98 98 echo "Linking tint2"
link $cwd/tint2/tint2 ~/.config/tint2 99 99 link $cwd/tint2/tint2 ~/.config/tint2
} 100 100 }
101 101
function sublime { 102 102 function sublime {
echo "Linking Sublime Text" 103 103 echo "Linking Sublime Text"
link $cwd/sublime-text-3/User ~/.config/sublime-text-3/Packages/User 104 104 link $cwd/sublime-text-3/User ~/.config/sublime-text-3/Packages/User
echo "Downloading Package Manager PLugin" 105 105 echo "Downloading Package Manager PLugin"
wget -P ~/.config/sublime-text-3/Installed\ Packages/ https://sublime.wbond.net/Package%20Control.sublime-package 106 106 wget -P ~/.config/sublime-text-3/Installed\ Packages/ https://sublime.wbond.net/Package%20Control.sublime-package
} 107 107 }
108 108
function scripts { 109 109 function scripts {
#DO NOTHING 110 110 echo "Linking scripts"
echo "Skipping scripts" 111 111 for script in $cwd/scripts/*
112 do
113 link $script ~/bin/$(basename $script)
114 done
} 112 115 }
113 116
function run { 114 117 function run {
if [ $1 == "git" ]; 115 118 if [ $1 == "git" ];
then 116 119 then
c="git_config" 117 120 c="git_config"
elif [ $1 == "sublime-text-3" ]; 118 121 elif [ $1 == "sublime-text-3" ];
then 119 122 then
c="sublime" 120 123 c="sublime"
else 121 124 else
c=$1 122 125 c=$1
fi 123 126 fi
eval ${c} 124 127 eval ${c}
} 125 128 }
126 129
function all { 127 130 function all {
echo "Linking all configs" 128 131 echo "Linking all configs"
scripts/awmtt View file @ 1610fce
#!/bin/bash 1 1 #!/bin/env bash
# awmtt: awesomewm testing tool 2 2 # awmtt: awesomewm testing tool
3 3
#{{{ Usage 4 4 #{{{ Usage
usage() { 5 5 usage() {
cat <<EOF 6 6 cat <<EOF
awmtt [ start | stop | restart | -h | -e | -t [ get | change | list | random ] ] [ -C /path/to/rc.lua ] [ -D display ] [ -S windowsize ] 7 7 awmtt [ start | stop | restart | -h | -e | -t [ get | change | list | random ] ] [ -C /path/to/rc.lua ] [ -D display ] [ -S windowsize ]
8 8
start Spawn nested Awesome via Xephyr 9 9 start Spawn nested Awesome via Xephyr
stop Stops Xephyr 10 10 stop Stops Xephyr
all Stop all instances of Xephyr 11 11 all Stop all instances of Xephyr
restart Restart nested Awesome 12 12 restart Restart nested Awesome
-N|--notest Don't use a testfile but your actual rc.lua (i.e. $HOME/.config/awesome/rc.lua) 13 13 -N|--notest Don't use a testfile but your actual rc.lua (i.e. $HOME/.config/awesome/rc.lua)
-C|--config Specify configuration file 14 14 -C|--config Specify configuration file
-D|--display Specify the display to use (e.g. 1) 15 15 -D|--display Specify the display to use (e.g. 1)
-S|--size Specify the window size 16 16 -S|--size Specify the window size
-e|--execute Execute command in nested Awesome 17 17 -e|--execute Execute command in nested Awesome
-t|--theme Control the current theme 18 18 -t|--theme Control the current theme
c|change Change theme 19 19 c|change Change theme
p|print Print themename 20 20 p|print Print themename
l|list List available themes 21 21 l|list List available themes
r|random Choose random theme 22 22 r|random Choose random theme
-h|--help Show this help text 23 23 -h|--help Show this help text
24 24
examples: 25 25 examples:
awmtt start -D 3 -C /etc/xdg/awesome/rc.lua -S 1280x800 26 26 awmtt start -D 3 -C /etc/xdg/awesome/rc.lua -S 1280x800
awmtt -t change zenburn 27 27 awmtt -t change zenburn
awmtt start (uses defaults) 28 28 awmtt start (uses defaults)
29 29
The defaults are -D 1 -C $HOME/.config/awesome/rc.lua.test -S 1024x640. 30 30 The defaults are -D 1 -C $HOME/.config/awesome/rc.lua.test -S 1024x640.
31 31
EOF 32 32 EOF
exit 0 33 33 exit 0
} 34 34 }
[ "$#" -lt 1 ] && usage 35 35 [ "$#" -lt 1 ] && usage
#}}} 36 36 #}}}
37 37
#{{{ Utilities 38 38 #{{{ Utilities
awesome_pid() { pgrep -fn "/usr/bin/awesome"; } 39 39 awesome_pid() { pgrep -fn "/usr/bin/awesome"; }
xephyr_pid() { pgrep -f xephyr_$D; } 40 40 xephyr_pid() { pgrep -f xephyr_$D; }
errorout() { echo "error: $*" >&2; exit 1; } 41 41 errorout() { echo "error: $*" >&2; exit 1; }
#}}} 42 42 #}}}
43 43
#{{{ Executable check 44 44 #{{{ Executable check
AWESOME=$(which awesome) 45 45 AWESOME=$(which awesome)
XEPHYR=$(which Xephyr) 46 46 XEPHYR=$(which Xephyr)
[[ -x "$AWESOME" ]] || errorout 'Please install Awesome first' 47 47 [[ -x "$AWESOME" ]] || errorout 'Please install Awesome first'
[[ -x "$XEPHYR" ]] || errorout 'Please install Xephyr first' 48 48 [[ -x "$XEPHYR" ]] || errorout 'Please install Xephyr first'
#}}} 49 49 #}}}
50 50
#{{{ Default Variables 51 51 #{{{ Default Variables
# Display and window size 52 52 # Display and window size
D=1 53 53 D=1
SIZE="1024x640" 54 54 SIZE="1024x640"
# Path to rc.lua 55 55 # Path to rc.lua
if [[ "$XDG_CONFIG_HOME" ]];then 56 56 if [[ "$XDG_CONFIG_HOME" ]];then
RC_FILE="$XDG_CONFIG_HOME"/awesome/rc.lua.test 57 57 RC_FILE="$XDG_CONFIG_HOME"/awesome/rc.lua.test
else 58 58 else
RC_FILE="$HOME"/.config/awesome/rc.lua.test 59 59 RC_FILE="$HOME"/.config/awesome/rc.lua.test
fi 60 60 fi
[[ -f "$RC_FILE" ]] || cp /etc/xdg/awesome/rc.lua "$RC_FILE" 61 61 [[ -f "$RC_FILE" ]] || cp /etc/xdg/awesome/rc.lua "$RC_FILE"
#}}} 62 62 #}}}
63 63
#{{{ Hostname Check - this is probably only useful for me. I have the same rc.lua running on two different machines 64 64 #{{{ Hostname Check - this is probably only useful for me. I have the same rc.lua running on two different machines
HOSTNAME=$(cat /proc/sys/kernel/hostname) 65 65 HOSTNAME=$(cat /proc/sys/kernel/hostname)
#}}} 66 66 #}}}
67 67
#{{{ Functions 68 68 #{{{ Functions
#{{{ Start function 69 69 #{{{ Start function
start() { 70 70 start() {
"$XEPHYR" -name xephyr_$D -ac -br -noreset -screen "$SIZE" :$D >/dev/null 2>&1 & 71 71 "$XEPHYR" -name xephyr_$D -ac -br -noreset -screen "$SIZE" :$D >/dev/null 2>&1 &
sleep 1 72 72 sleep 1
DISPLAY=:$D.0 "$AWESOME" -c "$RC_FILE" & 73 73 DISPLAY=:$D.0 "$AWESOME" -c "$RC_FILE" &
sleep 1 74 74 sleep 1
echo "Using display $D ($RC_FILE)" 75 75 echo "Using display $D ($RC_FILE)"
echo "$D: Awesome PID is $(awesome_pid)" 76 76 echo "$D: Awesome PID is $(awesome_pid)"
echo "$D: Xephyr PID is $(xephyr_pid)" 77 77 echo "$D: Xephyr PID is $(xephyr_pid)"
} 78 78 }
#}}} 79 79 #}}}
#{{{ Stop function 80 80 #{{{ Stop function
stop() { 81 81 stop() {
if [[ "$1" == all ]];then 82 82 if [[ "$1" == all ]];then
echo "Stopping all instances of Xephyr" 83 83 echo "Stopping all instances of Xephyr"
kill $(pgrep Xephyr) >/dev/null 2>&1 84 84 kill $(pgrep Xephyr) >/dev/null 2>&1
elif [[ $(xephyr_pid) ]];then 85 85 elif [[ $(xephyr_pid) ]];then
echo "Stopping Xephyr for display $D" 86 86 echo "Stopping Xephyr for display $D"
kill $(xephyr_pid) 87 87 kill $(xephyr_pid)
else 88 88 else
echo "Xephyr is not running or you did not specify the correct display with -D" 89 89 echo "Xephyr is not running or you did not specify the correct display with -D"
exit 0 90 90 exit 0
fi 91 91 fi
} 92 92 }
#}}} 93 93 #}}}
#{{{ Restart function 94 94 #{{{ Restart function
restart() { # TODO: Find a way to uniquely identify an awesome instance (without storing the PID in a file). Until then all instances spawned by this script are restarted... 95 95 restart() { # TODO: Find a way to uniquely identify an awesome instance (without storing the PID in a file). Until then all instances spawned by this script are restarted...
echo -n "Restarting Awesome... " 96 96 echo -n "Restarting Awesome... "
for i in $(pgrep -f "/usr/bin/awesome"); do kill -s SIGHUP $i; done 97 97 for i in $(pgrep -f "/usr/bin/awesome"); do kill -s SIGHUP $i; done
} 98 98 }
#}}} 99 99 #}}}
#{{{ Run function 100 100 #{{{ Run function
run() { 101 101 run() {
#shift 102 102 #shift
DISPLAY=:$D.0 "$@" & 103 103 DISPLAY=:$D.0 "$@" &
LASTPID=$! 104 104 LASTPID=$!
echo "PID is $LASTPID" 105 105 echo "PID is $LASTPID"
} 106 106 }
#}}} 107 107 #}}}
#{{{ Theme function 108 108 #{{{ Theme function
theme() { 109 109 theme() {
110 110
# List themes 111 111 # List themes
theme_list() { #TODO: list only directories 112 112 theme_list() { #TODO: list only directories
if [[ -d $(dirname "$RC_FILE")/themes ]];then 113 113 if [[ -d $(dirname "$RC_FILE")/themes ]];then
ls /usr/share/awesome/themes $(dirname "$RC_FILE")/themes 114 114 ls /usr/share/awesome/themes $(dirname "$RC_FILE")/themes
else 115 115 else
ls /usr/share/awesome/themes "$HOME"/.config/awesome/themes 116 116 ls /usr/share/awesome/themes "$HOME"/.config/awesome/themes
fi 117 117 fi
} 118 118 }
case "$1" in 119 119 case "$1" in
l|list) theme_list 120 120 l|list) theme_list
exit 0;; 121 121 exit 0;;
esac 122 122 esac
123 123
# Check for Beautiful library 124 124 # Check for Beautiful library
BEAUTIFUL=$(grep -c 'beautiful.init' "$RC_FILE") 125 125 BEAUTIFUL=$(grep -c 'beautiful.init' "$RC_FILE")
[[ "$BEAUTIFUL" -ge 1 ]] || errorout 'Could not detect theme library "beautiful". Exiting.' 126 126 [[ "$BEAUTIFUL" -ge 1 ]] || errorout 'Could not detect theme library "beautiful". Exiting.'
127 127
if [[ "$HOSTNAME" == laptop ]];then 128 128 if [[ "$HOSTNAME" == laptop ]];then
curtheme=$(grep "^themelap" "$RC_FILE" | awk -F\/ '{print $2}') 129 129 curtheme=$(grep "^themelap" "$RC_FILE" | awk -F\/ '{print $2}')
elif [[ "$HOSTNAME" == htpc ]];then 130 130 elif [[ "$HOSTNAME" == htpc ]];then
curtheme=$(grep "^themehtpc" "$RC_FILE" | awk -F\/ '{print $2}') 131 131 curtheme=$(grep "^themehtpc" "$RC_FILE" | awk -F\/ '{print $2}')
else 132 132 else
curtheme=$(grep -oP "[^\/]+(?=\/theme.lua)" "$RC_FILE") 133 133 curtheme=$(grep -oP "[^\/]+(?=\/theme.lua)" "$RC_FILE")
fi 134 134 fi
135 135
# Change theme 136 136 # Change theme
theme_change() { 137 137 theme_change() {
138 138
if [[ "$HOSTNAME" == laptop ]];then 139 139 if [[ "$HOSTNAME" == laptop ]];then
theme=themelap 140 140 theme=themelap
elif [[ "$HOSTNAME" == htpc ]];then 141 141 elif [[ "$HOSTNAME" == htpc ]];then
theme=themehtpc 142 142 theme=themehtpc
else 143 143 else
theme="^beautiful\.init" 144 144 theme="^beautiful\.init"
fi 145 145 fi
146 146
if [[ "$file" ]];then 147 147 if [[ "$file" ]];then
echo "changing $curtheme to $file" 148 148 echo "changing $curtheme to $file"
sed -i "/$theme.*\/theme\.lua\"/s/[^/]*\(\/theme\.lua\)/$file\1/" "$RC_FILE" 149 149 sed -i "/$theme.*\/theme\.lua\"/s/[^/]*\(\/theme\.lua\)/$file\1/" "$RC_FILE"
else 150 150 else
echo "changing $curtheme to $2" 151 151 echo "changing $curtheme to $2"
sed -i "/$theme.*\/theme\.lua\"/s/[^/]*\(\/theme\.lua\)/$2\1/" "$RC_FILE" 152 152 sed -i "/$theme.*\/theme\.lua\"/s/[^/]*\(\/theme\.lua\)/$2\1/" "$RC_FILE"
fi 153 153 fi
} 154 154 }
# Print themename 155 155 # Print themename
theme_print() { 156 156 theme_print() {
echo "$curtheme" 157 157 echo "$curtheme"
} 158 158 }
# Select random theme and start Xephyr instance 159 159 # Select random theme and start Xephyr instance
theme_random() { 160 160 theme_random() {
themes=$(ls -1 $(dirname "$RC_FILE")/themes /usr/share/awesome/themes | grep -vE '/home/|/usr/|icons|README') 161 161 themes=$(ls -1 $(dirname "$RC_FILE")/themes /usr/share/awesome/themes | grep -vE '/home/|/usr/|icons|README')
file=$(echo "$themes" | sort --random-sort | head -1) 162 162 file=$(echo "$themes" | sort --random-sort | head -1)
theme_change 163 163 theme_change
D=11 && start 164 164 D=11 && start
165 165
} 166 166 }
167 167
case "$1" in 168 168 case "$1" in
c|change) theme_change "${args[@]}" ;; 169 169 c|change) theme_change "${args[@]}" ;;
p|print) theme_print ;; 170 170 p|print) theme_print ;;
r|random) theme_random ;; 171 171 r|random) theme_random ;;
*) errorout "unrecognized option to -t";; 172 172 *) errorout "unrecognized option to -t";;
esac 173 173 esac
} 174 174 }
#}}} 175 175 #}}}
176 176
#{{{ Parse options 177 177 #{{{ Parse options
parse_options() { 178 178 parse_options() {
179 179
while [[ -n "$1" ]];do 180 180 while [[ -n "$1" ]];do
case "$1" in 181 181 case "$1" in
-N|--notest) RC_FILE="$HOME"/.config/awesome/rc.lua ;; 182 182 -N|--notest) RC_FILE="$HOME"/.config/awesome/rc.lua ;;
-C|--config) shift; RC_FILE="$1" ;; 183 183 -C|--config) shift; RC_FILE="$1" ;;
-D|--display) shift; D="$1" 184 184 -D|--display) shift; D="$1"
[[ ! "$D" =~ ^[0-9] ]] && errorout "$D is not a valid display number" ;; 185 185 [[ ! "$D" =~ ^[0-9] ]] && errorout "$D is not a valid display number" ;;
-S|--size) shift; SIZE="$1" ;; 186 186 -S|--size) shift; SIZE="$1" ;;
-h|--help) usage ;; 187 187 -h|--help) usage ;;
start) input=start ;; 188 188 start) input=start ;;
stop) input=stop ;; 189 189 stop) input=stop ;;
restart|reload) input=restart ;; 190 190 restart|reload) input=restart ;;
-e|--execute) input=run ;; 191 191 -e|--execute) input=run ;;
-t|--theme) input=theme ;; 192 192 -t|--theme) input=theme ;;
*) args+=( "$1" ) ;; 193 193 *) args+=( "$1" ) ;;
esac 194 194 esac
scripts/pinhole.py View file @ 1610fce
#! /usr/bin/env python 1 1 #!/usr/bin/env python
""" 2 2 """
usage 'pinhole port host [newport]' 3 3 usage 'pinhole port host [newport]'
4 4
Pinhole forwards the port to the host specified. 5 5 Pinhole forwards the port to the host specified.
The optional newport parameter may be used to 6 6 The optional newport parameter may be used to
redirect to a different port. 7 7 redirect to a different port.
8 8
eg. pinhole 80 webserver 9 9 eg. pinhole 80 webserver
Forward all incoming WWW sessions to webserver. 10 10 Forward all incoming WWW sessions to webserver.
11 11
pinhole 23 localhost 2323 12 12 pinhole 23 localhost 2323
Forward all telnet sessions to port 2323 on localhost. 13 13 Forward all telnet sessions to port 2323 on localhost.
14 14
""" 15 15 """
16 16
import sys 17 17 import sys
from socket import * 18 18 from socket import *
from threading import Thread 19 19 from threading import Thread
import time 20 20 import time
import signal 21 21 import signal
import os 22 22 import os
23 23
running = True 24 24 running = True
25 25
def log( s ): 26 26 def log( s ):
print '%s:%s' % ( time.ctime(), s ) 27 27 print '%s:%s' % ( time.ctime(), s )
sys.stdout.flush() 28 28 sys.stdout.flush()
29 29
class PipeThread( Thread ): 30 30 class PipeThread( Thread ):
pipes = [] 31 31 pipes = []
def __init__( self, source, sink ): 32 32 def __init__( self, source, sink ):
Thread.__init__( self ) 33 33 Thread.__init__( self )
self.source = source 34 34 self.source = source
self.sink = sink 35 35 self.sink = sink
36 36
log( 'Creating new pipe thread %s ( %s -> %s )' % \ 37 37 log( 'Creating new pipe thread %s ( %s -> %s )' % \
( self, source.getpeername(), sink.getpeername() )) 38 38 ( self, source.getpeername(), sink.getpeername() ))
PipeThread.pipes.append( self ) 39 39 PipeThread.pipes.append( self )
log( '%s pipes active' % len( PipeThread.pipes )) 40 40 log( '%s pipes active' % len( PipeThread.pipes ))
41 41
def run( self ): 42 42 def run( self ):
while running: 43 43 while running:
try: 44 44 try:
data = self.source.recv( 1024 ) 45 45 data = self.source.recv( 1024 )
if not data: break 46 46 if not data: break
self.sink.send( data ) 47 47 self.sink.send( data )
except: 48 48 except:
break 49 49 break
50 50
log( '%s terminating' % self ) 51 51 log( '%s terminating' % self )
PipeThread.pipes.remove( self ) 52 52 PipeThread.pipes.remove( self )
log( '%s pipes active' % len( PipeThread.pipes )) 53 53 log( '%s pipes active' % len( PipeThread.pipes ))
54 54
class Pinhole( Thread ): 55 55 class Pinhole( Thread ):
def __init__( self, port, newhost, newport ): 56 56 def __init__( self, port, newhost, newport ):
Thread.__init__( self ) 57 57 Thread.__init__( self )
log( 'Redirecting: localhost:%s -> %s:%s' % ( port, newhost, newport )) 58 58 log( 'Redirecting: localhost:%s -> %s:%s' % ( port, newhost, newport ))
self.newhost = newhost 59 59 self.newhost = newhost
self.newport = newport 60 60 self.newport = newport
self.sock = socket( AF_INET, SOCK_STREAM ) 61 61 self.sock = socket( AF_INET, SOCK_STREAM )
self.sock.bind(( '', port )) 62 62 self.sock.bind(( '', port ))
self.sock.listen(5) 63 63 self.sock.listen(5)
64 64
def run( self ): 65 65 def run( self ):
while running: 66 66 while running:
newsock, address = self.sock.accept() 67 67 newsock, address = self.sock.accept()
log( 'Creating new session for %s %s ' % address ) 68 68 log( 'Creating new session for %s %s ' % address )
fwd = socket( AF_INET, SOCK_STREAM ) 69 69 fwd = socket( AF_INET, SOCK_STREAM )
fwd.connect(( self.newhost, self.newport )) 70 70 fwd.connect(( self.newhost, self.newport ))
PipeThread( newsock, fwd ).start() 71 71 PipeThread( newsock, fwd ).start()
PipeThread( fwd, newsock ).start() 72 72 PipeThread( fwd, newsock ).start()
73 73
if __name__ == '__main__': 74 74 if __name__ == '__main__':
75 75
print 'Starting Pinhole' 76 76 print 'Starting Pinhole'
77 77
scripts/touchpad.sh View file @ 1610fce
1 #!/usr/bin/env bash
## Detect and configure touchpad. See 'man synclient' for more info. 1 2 ## Detect and configure touchpad. See 'man synclient' for more info.
if egrep -iq 'touchpad' /proc/bus/input/devices; then 2 3 if egrep -iq 'touchpad' /proc/bus/input/devices; then
synclient VertEdgeScroll=0 3 4 synclient VertEdgeScroll=0
synclient HorizTwoFingerScroll=1 4 5 synclient HorizTwoFingerScroll=1
synclient PalmDetect=1 5 6 synclient PalmDetect=1
fi 6 7 fi