#!/usr/bin/perl -w # # Copyright Arthur Clune and Gavin Atkinson 2004 # # arthur@clune.org # # This software is released under the terms of the Gnu Public License (GPL) # http://www.gnu.org/licenses/gpl.txt # AJC 25 Nov 2002 - Created # # GA 16 Dec 2003 - Made multi-platform. All the world is not linux... # Now uses which(1) to locate dcop # Now uses POSIX 'ps -o "user pid ppid"' rather than 'ps -j' # # AJC 30 Jan 2003 - Now uses KDEHOME correctly and checks for existence # of config directory # setup $DCOP = `which dcop`; chomp $DCOP; $USER = $ENV{'USER'}; $HOME = $ENV{'HOME'}; $KDEHOME = $ENV{'KDEHOME'} || "$HOME/.kde"; $KONSOLE_BASE = "$KDEHOME/share/apps/konsole"; die "Usage: go \n" unless @ARGV==1; $host = shift; # get our konsole process $pid = (split " ", `ps -o "user pid ppid"|egrep "^$USER\[[:space:]\]+$$"`)[2]; $pid = (split " ", `ps -o "user pid ppid"|egrep "^$USER\[[:space:]\]+$pid"`)[2]; # now hack up a type $file = "$KONSOLE_BASE/$host.desktop"; $created_file = 0; if(! -d $KONSOLE_BASE){ system("mkdir -p $KONSOLE_BASE"); } if(! -f $file){ undef $/; @file = map { s/XXXX/$host/g; $_ } ; open(FH, ">$file") or die "Can't open $file: $!\n"; print FH @file; close FH; $created_file = 1; } # and exec `$DCOP konsole-$pid konsole newSession $host`; # if launched as og or launch, keep focus on # original session if($0 =~ /og/ or $0 =~ /launch/){ `$DCOP konsole-$pid konsole nextSession`; } # and clean if($created_file){ unlink "$file" or die "Can't unlink $file: $!\n"; } __DATA__ [Desktop Entry] Cwd= Exec=ssh -q XXXX Font= Icon=openterm KeyTab= Name=XXXX Schema=vim.schema Term=xterm Type=KonsoleApplication