So, in order to hide some files and folders to unskilled eyes, I modified their names putting a dot to the start of the name. It works, and files are hidden. Nosy people that are not skilled will not see them. And using Nautilus I turn "show hidden files" on and off by using the key combination Ctrl–H. Fine. But then I never know if I leave the feature on or off.
I'd like to write a bash script that automatically starts every, say, 10 mins, and will turn off the "show hidden files" feature. So I would be sure that nosy eyes will never see hidden files.
Now the problem is that:
- I don't know what bash instruction to use, if any. I'm pretty sure that bash scripts can do almost everything, so, please help!
- I don't know how to automatically start the bash script every xx seconds or minutes.
How do I do it?
Best Answer
You can use
gsettings
to access the responsible setting in thedconf
registry easily from the command line.The setting whether to show hidden files (with names starting with
.
) is located in the schemaorg.gtk.Settings.FileChooser
and calledshow-hidden
.Allowed values are either
true
(show hidden files) orfalse
(don't show them).So here are the commands to enable or disable showing the hidden files:
To automatically run this command every x minutes, there are two good resources to learn how to achieve this:
Using
cron
(minimum resolution is 1 minute): help.ubuntu.com: Cron How-toNote that
cron
runs tasks with a very limited set ofenv
variables which do not includeDBUS_SESSION_BUS_ADDRESS
, but that's needed forgsettings
to work. So we have to take care of setting this variable ourselves in the script we run if we need itI prepared a script for you (with the help of @JacobVlijm who linked me this answer on Stack Overflow by @Radu Rădeanu) that takes care of this problem and can be run directly by
cron
:Without using
cron
: How to execute command every 10 seconds (without cron)?