Nautilus Show Or Hide Files bash Script Not Working

Asked by Krishna on 2010-10-15

I just have a script with me for Showing Or Hiding Files In a Folder.

Here is the script

#!/bin/sh

OLDSTATE=$(gconftool-2 --get "/desktop/gnome/file_views/show_hidden_files")

if [ "$OLDSTATE" == "false" ] ; then
   NEWSTATE="True"
else
   NEWSTATE="False"
fi

gconftool-2 --set "/desktop/gnome/file_views/show_hidden_files" --type boolean $NEWSTATE

If I execute it in terminal it works. If I run it via right click -> Scripts, It's not working.

Please tell me how can I make it run via Right Click,..

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
Emre AYTAÇ
Solved:
2010-10-15
Last query:
2010-10-15
Last reply:
2010-10-15

In nautilus you can press CTRL + H and it will show / hide them

Krishna (krishnab) said : #2

Yes, I know that. But I am asking a solution for executing the script from the Right Click Menu...

Best Emre AYTAÇ (eaytac) said : #3

Hi;

I think the problem is "==", because the if statement should use like this;

#!/bin/bash
            if [ "foo" = "foo" ]; then
               echo expression evaluated as true
            else
               echo expression evaluated as false
            fi

So your script is;

#!/bin/sh

OLDSTATE=$(gconftool-2 --get "/desktop/gnome/file_views/show_hidden_files")

if [ "$OLDSTATE" = "false" ]; then
 NEWSTATE="true"
else
 NEWSTATE="false"
fi
gconftool-2 --set "/desktop/gnome/file_views/show_hidden_files" --type boolean $NEWSTATE

I hope this helps :)

Krishna (krishnab) said : #4

Oh... So simple...

I didn't observe that... I am more of a C Programmer and I didn't see that..

Yes that was the problem and solved the problem.

Script now works via Right Click -> Scripts....

Thank You Emre..