Script to Replace Nautilus for Dropbox

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

Script to Replace Nautilus for Dropbox

#1 Post by s243a »

Fatdog (and likely other slackware based versions of pupplinux) does not come with nautilus

The consequence is that when you right click on the dropbox icon (located on the taskbar after typing "dropbox start -i") you get the error "no nautilus" and the folder does not open. I found on another site that the trick is to replace nautilus with a bash scrip.

Here is my hack:

Code: Select all

#!/bin/bash
#echo 'hi'"$@" 1>&2
exec rox $2
exit 0
(script full name: /usr/local/bin/nautilus

The commented out echo was because I needed to see what the input arguments were which dropbox was passing to this script.

The arguments were:

Code: Select all

--no-desktop /root/dropbox
rox does not recognize the "--no-desktop" option. The proper way to do this script would be to process each argument one by one and then either translate or remove each option as needed. I may do this later when I get time. The risk of my hack is that some other program may think that nautilus exists and act in appropriately as a consequence.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#2 Post by technosaurus »

Here is a start... currently strips all options, but you can just add different case statements as needed for supported options

Code: Select all

#!/bin/sh
for x in $@; do
[ $INITIALIZED ] || INITIALIZED=1 && set --
case "$x" in
 -*);; #remove all options
 *)set $@ $x
esac
done
rox $@
If there is a rox option that is similar to the nautilus option, the case statement would look like:
--some-nautilus-option) set $@ --equivalent-rox-option;;
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#3 Post by s243a »

technosaurus wrote:Here is a start... currently strips all options, but you can just add different case statements as needed for supported options

Code: Select all

#!/bin/sh
for x in $@; do
[ $INITIALIZED ] || INITIALIZED=1 && set --
case "$x" in
 -*);; #remove all options
 *)set $@ $x
esac
done
rox $@
If there is a rox option that is similar to the nautilus option, the case statement would look like:
--some-nautilus-option) set $@ --equivalent-rox-option;;
I finally got around to trying this but I modified it some because I didn't understand some things in your script.

My script is

Code: Select all

#!/bin/sh
ARGS=()
for x in $@; do
case "$x" in
 --no-desktop);; #remove all options
 *)ARGS+=($X)
esac
done
rox ${ARGS[*]}
And I had help from the two stack overflow threads:

- Expanding an array in BASH [duplicate]
- https://stackoverflow.com/questions/21542054/how-to-intercept-and-remove-a-command-line-argument-in-bash

I never tried your script as you wrote it because I don't understand what "set --" does. I don't know the function of the "INITIALIZED" variable, and I don't understand how you can assign to the same variable that you are removing stuff from in a loop. It's probably some things that I don't know about linux but no-one always writes 100% bug free code.

Anyway, I tested my script and it works. Maybe you script would also work. I don't know. Thanks for the help though because I used your script as the starting point :)

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#4 Post by s243a »

s243a wrote:
I finally got around to trying this but I modified it some because I didn't understand some things in your script.

My script is

Code: Select all

#!/bin/sh
ARGS=()
for x in $@; do
case "$x" in
 --no-desktop);; #remove all options
 *)ARGS+=($X)
esac
done
rox ${ARGS[*]}
And I had help from the two stack overflow threads:

- Expanding an array in BASH [duplicate]
- https://stackoverflow.com/questions/21542054/how-to-intercept-and-remove-a-command-line-argument-in-bash

I never tried your script as you wrote it because I don't understand what "set --" does. I don't know the function of the "INITIALIZED" variable, and I don't understand how you can assign to the same variable that you are removing stuff from in a loop. It's probably some things that I don't know about linux but no-one always writes 100% bug free code.

Anyway, I tested my script and it works. Maybe you script would also work. I don't know. Thanks for the help though because I used your script as the starting point :)
I'm incorporating this into a dropbox package that I'm building for TazPup64 (available at this link). Here's the recepit, which contains the post install script.

Code: Select all

PACKED_SIZE="76.0K"
UNPACKED_SIZE="392.0K"
PACKAGE="dropbox" 
version="2019.02.14" 
category="util" 
SHORT_DESC="Virtualization Utility" 
MAINTAINE="Dropbox" 
WEB_SITE="https://www.dropbox.com/" 
DEPENDENCIES="python3-pygobject python3 atk glibc cairo glib gtk3 pango lsb-release gdk-pixbuf" 
post_install(){
#See post: http://www.murga-linux.com/puppy/viewtopic.php?p=981866#981866
if [ -z "`which nautilus`" ]; then
echo '#!/bin/sh 
ARGS=() 
for x in $@; do 
case "$x" in 
 --no-desktop);; #remove all options 
 *)ARGS+=($X) 
esac 
done 
rox ${ARGS[*]} ' > /usr/bin/nautilus
chmod +x /usr/bin/nautilus
fi
}
hope it works :)

User avatar
6502coder
Posts: 677
Joined: Mon 23 Mar 2009, 18:07
Location: Western United States

#5 Post by 6502coder »

In

Code: Select all

for x in $@; do
case "$x" in
 --no-desktop);; #remove all options
 *)ARGS+=($X)
esac

is that really supposed to be lowercase "x" in lines 1 and 2, but uppercase "x" in line 4?? Seems like it should be lowercase everywhere (or uppercase everywhere).

s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

#6 Post by s243a »

6502coder wrote:In

Code: Select all

for x in $@; do
case "$x" in
 --no-desktop);; #remove all options
 *)ARGS+=($X)
esac

is that really supposed to be lowercase "x" in lines 1 and 2, but uppercase "x" in line 4?? Seems like it should be lowercase everywhere (or uppercase everywhere).
Good eye! Looks like I need to fix this. :O

Post Reply