Skip to content

Commit

Permalink
- Fixed: s2c is no longer required to be in the PATH
Browse files Browse the repository at this point in the history
- Better error diagnostics (show the name of the logfile at the start)
  • Loading branch information
philipp-classen committed Dec 22, 2013
1 parent b8d7f26 commit 6b1aed1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions s2cctl
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#! /bin/sh
logfile="$HOME/.Space2Ctrl.log"

start() {
origmap=$(xmodmap -pke | grep -E "^keycode[[:blank:]]*?65")
#newmap=$(echo ${origmap} | perl -pe "s/65[[:blank:]]*?=[[:blank:]]*?space/65 = Control_L/")
newmap=$(echo ${origmap} | perl -pe "s/ space/ Control_L/g")

xmodmap -e "$newmap"
xmodmap -e "keycode 255 = space VoidSymbol VoidSymbol VoidSymbol VoidSymbol"
nohup s2c >> ~/.Space2Ctrl.log 2>&1 &
nohup "${0%/*}/s2c" >> "$logfile" 2>&1 &
sleep 1 # Don't ask me why but we need to wait more than one second else the ctrl modifier is
# reinitialized to XK_Control_L XK_Control_R as soon as keycode 65 is pressed!
`xmodmap -e "add control = Control_L Control_R"`
echo "Space2Ctrl is now active (logfile: $logfile)"
exit 0
}

Expand All @@ -26,10 +29,10 @@ stop() {

case $1 in
start)
echo "Starting Space2Ctrl"
echo "Starting Space2Ctrl..."
start;;
stop)
echo "Stoping Space2Ctrl"
echo "Stopping Space2Ctrl..."
stop;;
*)
echo "Please pass start or stop";;
Expand Down

0 comments on commit 6b1aed1

Please sign in to comment.