Skip to content

Commit

Permalink
Disable buggy xdg-open/gvfs-open
Browse files Browse the repository at this point in the history
Xdg-open (or rather gvfs-open which it calls) has had a bug for nearly
1 year since GNOME 3.14 (now also on 3.16) where it does not work when
nautilus is not previously running. So let's disable it.
  • Loading branch information
bulletmark committed Jun 25, 2015
1 parent a915e4d commit 6606f0e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions encfsui
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ TITLE="Mount encfs directory"

CLS="--class EncFSUI"

# Xdg-open (or rather gvfs-open which it calls) has had a bug for nearly
# 1 year since GNOME 3.14 (now also on 3.16) where it does not work when
# nautilus is not previously running. So let's disable it.
#DIR_OPENER="xdg-open"
DIR_OPENER="nautilus"

# Process command line options
MINS=""
PUBLIC=""
Expand Down Expand Up @@ -77,7 +83,7 @@ if mount | grep -q "^encfs on $tgt "; then
fi

# Unmount it
res=$(fusermount -u $tgt 2>&1)
res=$(fusermount -u "$tgt" 2>&1)

# Output an error if the unmount failed
if [ $? -ne 0 ]; then
Expand All @@ -86,30 +92,36 @@ if mount | grep -q "^encfs on $tgt "; then
fi

# Remove target dir if it is empty
rmdir $tgt &>/dev/null
rmdir "$tgt" &>/dev/null
exit 0
fi

open-dir-gui() {
local dir="$1"
$DIR_OPENER $dir &>/dev/null &
}

# Mount the directory. Check first that this is an encfs filesystem
if ! encfsctl $src &>/dev/null; then
if ! encfsctl "$src" &>/dev/null; then

# Open terminal and run encfs to prompt user through creation
if ! xterm -fa monospace -fs 10 -T "$TITLE" \
-e "encfs $PUBLIC $MINS $src $tgt" &>/dev/null; then
-e "encfs $PUBLIC $MINS \"$src\" \"$tgt\"" &>/dev/null; then
zenity $CLS --title "$TITLE" --error --text \
"$src is not an encfs filesystem.\n\nCreate it manually with encfs."
exit 1
fi

if [ $NOOPEN -eq 0 ]; then
open-dir-gui "$tgt"
xdg-open $tgt &>/dev/null
fi

exit 0
fi

# Create target dir if it doesn't exist
mkdir -p $tgt &>/dev/null
mkdir -p "$tgt" &>/dev/null

# Loop on user entry for passphrase ..
mounted=0
Expand All @@ -128,12 +140,12 @@ while true; do
fi

# Give passphrase to encfs and mount the file system
res=$(echo "$res" | encfs -S $PUBLIC $MINS $src $tgt 2>&1)
res=$(echo "$res" | encfs -S $PUBLIC $MINS "$src" "$tgt" 2>&1)

# Check for error (typically a bad passphrase)
if [ $? -eq 0 ]; then
if [ $NOOPEN -eq 0 ]; then
xdg-open $tgt &>/dev/null
open-dir-gui "$tgt"
fi

mounted=1
Expand All @@ -144,7 +156,7 @@ while true; do
done

if [ $mounted -eq 0 ]; then
rmdir $tgt &>/dev/null
rmdir "$tgt" &>/dev/null
fi

exit 0

0 comments on commit 6606f0e

Please sign in to comment.