#!/bin/sh #This script is licensed under GPL, -> http://www.gnu.org # #Original script: #Peppe Bergqvist #Visit http://peppesbodega.nu/node/Yakuake-F4 for updates. # #Fitted for KDE 4 by: #Maurizio Dal Magro #http://users.telenet.be/X86_64/Scripts/Yakuake4-F4 # #Is Yakuake running? if `! qdbus | grep yakuake > /dev/null 2>/dev/null`; then #If not, start Yakuake! exec yakuake & sleep 3 else #Yes, launch another session! qdbus org.kde.yakuake /yakuake/sessions addSession fi #Which window has Konqueror focus? Konqy=$(qdbus | grep konqueror) for i in $Konqy; do if [ $(qdbus $i /konqueror/MainWindow_1 Get QWidget isActiveWindow) = "true" ]; then Url=$(qdbus $i /konqueror/MainWindow_1 Get KonqMainWindow locationBarURL) break; fi done #If Yakuake is hidden, then acivate! if [ $(qdbus org.kde.yakuake /yakuake/MainWindow_1 Get QWidget visible) = "false" ]; then qdbus org.kde.yakuake /yakuake/window toggleWindowState fi #Now the real stuff! Url2=$(echo "$Url" | sed 's/ /\\ /g') Begin=$(echo $Url2 | grep -E "^(fish|sftp|ftp|smb|/)" - ) if [ `echo $Begin | cut -c1` == "/" ]; then #Do the task with cd! qdbus org.kde.yakuake /yakuake/sessions runCommand "cd $Url2" exit elif [ `echo $Begin | cut -c1-4` == "fish" ]; then Ssh=$(echo "$Url2" | sed 's/fish:\/\///') # Remove 'fish://'. elif [ `echo $Begin | cut -c1-4` == "sftp" ]; then Ssh=$(echo "$Url2" | sed 's/sftp:\/\///') # Remove 'sftp://'. elif [ `echo $Begin | cut -c1-3` == "ftp" ]; then Ssh=$(echo "$Url2" | sed 's/ftp:\/\///') # Remove 'ftp://'. elif [ `echo $Begin | cut -c1-3` == "smb" ]; then Ssh=$(echo "$Url2" | sed 's/smb:\/\///') # Remove 'smb://'. else exit fi dirstart=`expr index $Ssh /` # Where is '/'. dirend=`expr length $Ssh` # Length (number of chr) of the string. let dirlength=($dirend - $dirstart + 1) # Length (number of chr) from '/'. if [ `echo $dirstart` == "0" ]; then SshHost=$Ssh # There is no '/'. else SshDir=`expr substr $Ssh $dirstart $dirlength` # The folder behind '/'. SshHost=`expr substr $Ssh 1 $dirstart` # IP-adres + port + '/' -> 192.168.0.1:800/ fi SshHost=$(echo "$SshHost"|sed 's/\///') # Remove the '/'. SshHost=$(echo "$SshHost"|sed 's/:/ -p/') # Translate ':' -> ' -p'. #Do the task over ssh! qdbus org.kde.yakuake /yakuake/sessions runCommand "ssh $SshHost" sleep 20 qdbus org.kde.yakuake /yakuake/sessions runCommand "cd $SshDir" exit