#!/bin/bash # rfs_konqueror -- 2 pane konqueror with remote file system # Use: # $ rfs_konqueror script_name [directory_name] # 28-Apr-20 -- First light, Marvin L Jones # # Mount a remote file system and open konqueror with # 2 panes -- one in the remote fs, one in $HOME/...somewhere. # "script_name" is any of several unique bash scripts that # mount (sshfs) remote file systems on a unique $HOME/ # directory for each unique mount. # E.g., `vps` is a script to sshfs mount the remote VPS # server on $HOME/VPS # Likewise `example.net` would be a script to mount the # root directory of the website on $HOME/EXAMPLE.NET # # Convention: lowercase script_name corresponds 1-to-1 # with UPPERCASE mount point in $HOME. # # "directory_name" is an optional directory in $HOME # on which the pane for the _local_ directory opens. # The default is "$HOME" # # Flow: # Mount the remote file system, and cd onto the mount point # to prevent it being umount'ed while we're active. # Then a dual-pane konqueror profile is built (if not yet # existing) specifying the local $HOME/..../ directory # and the remote directory. # Then konqueror is executed with this profile. # When konqueror ends, we cd out of the remote mount point # and umount the remote fs. # (We leave the profile for possible future use....) # # It is expected that this script will only be executed # from desktops objects. But, command line junquies # could make use of it. cd # Move to $HOME. cmd="$1" # Script for the remote dir dir=$(echo "$cmd" | tr 'a-z' 'A-Z') # dir (mount point) for the remote dir if [ $# -eq 2 ] then ldir="$HOME/$2/" # Specific $HOME/directory for pane 1 else ldir="$HOME/" # Default ... simpoly $HOME fi if [ ! -d $dir ] then # Set up for pop-up messages if we can... if [ `which kdialog` ] then kdialog --error "The mount point $dir/ does not exist ! !" \ --title "Error: $dir" else if [ `which zenity` ] then zenity --error --title="Error $dir" \ --text="The mount point $dir/ does not exist ! !" 2>/dev/null fi fi exit 1 fi $HOME/bin/$cmd # Execute the sshfs mount for the remote fs. cd $HOME/$dir # Move into & hold the remote dir. if [ "$(ls -ol)" = "total 0" ] # Verify it ain't the empty mount point. then echo "not mounted" # Set up for pop-up messages if we can... if [ `which kdialog` ] then kdialog --error "Unable to mount $dir/ ! !" \ --title "$dir Mount" else if [ `which zenity` ] then zenity --error --title="$dir mount" \ --text="Unable to mount $dir/ ! !" 2>/dev/null fi fi exit 2 fi profiles="$HOME/.trinity/share/apps/konqueror/profiles/" # konqueror's profiles dir. if [ ! -e "$profiles$cmd" ] # If this profile does not (yet) then # exist -- create it. while read setting do printf "$setting\n" >> "$profiles$cmd" # Output settings to new profile # Warning. There are "$" in an actual profile -- which need to be escaped below. done <