Nautilus Show Or Hide Files bash Script Not Working

Asked by Krishna

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:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

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

Revision history for this message
Krishna (krishnab) said :
#2

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

Revision history for this message
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 :)

Revision history for this message
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..